You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code
It seems, that the combination of importing Debug, redefining it as a function and then setting a property on that function (Debug.enable) breaks the compiler.
importDebugfrom'debug'constcache: any[]=[]constMAX_LOGS=100constnamespaces: string[]=[]// for our use-case, map is faster, as retrieving values is faster than with Set or ObjectconstenabledNamespaces: Map<string,true>=newMap<string,true>()exportdefaultfunctionDebug(namespace: string): Debug.Debugger{constdebug: any=Debug(namespace)namespaces.push(namespace)Debug.enable(namespaces.join(','))debug.log=(...args)=>{cache.push(args)// keeping 100 logs is just a heuristic. The real truncating comes laterif(cache.length>MAX_LOGS){cache.shift()}if(enabledNamespaces.has(namespace)){console.error(...args)}}returndebug}Debug.enable=(namespace)=>{enabledNamespaces.set(namespace,true)}
Expected behavior: The compiler should give me a readable error message, that I have a naming conflict.
Actual behavior:
errors.ts:22 Uncaught Error: Cannot read property 'kind' of undefined
TypeError: Cannot read property 'kind' of undefined
at Object.e.isFunctionDeclaration (tsWorker.js:21)
at Object.$n [as getEffectiveTypeAnnotationNode] (tsWorker.js:21)
at tsWorker.js:21
at Vm (tsWorker.js:21)
at Qm (tsWorker.js:21)
at Jm (tsWorker.js:21)
at a_ (tsWorker.js:21)
at tsWorker.js:21
at Gy (tsWorker.js:21)
at tsWorker.js:21
at errors.ts:22
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
Code
It seems, that the combination of importing
Debug
, redefining it as a function and then setting a property on that function (Debug.enable
) breaks the compiler.Expected behavior: The compiler should give me a readable error message, that I have a naming conflict.
Actual behavior:
Playground Link
The text was updated successfully, but these errors were encountered: