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
bug(typescript): Breaks on .d.ts declaration inputs #992
The plugin should not break on .d.ts inputs, including module declarations.
Actual Behavior
The plugin throws:
src/env.d.ts → dist...
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/env.d.ts (1:8)
1: declare module test {}
^
Thought this might've been something weird with the module keyword, but it doesn't appear to be, as declare const ... also throws:
src/env.d.ts → dist...
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/env.d.ts (2:8)
1: // declare module test {}
2: declare const helloWorld: RegExp;
^
Very confusing stuff. declare statements are (of course) supported in regular TS files, so adding a declare statement to src/input.ts does not change anything—but .d.ts files with onlydeclare statements break completely.
It's pretty unfeasible to run a Rollup pass on this TS project if it can't eat the env.d.ts file. Shocked this has been in production this long?
If any of this logic is ringing any bells for anyone, I can have a PR in by tomorrow for sure with a little guidance—if I don't hear back I'll just start dumpster diving through the plugin source, probably stick to same timeframe.
Side Note: Please use the "edit" feature on issues to cut down on notification noise. It's also easier to track all info if it's not split up between N successive replies
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ
Still an issue , This is required for example I am building a component library , I need to also export a type with styled-components to override the DefaultTheme type
Still an issue , This is required for example I am building a component library , I need to also export a type with styled-components to override the DefaultTheme type
This is exactly my use case. I have a modules.d.ts which declares the types fine while developing, but I need to build/publish this with the rest of the code. Just importing it to index.ts results in the above error
Still an issue , This is required for example I am building a component library , I need to also export a type with styled-components to override the DefaultTheme type
This is exactly my use case. I have a modules.d.ts which declares the types fine while developing, but I need to build/publish this with the rest of the code. Just importing it to index.ts results in the above error
This happens to me too, is there a way to fix this problem?
Still an issue , This is required for example I am building a component library , I need to also export a type with styled-components to override the DefaultTheme type
You can check the above solution, I don’t know if it can help you
Activity
ctjlewis commentedon Sep 5, 2021
Thought this might've been something weird with the
modulekeyword, but it doesn't appear to be, asdeclare const ...also throws:[-]bug(typescript): Breaks on declaration inputs[/-][+]bug(typescript): Breaks on .d.ts declaration inputs[/+]ctjlewis commentedon Sep 5, 2021
Very confusing stuff.
declarestatements are (of course) supported in regular TS files, so adding adeclarestatement tosrc/input.tsdoes not change anything—but.d.tsfiles with onlydeclarestatements break completely.It's pretty unfeasible to run a Rollup pass on this TS project if it can't eat the
env.d.tsfile. Shocked this has been in production this long?If any of this logic is ringing any bells for anyone, I can have a PR in by tomorrow for sure with a little guidance—if I don't hear back I'll just start dumpster diving through the plugin source, probably stick to same timeframe.
shellscape commentedon Sep 5, 2021
Side Note: Please use the "edit" feature on issues to cut down on notification noise. It's also easier to track all info if it's not split up between N successive replies
FPDK commentedon Oct 10, 2021
@ctjlewis Did you find a solution? I'm dealing with the same issue right now.
EDIT:
I changed the order of my plugin that used the .d.ts file and the problem is now resolved.
stale commentedon Dec 11, 2021
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ
wakaztahir commentedon Jul 13, 2023
Still an issue , This is required for example I am building a component library , I need to also export a type with styled-components to override the DefaultTheme type
samboylett commentedon Sep 14, 2023
This is exactly my use case. I have a modules.d.ts which declares the types fine while developing, but I need to build/publish this with the rest of the code. Just importing it to index.ts results in the above error
tangerball commentedon Dec 11, 2024
This happens to me too, is there a way to fix this problem?
tangerball commentedon Dec 11, 2024
Is there any example? I adjusted the plugin and the problem still occurs
ctjlewis commentedon Dec 11, 2024
tangerball commentedon Dec 13, 2024
I found a solution to process .d.ts files using transformers in @rollup-plugin-typescript
tangerball commentedon Dec 13, 2024
You can check the above solution, I don’t know if it can help you