TypeScript Version: 3.7.0-dev.20191002
Search Terms:
Code
Emitted index.d.ts from these JS files using --declaration --allowJs has an avoidable semantic error. It looks like the compiler usually avoids this error, but in this particular case it doesn't.
// foo.jsfunctionfoo(){}export{foo}// index.jsimport{foo}from'./foo'export{MyClass}functionMyClass(){}MyClass.prototype={method(){}}MyClass.foo=fooExpected behavior:
This declaration is emitted:
// index.d.tsexportfunctionMyClass(): void;exportclassMyClass{method(): void;}exportnamespaceMyClass{export{foo};import{foo}from"./foo";}export{};Actual behavior:
This declaration is emitted:
// index.d.tsexportfunctionMyClass(): void;exportclassMyClass{method(): void;}exportnamespaceMyClass{export{foo};}declarevarfoo: typeoffoo;// <-- foo circularly references selfimport{foo}from"./foo";// <-- import foo conflicts with var fooexport{};//# sourceMappingURL=index.d.ts.mapIt appears to be triggered by the combination of both function MyClass and MyClass.prototype = assignment. Removing one or the other fixes the bug, so that the import {foo} from './foo'; is nested within export namespace MyClass as in the "expected behavior" above.
Playground Link:
Related Issues:
TypeScript Version: 3.7.0-dev.20191002
Search Terms:
Code
Emitted
index.d.tsfrom these JS files using--declaration --allowJshas an avoidable semantic error. It looks like the compiler usually avoids this error, but in this particular case it doesn't.Expected behavior:
This declaration is emitted:
Actual behavior:
This declaration is emitted:
It appears to be triggered by the combination of both
function MyClassandMyClass.prototype =assignment. Removing one or the other fixes the bug, so that theimport {foo} from './foo';is nested withinexport namespace MyClassas in the "expected behavior" above.Playground Link:
Related Issues: