-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--esModuleInterop changes meaning of declaration #21535
Comments
I'm not really a fan of eliding the error just because the source import is in a definition file. It's a legitimate shape (reexporting the namespace as a member) that would strip the call and construct signatures if the .d.ts truly reflects the source. I think doing this for compat reasons may hamstring our ability to catch real errors - each of these files could easily be generated from the user's own code and actually be indicative of an issue. |
@andy-ms You suggestion in the associated dt PR:
Is really the correct fix. You shouldn't use an es6-style import if you don't want es6-style semantics. |
Chatted with @weswigham offline, we need to go update definitelytyped to remove all references of this form to avoid users having to deal with the error. |
@weswigham can you run the tests and let us know which ones need updating? i would be happy to help fixing them as needed. |
I opened DefinitelyTyped/DefinitelyTyped#23355 with fixes for the packages that I identified had issues. I can't seem to load @andy-ms 's PR that enables the flag on all packages at DefinitelyTyped/DefinitelyTyped#23354 - it keeps Unicorn'ing. |
@weswigham If it helps, I was able to load the page in a Chrome incognito window; maybe not being logged into GitHub has some effect. |
It also would be great if we could get, in writing, in some DefinitelyTyped guidelines, that you always must write As an example, a lot of the pull requests to |
So is this then not considered a bug? I think this is good behavior as @weswigham stated. |
Had a chat about this offline, now that DefinitelyTyped has been updated, we will add a new lint rule to ensure that reexports of an |
That's backwards; the problem is namespace imports, not default imports. If you do a default import, you'll just get a compile error; if you do a namespace import, you'll get a runtime error. |
The namespace imports are flagged in the type checker, as all packages now have |
Yes. The (commonjs) package exports a single top-level function. You should import as |
Hmm, when I use
|
I assume with |
Yes. |
Right, so you need to set |
TypeScript Version: 2.8.0-dev.20180201
Code
m.d.ts
n.d.ts
a.ts
Expected behavior:
No error.
Actual behavior:
No error normally. With
tsc --esModuleInterop
:The user may not have control over the definition file, so I think we could a) omit the error in the definition file, and b) preserve the original meaning where
typeof m
is callable.The text was updated successfully, but these errors were encountered: