diff --git a/web-infras/common/src/ast/module.ts b/web-infras/common/src/ast/module.ts index 3879b3bd..c0c991a4 100644 --- a/web-infras/common/src/ast/module.ts +++ b/web-infras/common/src/ast/module.ts @@ -15,6 +15,7 @@ import { Declaration, ClassDeclaration, FunctionDeclaration, TSDeclaration } fro export interface ImportDeclaration extends ModuleItem { kind: SyntaxKinds.ImportDeclaration; specifiers: Array; + importKind: "type" | "value"; source: StringLiteral; attributes: ImportAttribute[] | undefined; } @@ -25,6 +26,7 @@ export interface ImportDefaultSpecifier extends ModuleItem { export interface ImportSpecifier extends ModuleItem { kind: SyntaxKinds.ImportSpecifier; imported: Identifier | StringLiteral; + isTypeOnly: boolean; local: Identifier | null; } export interface ImportNamespaceSpecifier extends ModuleItem { @@ -44,6 +46,7 @@ export interface ExportNamedDeclarations extends ModuleItem { export interface ExportSpecifier extends ModuleItem { kind: SyntaxKinds.ExportSpecifier; exported: Identifier | StringLiteral; + isTypeOnly: boolean; local: Identifier | StringLiteral | null; } export interface ExportDefaultDeclaration extends ModuleItem { diff --git a/web-infras/common/src/factory/module.ts b/web-infras/common/src/factory/module.ts index 25ea113b..595634ef 100644 --- a/web-infras/common/src/factory/module.ts +++ b/web-infras/common/src/factory/module.ts @@ -12,6 +12,7 @@ export function createProgram( export function createImportDeclaration( specifiers: AST.ImportDeclaration["specifiers"], source: AST.ImportDeclaration["source"], + importKind: AST.ImportDeclaration["importKind"], attributes: AST.ImportDeclaration["attributes"], start: SourcePosition, end: SourcePosition, @@ -19,6 +20,7 @@ export function createImportDeclaration( return { kind: SyntaxKinds.ImportDeclaration, specifiers, + importKind, source, attributes, start, @@ -52,6 +54,7 @@ export function createImportNamespaceSpecifier( export function createImportSpecifier( imported: AST.ImportSpecifier["imported"], local: AST.ImportSpecifier["local"], + isTypeOnly: AST.ImportSpecifier["isTypeOnly"], start: SourcePosition, end: SourcePosition, ): AST.ImportSpecifier { @@ -59,6 +62,7 @@ export function createImportSpecifier( kind: SyntaxKinds.ImportSpecifier, imported, local, + isTypeOnly, start, end, }; @@ -82,6 +86,7 @@ export function createExportNamedDeclaration( specifiers: AST.ExportNamedDeclarations["specifiers"], declaration: AST.ExportNamedDeclarations["declaration"], source: AST.ExportNamedDeclarations["source"], + start: SourcePosition, end: SourcePosition, ): AST.ExportNamedDeclarations { @@ -97,12 +102,14 @@ export function createExportNamedDeclaration( export function createExportSpecifier( exported: AST.ExportSpecifier["exported"], local: AST.ExportSpecifier["local"], + isTypeOnly: AST.ExportSpecifier["isTypeOnly"], start: SourcePosition, end: SourcePosition, ): AST.ExportSpecifier { return { kind: SyntaxKinds.ExportSpecifier, exported, + isTypeOnly, local, start, end, diff --git a/web-infras/parser/src/dev.ts b/web-infras/parser/src/dev.ts index 5a600ff3..2b6ce662 100644 --- a/web-infras/parser/src/dev.ts +++ b/web-infras/parser/src/dev.ts @@ -5,6 +5,7 @@ import { transformSyntaxKindToLiteral } from "../tests/parserRunner/helpers/tran import fs from "fs"; import path from "path"; import { ParserPlugin } from "./parser/config"; +import { createErrorHandler } from "./errorHandler"; // import { ParserPlugin } from "./parser/config"; const code = fs.readFileSync(path.join(__dirname, "test.ts")).toString(); // console.log(code); @@ -32,7 +33,7 @@ function printLexer(code: string) { console.log("============ lexer =============="); console.log("================================="); - const lexer = createLexer(code); + const lexer = createLexer(code, createErrorHandler(code)); while (lexer.getTokenKind() != SyntaxKinds.EOFToken) { console.log( lexer.getTokenKind(), @@ -51,7 +52,7 @@ function printLexer(code: string) { ); } function printParser(code: string) { - const ast = parse(code, { sourceType: "script", plugins: [ParserPlugin.TypeScript] }); + const ast = parse(code, { sourceType: "module", plugins: [ParserPlugin.TypeScript] }); transformSyntaxKindToLiteral(ast); const astJsonString = JSON.stringify(ast, null, 4); fs.writeFileSync("./test.json", astJsonString); diff --git a/web-infras/parser/src/parser/error.ts b/web-infras/parser/src/parser/error.ts index f32e5966..deb549c0 100644 --- a/web-infras/parser/src/parser/error.ts +++ b/web-infras/parser/src/parser/error.ts @@ -264,4 +264,6 @@ export const ErrorMessageMap = { "TS 1245: Method {} cannot have an implementation because it is marked abstract.", ts_1267_property_cannot_have_an_initializer_because_it_is_marked_abstract: "TS 1267: Property '{}' cannot have an initializer because it is marked abstract.", + ts_1363_A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both: + "TS 1363: A type-only import can specify a default import or named bindings, but not both.", }; diff --git a/web-infras/parser/src/parser/js/module.ts b/web-infras/parser/src/parser/js/module.ts index abdfcdce..b3d33edf 100644 --- a/web-infras/parser/src/parser/js/module.ts +++ b/web-infras/parser/src/parser/js/module.ts @@ -25,7 +25,7 @@ import { import { ParserPlugin } from "@/src/parser/config"; import { ErrorMessageMap } from "@/src/parser/error"; import { ExportContext } from "@/src/parser/scope/lexicalScope"; -import { KeywordSet } from "@/src/parser/type"; +import { IdentiferWithKeyworArray, KeywordSet } from "@/src/parser/type"; import { Parser } from "@/src/parser"; export function parseProgram(this: Parser) { @@ -114,6 +114,14 @@ export function parseImportDeclaration(this: Parser): ImportDeclaration { start, ); } + let importKind: ImportDeclaration["importKind"] = "value"; + if (this.isContextKeyword("type")) { + const { kind, value } = this.lookahead(); + if (!((kind === SyntaxKinds.Identifier && value === "from") || kind === SyntaxKinds.StringLiteral)) { + this.nextToken(); + importKind = "type"; + } + } const specifiers: Array = []; if (this.match(SyntaxKinds.StringLiteral)) { const source = this.parseStringLiteral(); @@ -122,6 +130,7 @@ export function parseImportDeclaration(this: Parser): ImportDeclaration { return Factory.createImportDeclaration( specifiers, source, + importKind, attributes, start, cloneSourcePosition(source.end), @@ -136,6 +145,7 @@ export function parseImportDeclaration(this: Parser): ImportDeclaration { return Factory.createImportDeclaration( specifiers, source, + importKind, attributes, start, cloneSourcePosition(source.end), @@ -150,6 +160,7 @@ export function parseImportDeclaration(this: Parser): ImportDeclaration { return Factory.createImportDeclaration( specifiers, source, + importKind, attributes, start, cloneSourcePosition(source.end), @@ -159,8 +170,18 @@ export function parseImportDeclaration(this: Parser): ImportDeclaration { if (this.match(SyntaxKinds.CommaToken)) { this.nextToken(); if (this.match(SyntaxKinds.BracesLeftPunctuator)) { + if (importKind === "type") + this.raiseError( + ErrorMessageMap.ts_1363_A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both, + this.getStartPosition(), + ); this.parseImportSpecifiers(specifiers); } else if (this.match(SyntaxKinds.MultiplyOperator)) { + if (importKind === "type") + this.raiseError( + ErrorMessageMap.ts_1363_A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both, + this.getStartPosition(), + ); specifiers.push(this.parseImportNamespaceSpecifier()); } else { throw this.createMessageError( @@ -175,6 +196,7 @@ export function parseImportDeclaration(this: Parser): ImportDeclaration { return Factory.createImportDeclaration( specifiers, source, + importKind, attributes, start, cloneSourcePosition(source.end), @@ -239,43 +261,90 @@ export function parseImportSpecifiers( if (this.match(SyntaxKinds.BracesRightPunctuator) || this.match(SyntaxKinds.EOFToken)) { break; } - const imported = this.parseModuleExportName(); - if (!this.isContextKeyword("as")) { - if (isIdentifer(imported) && KeywordSet.has(imported.name)) { - // recoverable error - this.raiseError(ErrorMessageMap.extra_error_unexpect_keyword_in_module_name, imported.start); - } else if (isStringLiteral(imported)) { - // recoverable error - this.raiseError( - ErrorMessageMap.babel_error_string_literal_cannot_be_used_as_an_imported_binding, - imported.start, - ); - } - if (isIdentifer(imported)) this.declarateLetSymbol(imported.name, imported.start); - specifiers.push( - Factory.createImportSpecifier( - imported, - null, - cloneSourcePosition(imported.start), - cloneSourcePosition(imported.end), - ), - ); - continue; - } + specifiers.push(this.parseImportSpecifier()); + } + this.expect(SyntaxKinds.BracesRightPunctuator); +} + +export function parseImportSpecifier(this: Parser): ImportSpecifier { + const start = this.getStartPosition(); + // eslint-disable-next-line prefer-const + let [shouleParseAs, imported, local, isTypeOnly] = this.parseTypePrefixOfSpecifier("import"); + if (shouleParseAs && this.isContextKeyword("as")) { this.nextToken(); - const local = this.parseIdentifierReference(); + local = this.parseIdentifierReference(); this.declarateLetSymbol(local.name, local.start); - specifiers.push( - Factory.createImportSpecifier( - imported, - local, - cloneSourcePosition(imported.start), - cloneSourcePosition(local.end), - ), + return Factory.createImportSpecifier(imported, local, isTypeOnly, start, this.getLastTokenEndPositon()); + } + if (isIdentifer(imported) && KeywordSet.has(imported.name)) { + // recoverable error + this.raiseError(ErrorMessageMap.extra_error_unexpect_keyword_in_module_name, imported.start); + } else if (isStringLiteral(imported)) { + // recoverable error + this.raiseError( + ErrorMessageMap.babel_error_string_literal_cannot_be_used_as_an_imported_binding, + imported.start, ); } - this.expect(SyntaxKinds.BracesRightPunctuator); + if (isIdentifer(imported)) this.declarateLetSymbol(imported.name, imported.start); + return Factory.createImportSpecifier( + imported, + local as Identifier | null, + isTypeOnly, + cloneSourcePosition(imported.start), + cloneSourcePosition(imported.end), + ); +} + +export function parseTypePrefixOfSpecifier( + this: Parser, + kind: "import" | "export", +): [boolean, StringLiteral | Identifier, Identifier | StringLiteral | null, boolean] { + const maybeType = this.isContextKeyword("type"); + let isTypeOnly = false; + let imported = this.parseModuleExportName(); + let local: Identifier | StringLiteral | null = null; + let shouleParseAs = true; + // https://github.com/microsoft/TypeScript/blob/fc4f9d83d5939047aa6bb2a43965c6e9bbfbc35b/src/compiler/parser.ts#L7411-L7456 + // import { type } from "mod"; - hasTypeSpecifier: false, leftOfAs: type + // import { type as } from "mod"; - hasTypeSpecifier: true, leftOfAs: as + // import { type as as } from "mod"; - hasTypeSpecifier: false, leftOfAs: type, rightOfAs: as + // import { type as as as } from "mod"; - hasTypeSpecifier: true, leftOfAs: as, rightOfAs: as + if (maybeType) { + if (this.isContextKeyword("as")) { + const firstAs = this.parseIdentifierName(); + if (this.isContextKeyword("as")) { + const secondAs = this.parseIdentifierName(); + if (this.match(IdentiferWithKeyworArray)) { + // type as as + shouleParseAs = false; + isTypeOnly = true; + imported = firstAs; + local = kind === "import" ? this.parseIdentifierReference() : this.parseModuleExportName(); + } else { + // type as as + shouleParseAs = false; + local = secondAs; + } + } else if (this.match(IdentiferWithKeyworArray)) { + // type as + local = kind === "import" ? this.parseIdentifierReference() : this.parseModuleExportName(); + shouleParseAs = false; + } else { + // type as + imported = firstAs; + shouleParseAs = false; + isTypeOnly = true; + } + } else if (this.match(IdentiferWithKeyworArray)) { + // type somthing + imported = this.parseIdentifierReference(); + isTypeOnly = true; + } + } + return [shouleParseAs, imported, local, isTypeOnly]; } + export function parseImportAttributesOptional(this: Parser): ImportAttribute[] | undefined { if ( (this.requirePlugin(ParserPlugin.ImportAttribute) && this.match(SyntaxKinds.WithKeyword)) || @@ -455,33 +524,7 @@ export function parseExportNamedDeclaration(this: Parser, start: SourcePosition) if (this.match(Keywords)) { isMatchKeyword = true; } - const exported = this.parseModuleExportName(); - if (!this.isVariableDeclarated(helperGetValueOfExportName(exported))) { - undefExportSymbols.push([helperGetValueOfExportName(exported), exported.start]); - } - if (this.isContextKeyword("as")) { - this.nextToken(); - const local = this.parseModuleExportName(); - this.staticSematicForDuplicateExportName(local); - specifier.push( - Factory.createExportSpecifier( - exported, - local, - cloneSourcePosition(exported.start), - cloneSourcePosition(local.end), - ), - ); - continue; - } - this.staticSematicForDuplicateExportName(exported); - specifier.push( - Factory.createExportSpecifier( - exported, - null, - cloneSourcePosition(exported.start), - cloneSourcePosition(exported.end), - ), - ); + specifier.push(this.parseExportSpecifier(undefExportSymbols)); } const { end: bracesRightPunctuatorEnd } = this.expect(SyntaxKinds.BracesRightPunctuator); let source: StringLiteral | null = null; @@ -507,6 +550,36 @@ export function parseExportNamedDeclaration(this: Parser, start: SourcePosition) : specifier[specifier.length - 1].end; return Factory.createExportNamedDeclaration(specifier, null, source, start, cloneSourcePosition(end)); } +export function parseExportSpecifier( + this: Parser, + undefExportSymbols: Array<[string, SourcePosition]>, +): ExportSpecifier { + // eslint-disable-next-line prefer-const + let [shouleParseAs, exported, local, isTypeOnly] = this.parseTypePrefixOfSpecifier("export"); + if (!this.isVariableDeclarated(helperGetValueOfExportName(exported))) { + undefExportSymbols.push([helperGetValueOfExportName(exported), exported.start]); + } + if (shouleParseAs && this.isContextKeyword("as")) { + this.nextToken(); + local = this.parseModuleExportName(); + this.staticSematicForDuplicateExportName(local); + return Factory.createExportSpecifier( + exported, + local, + isTypeOnly, + cloneSourcePosition(exported.start), + cloneSourcePosition(local.end), + ); + } + this.staticSematicForDuplicateExportName(exported); + return Factory.createExportSpecifier( + exported, + local, + isTypeOnly, + cloneSourcePosition(exported.start), + cloneSourcePosition(exported.end), + ); +} /** * Static Sematic Check based on * - 16.2.3.1 Static Semantics: Early Errors diff --git a/web-infras/parser/tests/fixtures/babel/comments/interpreter-directive/interpreter-directive-import/output.json b/web-infras/parser/tests/fixtures/babel/comments/interpreter-directive/interpreter-directive-import/output.json index 1631f26c..54e0c324 100644 --- a/web-infras/parser/tests/fixtures/babel/comments/interpreter-directive/interpreter-directive-import/output.json +++ b/web-infras/parser/tests/fixtures/babel/comments/interpreter-directive/interpreter-directive-import/output.json @@ -21,6 +21,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 3, "col": 9, diff --git a/web-infras/parser/tests/fixtures/babel/comments/regression/10892/output.json b/web-infras/parser/tests/fixtures/babel/comments/regression/10892/output.json index 4b10f0f5..d8bbceed 100644 --- a/web-infras/parser/tests/fixtures/babel/comments/regression/10892/output.json +++ b/web-infras/parser/tests/fixtures/babel/comments/regression/10892/output.json @@ -21,6 +21,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 10, diff --git a/web-infras/parser/tests/fixtures/babel/core/opts/allowUndeclaredExports/output.json b/web-infras/parser/tests/fixtures/babel/core/opts/allowUndeclaredExports/output.json index e4040f9c..376c55d1 100644 --- a/web-infras/parser/tests/fixtures/babel/core/opts/allowUndeclaredExports/output.json +++ b/web-infras/parser/tests/fixtures/babel/core/opts/allowUndeclaredExports/output.json @@ -20,6 +20,7 @@ "index": 12 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-1/output.json b/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-1/output.json index 0a9f41c8..aa52433e 100644 --- a/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-1/output.json +++ b/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-1/output.json @@ -64,6 +64,7 @@ "index": 27 } }, + "isTypeOnly": false, "local": null, "start": { "row": 3, diff --git a/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-2/output.json b/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-2/output.json index bc3e4ab9..c0e61455 100644 --- a/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-2/output.json +++ b/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-function-loose-mode-2/output.json @@ -20,6 +20,7 @@ "index": 10 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-var/output.json b/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-var/output.json index 813c903e..aac2ab36 100644 --- a/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-var/output.json +++ b/web-infras/parser/tests/fixtures/babel/core/scope/undecl-export-var/output.json @@ -79,6 +79,7 @@ "index": 34 } }, + "isTypeOnly": false, "local": null, "start": { "row": 4, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/modules/duplicate-named-export-builtin/output.json b/web-infras/parser/tests/fixtures/babel/es2015/modules/duplicate-named-export-builtin/output.json index 4dc0da37..5720c4d8 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/modules/duplicate-named-export-builtin/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/modules/duplicate-named-export-builtin/output.json @@ -77,6 +77,7 @@ "index": 38 } }, + "isTypeOnly": false, "local": null, "start": { "row": 3, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/modules/export-declaration-trailing-comma/output.json b/web-infras/parser/tests/fixtures/babel/es2015/modules/export-declaration-trailing-comma/output.json index ec330c8a..ec5eebfd 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/modules/export-declaration-trailing-comma/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/modules/export-declaration-trailing-comma/output.json @@ -20,6 +20,7 @@ "index": 24 } }, + "isTypeOnly": false, "local": null, "start": { "row": 2, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/modules/export-from-valid-reserved-word/output.json b/web-infras/parser/tests/fixtures/babel/es2015/modules/export-from-valid-reserved-word/output.json index 2e8a0b0a..6549552b 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/modules/export-from-valid-reserved-word/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/modules/export-from-valid-reserved-word/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/modules/import-declaration-trailing-comma/output.json b/web-infras/parser/tests/fixtures/babel/es2015/modules/import-declaration-trailing-comma/output.json index f38633c7..0a545a9b 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/modules/import-declaration-trailing-comma/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/modules/import-declaration-trailing-comma/output.json @@ -21,6 +21,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 2, "col": 13, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/86/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/86/output.json index e63075be..d3de79f5 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/86/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/86/output.json @@ -20,6 +20,7 @@ "index": 16 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/87/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/87/output.json index 73a850fb..997e5c4a 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/87/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/87/output.json @@ -107,6 +107,7 @@ "index": 55 } }, + "isTypeOnly": false, "local": null, "start": { "row": 3, @@ -135,6 +136,7 @@ "index": 64 } }, + "isTypeOnly": false, "local": null, "start": { "row": 3, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/88/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/88/output.json index 502322b2..af24a3e4 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/88/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/88/output.json @@ -76,6 +76,7 @@ "index": 40 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "default", diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/89/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/89/output.json index ec430349..695b0b95 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/89/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/89/output.json @@ -107,6 +107,7 @@ "index": 55 } }, + "isTypeOnly": false, "local": null, "start": { "row": 3, @@ -135,6 +136,7 @@ "index": 64 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "dec", diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/90/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/90/output.json index d2ddce05..e6bf38fd 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/90/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/90/output.json @@ -20,6 +20,7 @@ "index": 16 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/93/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/93/output.json index c739f9f1..8f3ed5dd 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/93/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/93/output.json @@ -21,6 +21,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 10, @@ -49,6 +50,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 19, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/94/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/94/output.json index 7f958b2d..0eacd62b 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/94/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/94/output.json @@ -34,6 +34,7 @@ "index": 23 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 10, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/95/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/95/output.json index 3a747194..ab8c00db 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/95/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/95/output.json @@ -48,6 +48,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 18, @@ -89,6 +90,7 @@ "index": 40 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 27, diff --git a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/97/output.json b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/97/output.json index 77da1fbd..6b8e1e10 100644 --- a/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/97/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2015/uncategorised/97/output.json @@ -34,6 +34,7 @@ "index": 20 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 10, diff --git a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/default-import/output.json b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/default-import/output.json index 9310d536..014f9e06 100644 --- a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/default-import/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/default-import/output.json @@ -34,6 +34,7 @@ "index": 30 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 9, diff --git a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/export-from/output.json b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/export-from/output.json index f7fccefc..2c31e083 100644 --- a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/export-from/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/export-from/output.json @@ -20,6 +20,7 @@ "index": 22 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, @@ -48,6 +49,7 @@ "index": 33 } }, + "isTypeOnly": false, "local": { "kind": "StringLiteral", "value": "忠恕。", diff --git a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/mixed/output.json b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/mixed/output.json index d9844988..2c268ece 100644 --- a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/mixed/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/mixed/output.json @@ -34,6 +34,7 @@ "index": 21 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 10, @@ -75,6 +76,7 @@ "index": 39 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 24, @@ -172,6 +174,7 @@ "index": 110 } }, + "isTypeOnly": false, "local": { "kind": "StringLiteral", "value": "quux", diff --git a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-export/output.json b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-export/output.json index 63370d26..2efa9d70 100644 --- a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-export/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-export/output.json @@ -77,6 +77,7 @@ "index": 40 } }, + "isTypeOnly": false, "local": { "kind": "StringLiteral", "value": "學而時習之,不亦說乎?", diff --git a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-import/output.json b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-import/output.json index 32d174b2..72fca35b 100644 --- a/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-import/output.json +++ b/web-infras/parser/tests/fixtures/babel/es2022/module-string-names/named-import/output.json @@ -34,6 +34,7 @@ "index": 34 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 9, diff --git a/web-infras/parser/tests/fixtures/babel/estree/module-string-names/mixed/output.json b/web-infras/parser/tests/fixtures/babel/estree/module-string-names/mixed/output.json index d9844988..2c268ece 100644 --- a/web-infras/parser/tests/fixtures/babel/estree/module-string-names/mixed/output.json +++ b/web-infras/parser/tests/fixtures/babel/estree/module-string-names/mixed/output.json @@ -34,6 +34,7 @@ "index": 21 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 10, @@ -75,6 +76,7 @@ "index": 39 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 24, @@ -172,6 +174,7 @@ "index": 110 } }, + "isTypeOnly": false, "local": { "kind": "StringLiteral", "value": "quux", diff --git a/web-infras/parser/tests/fixtures/babel/estree/module-string-names/shorthand/output.json b/web-infras/parser/tests/fixtures/babel/estree/module-string-names/shorthand/output.json index 5502ccff..86f551a8 100644 --- a/web-infras/parser/tests/fixtures/babel/estree/module-string-names/shorthand/output.json +++ b/web-infras/parser/tests/fixtures/babel/estree/module-string-names/shorthand/output.json @@ -20,6 +20,7 @@ "index": 14 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-default/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-default/output.json index 1a798f9c..38083779 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-default/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-default/output.json @@ -20,6 +20,7 @@ "index": 15 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-default/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-default/output.json index 2b922a30..aa2ed497 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-default/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-default/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "default", diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifier/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifier/output.json index b14adb1a..4f1c4c13 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifier/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifier/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "bar", diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifiers/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifiers/output.json index adfd211c..690e4888 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifiers/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-named-as-specifiers/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "default", @@ -61,6 +62,7 @@ "index": 27 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifier/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifier/output.json index a0b429f8..da4bb37b 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifier/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifier/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifiers/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifiers/output.json index a92e2efb..dd536f70 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifiers/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-from-specifiers/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, @@ -48,6 +49,7 @@ "index": 16 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-default/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-default/output.json index d5e6b1ca..b82e243c 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-default/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-default/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "default", diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifier/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifier/output.json index 56d9e909..6e4c1979 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifier/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifier/output.json @@ -92,6 +92,7 @@ "index": 25 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "bar", diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifiers/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifiers/output.json index d0f42d6e..7799d075 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifiers/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-as-specifiers/output.json @@ -20,6 +20,7 @@ "index": 11 } }, + "isTypeOnly": false, "local": { "kind": "Identifer", "name": "default", @@ -61,6 +62,7 @@ "index": 27 } }, + "isTypeOnly": false, "local": null, "start": { "row": 1, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifier/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifier/output.json index dc9515e2..02750831 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifier/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifier/output.json @@ -64,6 +64,7 @@ "index": 20 } }, + "isTypeOnly": false, "local": null, "start": { "row": 2, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers-comma/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers-comma/output.json index 27ab3967..c34ccea3 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers-comma/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers-comma/output.json @@ -64,6 +64,7 @@ "index": 20 } }, + "isTypeOnly": false, "local": null, "start": { "row": 2, @@ -92,6 +93,7 @@ "index": 25 } }, + "isTypeOnly": false, "local": null, "start": { "row": 2, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers/output.json index 9afdfab5..1432f153 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/export-declaration/export-named-specifiers/output.json @@ -64,6 +64,7 @@ "index": 20 } }, + "isTypeOnly": false, "local": null, "start": { "row": 2, @@ -92,6 +93,7 @@ "index": 25 } }, + "isTypeOnly": false, "local": null, "start": { "row": 2, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-and-named-specifiers/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-and-named-specifiers/output.json index 273d9487..629258a0 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-and-named-specifiers/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-and-named-specifiers/output.json @@ -48,6 +48,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 14, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-as/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-as/output.json index 53512236..77c34f32 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-as/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-default-as/output.json @@ -34,6 +34,7 @@ "index": 22 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 9, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifier/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifier/output.json index b1639f80..4d5117ea 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifier/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifier/output.json @@ -34,6 +34,7 @@ "index": 18 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 9, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifiers/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifiers/output.json index 0912b1f7..3406dfd2 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifiers/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-as-specifiers/output.json @@ -34,6 +34,7 @@ "index": 18 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 9, @@ -62,6 +63,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 21, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifier/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifier/output.json index 6bd5b099..d945c019 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifier/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifier/output.json @@ -21,6 +21,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 9, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers-comma/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers-comma/output.json index a159ea19..b5bacb10 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers-comma/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers-comma/output.json @@ -21,6 +21,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 9, @@ -49,6 +50,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 14, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers/output.json index f0713051..a9f6bd79 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-named-specifiers/output.json @@ -21,6 +21,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 9, @@ -49,6 +50,7 @@ } }, "local": null, + "isTypeOnly": false, "start": { "row": 1, "col": 14, diff --git a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-null-as-nil/output.json b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-null-as-nil/output.json index 693a187e..a65b79ec 100644 --- a/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-null-as-nil/output.json +++ b/web-infras/parser/tests/fixtures/esprima/ES6/import-declaration/import-null-as-nil/output.json @@ -34,6 +34,7 @@ "index": 20 } }, + "isTypeOnly": false, "start": { "row": 1, "col": 10,