Skip to content

--moduleResolution bundler: Allow import assignment in ambient contexts #51971

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

Merged

Conversation

andrewbranch
Copy link
Member

Adds an overlooked check for ambient context in --moduleResolution bundler. I was trying to dogfood the mode in a side project, and immediately got a bunch of errors inside node_modules because of this.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Dec 20, 2022
@andrewbranch andrewbranch changed the title --moduleResoltuion bunlder: Allow import assignment in ambient contexts --moduleResolution bundler: Allow import assignment in ambient contexts Dec 20, 2022
@andrewbranch
Copy link
Member Author

WOW that spelling

@@ -42778,7 +42778,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// Import equals declaration is deprecated in es6 or above
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
}
else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) {
else if (!(node.flags & NodeFlags.Ambient) && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems okay - I might try to reorder this to make it consistent with the above check

(also, you might want to just hoist the node.flags up a level.

@andrewbranch andrewbranch merged commit 714d734 into microsoft:main Dec 20, 2022
@andrewbranch andrewbranch deleted the bug/bundler-ambient-import-equals branch December 20, 2022 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants