diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a9d11787a14a3..54934139c5bf1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6130,7 +6130,7 @@ namespace ts { function inlineExportModifiers(statements: Statement[]) { // Pass 3: Move all `export {}`'s to `export` modifiers where possible - const index = findIndex(statements, d => isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && isNamedExports(d.exportClause)); + const index = findIndex(statements, d => isExportDeclaration(d) && !d.moduleSpecifier && !d.assertClause && !!d.exportClause && isNamedExports(d.exportClause)); if (index >= 0) { const exportDecl = statements[index] as ExportDeclaration & { readonly exportClause: NamedExports }; const replacements = mapDefined(exportDecl.exportClause.elements, e => { @@ -6162,7 +6162,8 @@ namespace ts { exportDecl.exportClause, replacements ), - exportDecl.moduleSpecifier + exportDecl.moduleSpecifier, + exportDecl.assertClause ); } } @@ -6798,7 +6799,8 @@ namespace ts { // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already - factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)) + factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), + /*assertClause*/ undefined ), ModifierFlags.None); break; case SyntaxKind.NamespaceImport: @@ -6806,7 +6808,8 @@ namespace ts { /*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, factory.createNamespaceImport(factory.createIdentifier(localName))), - factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)) + factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), + /*assertClause*/ undefined ), ModifierFlags.None); break; case SyntaxKind.NamespaceExport: @@ -6831,7 +6834,8 @@ namespace ts { factory.createIdentifier(localName) ) ])), - factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)) + factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), + /*assertClause*/ undefined ), ModifierFlags.None); break; case SyntaxKind.ExportSpecifier: diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 3d1b6fdb9a7d3..6112446acb606 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -287,6 +287,10 @@ namespace ts { updateImportDeclaration, createImportClause, updateImportClause, + createAssertClause, + updateAssertClause, + createAssertEntry, + updateAssertEntry, createNamespaceImport, updateNamespaceImport, createNamespaceExport, @@ -3790,7 +3794,8 @@ namespace ts { decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, - moduleSpecifier: Expression + moduleSpecifier: Expression, + assertClause: AssertClause | undefined ): ImportDeclaration { const node = createBaseDeclaration( SyntaxKind.ImportDeclaration, @@ -3799,6 +3804,7 @@ namespace ts { ); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; + node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); @@ -3812,13 +3818,15 @@ namespace ts { decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, - moduleSpecifier: Expression + moduleSpecifier: Expression, + assertClause: AssertClause | undefined ) { return node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier - ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + || node.assertClause !== assertClause + ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause), node) : node; } @@ -3847,6 +3855,38 @@ namespace ts { : node; } + // @api + function createAssertClause(elements: NodeArray | undefined): AssertClause { + const node = createBaseNode(SyntaxKind.AssertClause); + node.elements = elements; + node.transformFlags |= TransformFlags.ContainsESNext; + return node; + } + + // @api + function updateAssertClause(node: AssertClause, elements: NodeArray | undefined): AssertClause { + return node.elements !== elements + ? update(createAssertClause(elements), node) + : node; + } + + // @api + function createAssertEntry(name: AssertionKey, value: StringLiteral): AssertEntry { + const node = createBaseNode(SyntaxKind.AssertEntry); + node.name = name; + node.value = value; + node.transformFlags |= TransformFlags.ContainsESNext; + return node; + } + + // @api + function updateAssertEntry (node: AssertEntry, name: AssertionKey, value: StringLiteral): AssertEntry { + return node.name !== name + || node.value !== value + ? update(createAssertEntry(name, value), node) + : node; + } + // @api function createNamespaceImport(name: Identifier): NamespaceImport { const node = createBaseNode(SyntaxKind.NamespaceImport); @@ -3958,7 +3998,8 @@ namespace ts { modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, - moduleSpecifier?: Expression + moduleSpecifier?: Expression, + assertClause?: AssertClause ) { const node = createBaseDeclaration( SyntaxKind.ExportDeclaration, @@ -3968,6 +4009,7 @@ namespace ts { node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; + node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); @@ -3982,14 +4024,16 @@ namespace ts { modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, - moduleSpecifier: Expression | undefined + moduleSpecifier: Expression | undefined, + assertClause: AssertClause | undefined ) { return node.decorators !== decorators || node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier - ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier), node) + || node.assertClause !== assertClause + ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause), node) : node; } @@ -5776,9 +5820,9 @@ namespace ts { isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifiers, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifiers, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifiers, node.name, node.moduleReference) : - isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier) : + isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier, node.assertClause) : isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifiers, node.expression) : - isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier) : + isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) : Debug.assertNever(node); } diff --git a/src/compiler/factory/nodeTests.ts b/src/compiler/factory/nodeTests.ts index b7da2127f2aae..3da83e29dce98 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -517,6 +517,14 @@ namespace ts { return node.kind === SyntaxKind.ImportClause; } + export function isAssertClause(node: Node): node is AssertClause { + return node.kind === SyntaxKind.AssertClause; + } + + export function isAssertEntry(node: Node): node is AssertEntry { + return node.kind === SyntaxKind.AssertEntry; + } + export function isNamespaceImport(node: Node): node is NamespaceImport { return node.kind === SyntaxKind.NamespaceImport; } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 770600d94b71d..59503923f692c 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -446,7 +446,8 @@ namespace ts { /*decorators*/ undefined, /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), - nodeFactory.createStringLiteral(externalHelpersModuleNameText) + nodeFactory.createStringLiteral(externalHelpersModuleNameText), + /*assertClause*/ undefined ); addEmitFlags(externalHelpersImportDeclaration, EmitFlags.NeverApplyImportHelper); return externalHelpersImportDeclaration; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a815a12db9a53..533b8699e3746 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1690,6 +1690,11 @@ namespace ts { token() === SyntaxKind.NumericLiteral; } + function isAssertionKey(): boolean { + return tokenIsIdentifierOrKeyword(token()) || + token() === SyntaxKind.StringLiteral; + } + function parsePropertyNameWorker(allowComputedPropertyNames: boolean): PropertyName { if (token() === SyntaxKind.StringLiteral || token() === SyntaxKind.NumericLiteral) { const node = parseLiteralNode(); @@ -1854,6 +1859,8 @@ namespace ts { return isLiteralPropertyName(); case ParsingContext.ObjectBindingElements: return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName(); + case ParsingContext.AssertEntries: + return isAssertionKey() case ParsingContext.HeritageClauseElement: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. @@ -1974,6 +1981,7 @@ namespace ts { case ParsingContext.ObjectLiteralMembers: case ParsingContext.ObjectBindingElements: case ParsingContext.ImportOrExportSpecifiers: + case ParsingContext.AssertEntries: return token() === SyntaxKind.CloseBraceToken; case ParsingContext.SwitchClauseStatements: return token() === SyntaxKind.CloseBraceToken || token() === SyntaxKind.CaseKeyword || token() === SyntaxKind.DefaultKeyword; @@ -6901,13 +6909,33 @@ namespace ts { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); parseExpected(SyntaxKind.FromKeyword); } - const moduleSpecifier = parseModuleSpecifier(); + const afterSpecifierPos = scanner.getStartPos(); + + let assertClause: AssertClause | undefined; + if (token() === SyntaxKind.AssertKeyword && !scanner.hasPrecedingLineBreak()) { + assertClause = parseAssertClause(afterSpecifierPos); + } + parseSemicolon(); - const node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier); + const node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause); return withJSDoc(finishNode(node, pos), hasJSDoc); } + function parseAssertEntry () { + const pos = getNodePos(); + const name = tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(SyntaxKind.StringLiteral) as StringLiteral; + parseExpected(SyntaxKind.ColonToken) + const value = parseLiteralLikeNode(SyntaxKind.StringLiteral) as StringLiteral; + return finishNode(factory.createAssertEntry(name, value), pos); + } + + function parseAssertClause(pos: number) { + parseExpected(SyntaxKind.AssertKeyword) + const elements = parseList(ParsingContext.AssertEntries, parseAssertEntry) + return finishNode(factory.createAssertClause(elements), pos); + } + function tokenAfterImportDefinitelyProducesImportDeclaration() { return token() === SyntaxKind.AsteriskToken || token() === SyntaxKind.OpenBraceToken; } @@ -7058,6 +7086,7 @@ namespace ts { setAwaitContext(/*value*/ true); let exportClause: NamedExportBindings | undefined; let moduleSpecifier: Expression | undefined; + let assertClause: AssertClause | undefined; const isTypeOnly = parseOptional(SyntaxKind.TypeKeyword); const namespaceExportPos = getNodePos(); if (parseOptional(SyntaxKind.AsteriskToken)) { @@ -7077,9 +7106,13 @@ namespace ts { moduleSpecifier = parseModuleSpecifier(); } } + if (token() === SyntaxKind.AssertKeyword && !scanner.hasPrecedingLineBreak()) { + const posAfterSpecifier = getNodePos(); + assertClause = parseAssertClause(posAfterSpecifier); + } parseSemicolon(); setAwaitContext(savedAwaitContext); - const node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier); + const node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause); return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7159,7 +7192,8 @@ namespace ts { TypeArguments, // Type arguments in type argument list TupleElementTypes, // Element types in tuple element type list HeritageClauses, // Heritage clauses for a class or interface declaration. - ImportOrExportSpecifiers, // Named import clause's import specifier list + ImportOrExportSpecifiers, // Named import clause's import specifier list, + AssertEntries, // Import entries list. Count // Number of parsing contexts } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 76fa4b62aab9c..297c0966f8c97 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2120,7 +2120,7 @@ namespace ts { && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration const externalHelpersModuleReference = factory.createStringLiteral(externalHelpersModuleNameText); - const importDecl = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference); + const importDecl = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); addEmitFlags(importDecl, EmitFlags.NeverApplyImportHelper); setParent(externalHelpersModuleReference, importDecl); setParent(importDecl, file); diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index af12fbe19258e..d1505304f85c7 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -702,7 +702,8 @@ namespace ts { /*decorators*/ undefined, decl.modifiers, decl.importClause, - rewriteModuleSpecifier(decl, decl.moduleSpecifier) + rewriteModuleSpecifier(decl, decl.moduleSpecifier), + decl.assertClause ); } // The `importClause` visibility corresponds to the default's visibility. @@ -714,7 +715,7 @@ namespace ts { decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined, - ), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); + ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), decl.assertClause); } if (decl.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { // Namespace import (optionally with visible default) @@ -724,7 +725,7 @@ namespace ts { decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings, - ), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; + ), rewriteModuleSpecifier(decl, decl.moduleSpecifier), decl.assertClause) : undefined; } // Named imports (optionally with visible default) const bindingList = mapDefined(decl.importClause.namedBindings.elements, b => resolver.isDeclarationVisible(b) ? b : undefined); @@ -739,7 +740,8 @@ namespace ts { visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined, ), - rewriteModuleSpecifier(decl, decl.moduleSpecifier) + rewriteModuleSpecifier(decl, decl.moduleSpecifier), + decl.assertClause ); } // Augmentation of export depends on import @@ -749,7 +751,8 @@ namespace ts { /*decorators*/ undefined, decl.modifiers, /*importClause*/ undefined, - rewriteModuleSpecifier(decl, decl.moduleSpecifier) + rewriteModuleSpecifier(decl, decl.moduleSpecifier), + decl.assertClause ); } // Nothing visible @@ -1084,6 +1087,7 @@ namespace ts { input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), + input.assertClause ); } case SyntaxKind.ExportAssignment: { diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 544275c6d201b..a802a7950512f 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -77,7 +77,7 @@ namespace ts { const specifier = `${currentFileState.importSpecifier}/${compilerOptions.jsx === JsxEmit.ReactJSXDev ? "jsx-dev-runtime" : "jsx-runtime"}`; if (isExternalModule(node)) { // Add `import` statement - const importStatement = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(arrayFrom(currentFileState.utilizedImplicitRuntimeImports.values()))), factory.createStringLiteral(specifier)); + const importStatement = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(arrayFrom(currentFileState.utilizedImplicitRuntimeImports.values()))), factory.createStringLiteral(specifier), /*assertClause*/ undefined); setParentRecursive(importStatement, /*incremental*/ false); statements = insertStatementAfterCustomPrologue(statements.slice(), importStatement); } diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index 24fd849e52bf2..b0dec59c55d89 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -96,6 +96,7 @@ namespace ts { ) ), node.moduleSpecifier, + node.assertClause ); setOriginalNode(importDecl, node.exportClause); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 3e2e789259915..eb6a0f606609b 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2828,7 +2828,9 @@ namespace ts { /*decorators*/ undefined, /*modifiers*/ undefined, importClause, - node.moduleSpecifier) + node.moduleSpecifier, + node.assertClause + ) : undefined; } @@ -2919,7 +2921,8 @@ namespace ts { /*modifiers*/ undefined, node.isTypeOnly, exportClause, - node.moduleSpecifier) + node.moduleSpecifier, + node.assertClause) : undefined; } @@ -2984,6 +2987,7 @@ namespace ts { /*modifiers*/ undefined, /*importClause*/ undefined, node.moduleReference.expression, + /*assertClause*/ undefined ), node, ), diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fbf308707a10d..e2c088a2f1509 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -159,6 +159,7 @@ namespace ts { AbstractKeyword, AsKeyword, AssertsKeyword, + AssertKeyword, AnyKeyword, AsyncKeyword, AwaitKeyword, @@ -337,6 +338,8 @@ namespace ts { DefaultClause, HeritageClause, CatchClause, + AssertClause, + AssertEntry, // Property assignments PropertyAssignment, @@ -536,6 +539,7 @@ namespace ts { | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword + | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword @@ -1006,6 +1010,7 @@ namespace ts { } export type AssertsKeyword = KeywordToken; + export type AssertKeyword = KeywordToken; export type AwaitKeyword = KeywordToken; /** @deprecated Use `AwaitKeyword` instead. */ @@ -1013,6 +1018,7 @@ namespace ts { /** @deprecated Use `AssertsKeyword` instead. */ export type AssertsToken = AssertsKeyword; + export type AssertToken = AssertKeyword; export interface ModifierToken extends KeywordToken { } @@ -2947,6 +2953,7 @@ namespace ts { readonly importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier: Expression; + readonly assertClause?: AssertClause; } export type NamedImportBindings = @@ -2973,6 +2980,21 @@ namespace ts { readonly namedBindings?: NamedImportBindings; } + export type AssertionKey = Identifier | StringLiteral; + + export interface AssertEntry extends Node { + readonly kind: SyntaxKind.AssertEntry; + readonly parent: AssertClause; + readonly name: AssertionKey; + readonly value: StringLiteral; + } + + export interface AssertClause extends Node { + readonly kind: SyntaxKind.AssertClause; + readonly parent: ImportDeclaration | ExportDeclaration + readonly elements?: NodeArray + } + export interface NamespaceImport extends NamedDeclaration { readonly kind: SyntaxKind.NamespaceImport; readonly parent: ImportClause; @@ -3000,6 +3022,7 @@ namespace ts { readonly exportClause?: NamedExportBindings; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier?: Expression; + readonly assertClause?: AssertClause; } export interface NamedImports extends Node { @@ -6982,10 +7005,14 @@ namespace ts { updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; + createAssertClause(elements: NodeArray | undefined): AssertClause; + updateAssertClause(node: AssertClause, elements: NodeArray | undefined): AssertClause; + createAssertEntry(name: AssertionKey, value: StringLiteral): AssertEntry; + updateAssertEntry (node: AssertEntry, name: AssertionKey, value: StringLiteral): AssertEntry; createNamespaceImport(name: Identifier): NamespaceImport; updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; createNamespaceExport(name: Identifier): NamespaceExport; @@ -6996,8 +7023,8 @@ namespace ts { updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; - createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression): ExportDeclaration; - updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 899936e5962b4..c0c8a0fad2e65 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -935,7 +935,8 @@ namespace ts { nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), nodeVisitor((node).importClause, visitor, isImportClause), - nodeVisitor((node).moduleSpecifier, visitor, isExpression)); + nodeVisitor((node).moduleSpecifier, visitor, isExpression), + nodeVisitor((node).assertClause, visitor, isAssertClause)); case SyntaxKind.ImportClause: return factory.updateImportClause(node, @@ -972,7 +973,8 @@ namespace ts { nodesVisitor((node).modifiers, visitor, isModifier), (node as ExportDeclaration).isTypeOnly, nodeVisitor((node).exportClause, visitor, isNamedExportBindings), - nodeVisitor((node).moduleSpecifier, visitor, isExpression)); + nodeVisitor((node).moduleSpecifier, visitor, isExpression), + nodeVisitor((node).assertClause, visitor, isAssertClause)); case SyntaxKind.NamedExports: return factory.updateNamedExports(node,