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
Emitted code errors at runtime with reference error
π Expected behavior
If I am default exporting a type I'd like that to be dropped from the emitted code as to not error.
Since this is old behavior I'm guessing this might have something to do with globals that I do not understand? Any clarification on the issue is also super appreciated.
Thanks for the import type issue! I also agree that it should fail at compile time!
I assumed it wasn't emitted at all - not sure if this is useful to the decision making process but essentially what "bit me" from this behavior was.
Old codebase didn't properly annotate type imports and exports (as well importEqualsDeclaration use).
(Sorry if annotate is the wrong word I should mean isTypeOnly=true on the import/export specifiers)
I wrote a script to fix these cases.
A file that used to be a module now only exported types so webpack dropped it - (at least this is my understanding).
Code that used to say something like
const webpack_default_export = (some_webpack_module.thingThatisType)
became:
const webpack_default_export = (thingThatisType)
which is a reference error at runtime.
I think this is the only weird edge case I missed - but I thought it was worth the bug report - thanks for the fast response and info again - really appreciate it!
Doubt this is wanted/will be accepted but here is the the change necessary to make this a compile time error
(I went through the tests and ran my own test cases locally this seems to work as intended)
This would be added to checkExportAssignment at the time of writing on line 44685. This causes 21 test failures as this is a behavior change. Would you be open to a compiler flag - or perhaps adding this as an error to verbatim module syntax? Although I would personally prefer something like this as either a separate flag (verbatimModuleSyntax seems to have a lot of baggage) or as default behavior.
Activity
EliLichtblau commentedon Jul 20, 2023
Notably this errors
fatcerberus commentedon Jul 20, 2023
import typedoesn't mean what you think it does: #54990 (comment)If there's a bug here, it's that the
export defaultisn't being flagged as an error at compile time.EliLichtblau commentedon Jul 20, 2023
Thanks for the import type issue! I also agree that it should fail at compile time!
I assumed it wasn't emitted at all - not sure if this is useful to the decision making process but essentially what "bit me" from this behavior was.
Old codebase didn't properly annotate type imports and exports (as well importEqualsDeclaration use).
(Sorry if annotate is the wrong word I should mean isTypeOnly=true on the import/export specifiers)
I wrote a script to fix these cases.
A file that used to be a module now only exported types so webpack dropped it - (at least this is my understanding).
Code that used to say something like
const webpack_default_export = (some_webpack_module.thingThatisType)
became:
const webpack_default_export = (thingThatisType)
which is a reference error at runtime.
I think this is the only weird edge case I missed - but I thought it was worth the bug report - thanks for the fast response and info again - really appreciate it!
EliLichtblau commentedon Jul 20, 2023
Doubt this is wanted/will be accepted but here is the the change necessary to make this a compile time error
(I went through the tests and ran my own test cases locally this seems to work as intended)
This would be added to checkExportAssignment at the time of writing on line 44685. This causes 21 test failures as this is a behavior change. Would you be open to a compiler flag - or perhaps adding this as an error to verbatim module syntax? Although I would personally prefer something like this as either a separate flag (verbatimModuleSyntax seems to have a lot of baggage) or as default behavior.
Sorry if this is too intrusive!
Error on export default of type: issue microsoft#55087 (microsoft#55097)