Repository navigation
Synthesize namespace records for proper esm interop #19675
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
Changes from 1 commit
213146d
b5a7ef9
8abc907
2d0c8d3
a725916
e910603
e84b051
f23d41c
ebd4c03
3b33df0
7ff11bb
bcafdba
eaf2fc5
29c731c
4350caf
e20a548
578141d
dfe5675
8c6c313
3d996d7
2f9c240
2361f37
357996b
a682476
6e9e874
a654b82
ef6faf1
a8233b3
f4f4e84
386c54d
2663db7
8068e2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,14 +25,14 @@ namespace ts { | |
| if (externalHelpersModuleName) { | ||
| const statements: Statement[] = []; | ||
| const statementOffset = addPrologue(statements, node.statements); | ||
| append(statements, | ||
| createImportDeclaration( | ||
| /*decorators*/ undefined, | ||
| /*modifiers*/ undefined, | ||
| createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), | ||
| createLiteral(externalHelpersModuleNameText) | ||
| ) | ||
| const tslibImport = createImportDeclaration( | ||
| /*decorators*/ undefined, | ||
| /*modifiers*/ undefined, | ||
| createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), | ||
| createLiteral(externalHelpersModuleNameText) | ||
| ); | ||
| tslibImport.transformFlags |= TransformFlags.NeverApplyImportHelper; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't set transform flags explicitly. See my related comment in program.ts. |
||
| append(statements, tslibImport); | ||
|
|
||
| addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset)); | ||
| return updateSourceFileNode( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,6 +143,7 @@ namespace ts { | |
| createLiteral(externalHelpersModuleNameText)); | ||
|
|
||
| if (externalHelpersImportDeclaration) { | ||
| externalHelpersImportDeclaration.transformFlags |= TransformFlags.NeverApplyImportHelper; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't set transform flags explicitly. See my related comment in program.ts. |
||
| externalImports.unshift(externalHelpersImportDeclaration); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4266,6 +4266,7 @@ namespace ts { | |
| ContainsYield = 1 << 24, | ||
| ContainsHoistedDeclarationOrCompletion = 1 << 25, | ||
| ContainsDynamicImport = 1 << 26, | ||
| NeverApplyImportHelper = 1 << 27, // Indicates the node should never be wrapped with an import star helper (because, for example, it import tslib itself) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be on |
||
|
|
||
| // Please leave this as 1 << 29. | ||
| // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. | ||
|
|
@@ -4305,6 +4306,7 @@ namespace ts { | |
| // - Additional bitmasks | ||
| TypeScriptClassSyntaxMask = ContainsParameterPropertyAssignments | ContainsPropertyInitializer | ContainsDecorators, | ||
| ES2015FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, | ||
| StickyFlags = NeverApplyImportHelper, // Flags which once set are retained by `aggregateTransformFlags` instead of overwritten | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't need this if |
||
| } | ||
|
|
||
| export interface SourceMapRange extends TextRange { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1466,7 +1466,9 @@ namespace ts { | |
| * Aggregates the TransformFlags for a Node and its subtree. | ||
| */ | ||
| export function aggregateTransformFlags<T extends Node>(node: T): T { | ||
| const stickyFlags = node.transformFlags & TransformFlags.StickyFlags; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is a good approach. |
||
| aggregateTransformFlagsForNode(node); | ||
| node.transformFlags |= stickyFlags; | ||
| return node; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only place that should be setting
transformFlagsiscomputeTransformFlagsForNodein binder.ts (the only notable exception isconvertIterationStatementBodyIfNecessaryin es2015.ts, which I'd eventually like to fix as well). This seems like it should be onEmitFlagsinstead.