-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Cannot import in 3.0.1: A declaration file cannot be imported without 'import type' #3620
Comments
Hey! I expected that, but I couldn't reproduce it. I'd appreciate it if you could produce a minimal repro example. |
@perrin4869 please try |
beautiful, that seems to have done the trick!!! thanks!! |
I ran into this as well. @kossnocorp - I see the solution in 3.0.2-rc.1 is to copy the contents of the .d.ts files to the .d.mts files. Why not just modify the exports in the package.json and do away with all the .d.mts files? TypeScript won't care about the extension as long as the exports are setup correctly. You could simplify the exports as well... Each export like this one... "./addMinutes": {
"require": {
"types": "./addMinutes.d.ts",
"default": "./addMinutes.js"
},
"import": {
"types": "./addMinutes.d.mts",
"default": "./addMinutes.mjs"
}
}, could be reduced to... "./addMinutes": {
"types": "./addMinutes.d.ts",
"require": "./addMinutes.js"
"import": "./addMinutes.mjs"
}, |
@nstuyvesant I think you're right, and it's possible to point to the same Regarding reducing, it's possible as it will give another error. |
Shipped the fix with |
Unfortunately, I messed up attw results, and pointing to the same d.ts indeed gives the error: https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md So I rolled back to the original solution by copying the content and released it as |
I can't find other reports here yet, but I ran into #3588 like everyone else, but unfortunately the fix introduced a new error in my case:
../../node_modules/date-fns/index.d.mts(1,15): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './index.js' instead?
I am guessing this might be the reason that
import type
was there originally in3.0.0
. Not quite sure what the fix is though, it's quite surprising...I can try to put together a reproduction later
The text was updated successfully, but these errors were encountered: