-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
TS1479 Unable to import types from ESM package when moduleResolution is nodenext #54523
Comments
A simple workaround for now is to put a // @ts-expect-error moduleResolution:nodenext issue 54523
import type {SomeType} from 'some-lib' |
Known issue, see #52529. |
Seeing this as well after updating TS, workaround doesn't work as the type is still seen as non-existent. |
I think you can add the resolution-mode import assertion and ts-ignore the error that tells you not to do that. import type { SomeType } from 'some-lib' assert { "resolution-mode": "module" } This will become an import attribute and not illegal once we land support for import attributes. |
This issue has been marked as 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
This is currently the correct way I guess: import type { SomeType } from 'some-lib' with { 'resolution-mode': 'import' }; |
Bug Report
When I set
moduleResolution: "nodenext"
I see this error when I try toimport type
from a package:Then I tried to switch to dynamic
import()
(even in for a type, not a runtime value), and get the same error:With runtime value, we can typically switch to dynamic
import()
to get around the problem. But with type imports, this is not getting around the problem.Here's the error message for searchability:
error message (click to open)
Note that the error says
which is what I've done with
import('wazum').Add
.Adding
typeof
has the same issue:Note, the
wazum
package is not the one currently at https://npmjs.com/wazum, but the one installed from my current GitHub fork:npm install 'wazum@trusktr/wazum#simple-esm-dist-output'
🔎 Search Terms
typescript moduleResolution nodenext unable to import types
🕗 Version & Regression Information
Not sure when it regressed, if at all.
⏯ Playground Link
I am unable to provide a playground link because it doesn't seem to be configurable with the required options.
TODO: make a clonable reproduction.
💻 Code
Here's my tsconfig:
🙁 Actual behavior
Unable to import types.
🙂 Expected behavior
Expect there to be some way to import types.
import type
imports are not regular ES Module imports, so it seems likeimport type {...} from '...'
should just work, however I understand if it should match with the runtimeimport()
requirement for CommonJS output for consistency, but that's just not working either.Plus using dynamic
import()
syntax for type imports is too cumbersome because some features are missing, f.e. the ability to import generic types:So even if
import()
is what I should be doing (currently not working)import type
would be better.The text was updated successfully, but these errors were encountered: