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
{{ message }}
Repository navigation
Incorrect declaration emit for allowJs JavaScript class with static members imported from other files #33777
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.
// 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.map
It 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.
To the OP: This should now be fixed on master (so should go out in the next nightly) and in the next 3.7 cut (which should be final release at this point?), by #34786 (essentially a dupe of one of the reports in #33626)
you're not allowed to have an import statement in a namespace, and the top-level export {}; is unneeded in your example (as something in the file is exported, so the file's definitely a module, and there's no privates which need their scoping preserved)~
Activity
weswigham commentedon Oct 30, 2019
To the OP: This should now be fixed on
master(so should go out in the next nightly) and in the next 3.7 cut (which should be final release at this point?), by #34786 (essentially a dupe of one of the reports in #33626)Your expected emit is a lil off though; we emit:
you're not allowed to have an
importstatement in a namespace, and the top-levelexport {};is unneeded in your example (as something in the file is exported, so the file's definitely a module, and there's no privates which need their scoping preserved)~typescript-bot commentedon Nov 2, 2019
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.