diff --git a/packages/babel-parser/src/parser/statement.ts b/packages/babel-parser/src/parser/statement.ts index 4399d933c2de..2d89c5911b31 100644 --- a/packages/babel-parser/src/parser/statement.ts +++ b/packages/babel-parser/src/parser/statement.ts @@ -2712,11 +2712,11 @@ export default abstract class StatementParser extends ExpressionParser { | N.ImportSpecifier | N.ImportDefaultSpecifier | N.ImportNamespaceSpecifier, - >(specifier: Undone, type: T["type"]) { + >(specifier: Undone, type: T["type"], bindingType = BIND_LEXICAL) { this.checkLVal(specifier.local, { // @ts-expect-error refine types in: specifier, - binding: BIND_LEXICAL, + binding: bindingType, }); return this.finishNode(specifier, type); } @@ -2890,6 +2890,7 @@ export default abstract class StatementParser extends ExpressionParser { importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, + undefined, ); node.specifiers.push(importSpecifier); } @@ -2902,6 +2903,7 @@ export default abstract class StatementParser extends ExpressionParser { /* eslint-disable @typescript-eslint/no-unused-vars -- used in TypeScript and Flow parser */ isInTypeOnlyImport: boolean, isMaybeTypeOnly: boolean, + bindingType: BindingTypes | undefined, /* eslint-enable @typescript-eslint/no-unused-vars */ ): N.ImportSpecifier { if (this.eatContextual(tt._as)) { @@ -2924,7 +2926,11 @@ export default abstract class StatementParser extends ExpressionParser { specifier.local = cloneIdentifier(imported); } } - return this.finishImportSpecifier(specifier, "ImportSpecifier"); + return this.finishImportSpecifier( + specifier, + "ImportSpecifier", + bindingType, + ); } // This is used in flow and typescript plugin diff --git a/packages/babel-parser/src/plugins/flow/index.ts b/packages/babel-parser/src/plugins/flow/index.ts index b5cb7d4586c0..ce57987624aa 100644 --- a/packages/babel-parser/src/plugins/flow/index.ts +++ b/packages/babel-parser/src/plugins/flow/index.ts @@ -2785,6 +2785,8 @@ export default (superClass: typeof Parser) => isInTypeOnlyImport: boolean, // eslint-disable-next-line @typescript-eslint/no-unused-vars isMaybeTypeOnly: boolean, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + bindingType: BindingTypes | undefined, ): N.ImportSpecifier { const firstIdent = specifier.imported; diff --git a/packages/babel-parser/src/plugins/typescript/index.ts b/packages/babel-parser/src/plugins/typescript/index.ts index 9d97c3f0d570..369116204f8f 100644 --- a/packages/babel-parser/src/plugins/typescript/index.ts +++ b/packages/babel-parser/src/plugins/typescript/index.ts @@ -27,9 +27,11 @@ import { BIND_TS_INTERFACE, BIND_TS_AMBIENT, BIND_TS_NAMESPACE, + BIND_TS_TYPE_IMPORT, BIND_CLASS, BIND_LEXICAL, BIND_NONE, + BIND_FLAGS_TS_IMPORT, } from "../../util/scopeflags"; import TypeScriptScopeHandler from "./scope"; import * as charCodes from "charcodes"; @@ -3922,7 +3924,7 @@ export default (superClass: ClassWithMixin) => } parseExportSpecifier( - node: any, + node: Undone, isString: boolean, isInTypeExport: boolean, isMaybeTypeOnly: boolean, @@ -3945,10 +3947,12 @@ export default (superClass: ClassWithMixin) => } parseImportSpecifier( - specifier: any, + specifier: Undone, importedIsString: boolean, isInTypeOnlyImport: boolean, isMaybeTypeOnly: boolean, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + bindingType: BindingTypes | undefined, ): N.ImportSpecifier { if (!importedIsString && isMaybeTypeOnly) { this.parseTypeOnlyImportExportSpecifier( @@ -3964,6 +3968,7 @@ export default (superClass: ClassWithMixin) => importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, + isInTypeOnlyImport ? BIND_TS_TYPE_IMPORT : BIND_FLAGS_TS_IMPORT, ); } @@ -4059,7 +4064,10 @@ export default (superClass: ClassWithMixin) => node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]); } if (isImport) { - this.checkIdentifier(node[rightOfAsKey], BIND_LEXICAL); + this.checkIdentifier( + node[rightOfAsKey], + hasTypeSpecifier ? BIND_TS_TYPE_IMPORT : BIND_FLAGS_TS_IMPORT, + ); } } }; diff --git a/packages/babel-parser/src/plugins/typescript/scope.ts b/packages/babel-parser/src/plugins/typescript/scope.ts index fa390603c38c..ad0be49bb9ed 100644 --- a/packages/babel-parser/src/plugins/typescript/scope.ts +++ b/packages/babel-parser/src/plugins/typescript/scope.ts @@ -9,8 +9,11 @@ import { BIND_FLAGS_CLASS, type ScopeFlags, type BindingTypes, + BIND_FLAGS_TS_IMPORT, + SCOPE_TS_MODULE, } from "../../util/scopeflags"; import type * as N from "../../types"; +import { Errors } from "../../parse-error"; class TypeScriptScope extends Scope { types: Set = new Set(); @@ -35,11 +38,57 @@ class TypeScriptScope extends Scope { // explanation of how typescript handles scope. export default class TypeScriptScopeHandler extends ScopeHandler { + importsStack: Set[] = []; + createScope(flags: ScopeFlags): TypeScriptScope { + this.importsStack.push(new Set()); // Always keep the top-level scope for export checks. + return new TypeScriptScope(flags); } + enter(flags: number): void { + if (flags == SCOPE_TS_MODULE) { + this.importsStack.push(new Set()); + } + + super.enter(flags); + } + + exit() { + const flags = super.exit(); + + if (flags == SCOPE_TS_MODULE) { + this.importsStack.pop(); + } + + return flags; + } + + hasImport(name: string, allowShadow?: boolean) { + const len = this.importsStack.length; + if (this.importsStack[len - 1].has(name)) { + return true; + } + if (!allowShadow && len > 1) { + for (let i = 0; i < len - 1; i++) { + if (this.importsStack[i].has(name)) return true; + } + } + return false; + } + declareName(name: string, bindingType: BindingTypes, loc: Position) { + if (bindingType & BIND_FLAGS_TS_IMPORT) { + if (this.hasImport(name, true)) { + this.parser.raise(Errors.VarRedeclaration, { + at: loc, + identifierName: name, + }); + } + this.importsStack[this.importsStack.length - 1].add(name); + return; + } + const scope = this.currentScope(); if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) { this.maybeExportDefined(scope, name); @@ -98,7 +147,8 @@ export default class TypeScriptScopeHandler extends ScopeHandler { this.scopeStack.push(this.createScope(flags)); } - exit() { - this.scopeStack.pop(); + exit(): ScopeFlags { + const scope = this.scopeStack.pop(); + return scope.flags; } // The spec says: diff --git a/packages/babel-parser/src/util/scopeflags.ts b/packages/babel-parser/src/util/scopeflags.ts index ade2bb881fae..e62ac9d7e825 100644 --- a/packages/babel-parser/src/util/scopeflags.ts +++ b/packages/babel-parser/src/util/scopeflags.ts @@ -35,12 +35,13 @@ export const BIND_KIND_VALUE = 0b000000_0000_01, BIND_SCOPE_OUTSIDE = 0b000000_1000_00, // Special case for function names as // bound inside the function // Misc flags - BIND_FLAGS_NONE = 0b000001_0000_00, - BIND_FLAGS_CLASS = 0b000010_0000_00, - BIND_FLAGS_TS_ENUM = 0b000100_0000_00, - BIND_FLAGS_TS_CONST_ENUM = 0b001000_0000_00, - BIND_FLAGS_TS_EXPORT_ONLY = 0b010000_0000_00, - BIND_FLAGS_FLOW_DECLARE_FN = 0b100000_0000_00; + BIND_FLAGS_NONE = 0b0000001_0000_00, + BIND_FLAGS_CLASS = 0b0000010_0000_00, + BIND_FLAGS_TS_ENUM = 0b0000100_0000_00, + BIND_FLAGS_TS_CONST_ENUM = 0b0001000_0000_00, + BIND_FLAGS_TS_EXPORT_ONLY = 0b0010000_0000_00, + BIND_FLAGS_FLOW_DECLARE_FN = 0b0100000_0000_00, + BIND_FLAGS_TS_IMPORT = 0b1000000_0000_00; // These flags are meant to be _only_ used by Scope consumers // prettier-ignore @@ -58,8 +59,9 @@ export const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_ BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE , BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE , - BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM, - BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY, + BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM , + BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY, + BIND_TS_TYPE_IMPORT= 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_TS_IMPORT, BIND_FLOW_DECLARE_FN = BIND_FLAGS_FLOW_DECLARE_FN; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-let/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-let/input.ts new file mode 100644 index 000000000000..e1265e0e4100 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-let/input.ts @@ -0,0 +1,7 @@ +import React, { Context } from 'react'; +import { a } from 'react'; +import { a as b } from 'react'; + +let Context: Context<{}> = React.createContext({}); +let a: a = 1; +let b: b = 1; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-let/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-let/output.json new file mode 100644 index 000000000000..21a0c7a0cec4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-let/output.json @@ -0,0 +1,257 @@ +{ + "type": "File", + "start":0,"end":179,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":179}}, + "program": { + "type": "Program", + "start":0,"end":179,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":179}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "local": { + "type": "Identifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12},"identifierName":"React"}, + "name": "React" + } + }, + { + "type": "ImportSpecifier", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":23,"index":23}}, + "imported": { + "type": "Identifier", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":23,"index":23},"identifierName":"Context"}, + "name": "Context" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":23,"index":23},"identifierName":"Context"}, + "name": "Context" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":38,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":38,"index":38}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":40,"end":66,"loc":{"start":{"line":2,"column":0,"index":40},"end":{"line":2,"column":26,"index":66}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":49,"end":50,"loc":{"start":{"line":2,"column":9,"index":49},"end":{"line":2,"column":10,"index":50}}, + "imported": { + "type": "Identifier", + "start":49,"end":50,"loc":{"start":{"line":2,"column":9,"index":49},"end":{"line":2,"column":10,"index":50},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":49,"end":50,"loc":{"start":{"line":2,"column":9,"index":49},"end":{"line":2,"column":10,"index":50},"identifierName":"a"}, + "name": "a" + } + } + ], + "source": { + "type": "StringLiteral", + "start":58,"end":65,"loc":{"start":{"line":2,"column":18,"index":58},"end":{"line":2,"column":25,"index":65}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":67,"end":98,"loc":{"start":{"line":3,"column":0,"index":67},"end":{"line":3,"column":31,"index":98}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":76,"end":82,"loc":{"start":{"line":3,"column":9,"index":76},"end":{"line":3,"column":15,"index":82}}, + "imported": { + "type": "Identifier", + "start":76,"end":77,"loc":{"start":{"line":3,"column":9,"index":76},"end":{"line":3,"column":10,"index":77},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":81,"end":82,"loc":{"start":{"line":3,"column":14,"index":81},"end":{"line":3,"column":15,"index":82},"identifierName":"b"}, + "name": "b" + } + } + ], + "source": { + "type": "StringLiteral", + "start":90,"end":97,"loc":{"start":{"line":3,"column":23,"index":90},"end":{"line":3,"column":30,"index":97}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "VariableDeclaration", + "start":100,"end":151,"loc":{"start":{"line":5,"column":0,"index":100},"end":{"line":5,"column":51,"index":151}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":104,"end":150,"loc":{"start":{"line":5,"column":4,"index":104},"end":{"line":5,"column":50,"index":150}}, + "id": { + "type": "Identifier", + "start":104,"end":124,"loc":{"start":{"line":5,"column":4,"index":104},"end":{"line":5,"column":24,"index":124},"identifierName":"Context"}, + "name": "Context", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":111,"end":124,"loc":{"start":{"line":5,"column":11,"index":111},"end":{"line":5,"column":24,"index":124}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":113,"end":124,"loc":{"start":{"line":5,"column":13,"index":113},"end":{"line":5,"column":24,"index":124}}, + "typeName": { + "type": "Identifier", + "start":113,"end":120,"loc":{"start":{"line":5,"column":13,"index":113},"end":{"line":5,"column":20,"index":120},"identifierName":"Context"}, + "name": "Context" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":120,"end":124,"loc":{"start":{"line":5,"column":20,"index":120},"end":{"line":5,"column":24,"index":124}}, + "params": [ + { + "type": "TSTypeLiteral", + "start":121,"end":123,"loc":{"start":{"line":5,"column":21,"index":121},"end":{"line":5,"column":23,"index":123}}, + "members": [] + } + ] + } + } + } + }, + "init": { + "type": "CallExpression", + "start":127,"end":150,"loc":{"start":{"line":5,"column":27,"index":127},"end":{"line":5,"column":50,"index":150}}, + "callee": { + "type": "MemberExpression", + "start":127,"end":146,"loc":{"start":{"line":5,"column":27,"index":127},"end":{"line":5,"column":46,"index":146}}, + "object": { + "type": "Identifier", + "start":127,"end":132,"loc":{"start":{"line":5,"column":27,"index":127},"end":{"line":5,"column":32,"index":132},"identifierName":"React"}, + "name": "React" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":133,"end":146,"loc":{"start":{"line":5,"column":33,"index":133},"end":{"line":5,"column":46,"index":146},"identifierName":"createContext"}, + "name": "createContext" + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "start":147,"end":149,"loc":{"start":{"line":5,"column":47,"index":147},"end":{"line":5,"column":49,"index":149}}, + "properties": [] + } + ] + } + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start":152,"end":165,"loc":{"start":{"line":6,"column":0,"index":152},"end":{"line":6,"column":13,"index":165}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":156,"end":164,"loc":{"start":{"line":6,"column":4,"index":156},"end":{"line":6,"column":12,"index":164}}, + "id": { + "type": "Identifier", + "start":156,"end":160,"loc":{"start":{"line":6,"column":4,"index":156},"end":{"line":6,"column":8,"index":160},"identifierName":"a"}, + "name": "a", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":157,"end":160,"loc":{"start":{"line":6,"column":5,"index":157},"end":{"line":6,"column":8,"index":160}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":159,"end":160,"loc":{"start":{"line":6,"column":7,"index":159},"end":{"line":6,"column":8,"index":160}}, + "typeName": { + "type": "Identifier", + "start":159,"end":160,"loc":{"start":{"line":6,"column":7,"index":159},"end":{"line":6,"column":8,"index":160},"identifierName":"a"}, + "name": "a" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":163,"end":164,"loc":{"start":{"line":6,"column":11,"index":163},"end":{"line":6,"column":12,"index":164}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start":166,"end":179,"loc":{"start":{"line":7,"column":0,"index":166},"end":{"line":7,"column":13,"index":179}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":170,"end":178,"loc":{"start":{"line":7,"column":4,"index":170},"end":{"line":7,"column":12,"index":178}}, + "id": { + "type": "Identifier", + "start":170,"end":174,"loc":{"start":{"line":7,"column":4,"index":170},"end":{"line":7,"column":8,"index":174},"identifierName":"b"}, + "name": "b", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":171,"end":174,"loc":{"start":{"line":7,"column":5,"index":171},"end":{"line":7,"column":8,"index":174}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":173,"end":174,"loc":{"start":{"line":7,"column":7,"index":173},"end":{"line":7,"column":8,"index":174}}, + "typeName": { + "type": "Identifier", + "start":173,"end":174,"loc":{"start":{"line":7,"column":7,"index":173},"end":{"line":7,"column":8,"index":174},"identifierName":"b"}, + "name": "b" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":177,"end":178,"loc":{"start":{"line":7,"column":11,"index":177},"end":{"line":7,"column":12,"index":178}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-import/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-import/input.ts new file mode 100644 index 000000000000..578c09945a99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-import/input.ts @@ -0,0 +1,2 @@ +import type { Context } from 'react'; +import { Context } from 'react'; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-import/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-import/output.json new file mode 100644 index 000000000000..055436438db1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-import/output.json @@ -0,0 +1,78 @@ +{ + "type": "File", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":32,"index":70}}, + "errors": [ + "SyntaxError: Identifier 'Context' has already been declared. (2:9)" + ], + "program": { + "type": "Program", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":32,"index":70}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":14,"end":21,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":21,"index":21}}, + "imported": { + "type": "Identifier", + "start":14,"end":21,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":21,"index":21},"identifierName":"Context"}, + "name": "Context" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":14,"end":21,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":21,"index":21},"identifierName":"Context"}, + "name": "Context" + } + } + ], + "source": { + "type": "StringLiteral", + "start":29,"end":36,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":36,"index":36}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":38,"end":70,"loc":{"start":{"line":2,"column":0,"index":38},"end":{"line":2,"column":32,"index":70}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":47,"end":54,"loc":{"start":{"line":2,"column":9,"index":47},"end":{"line":2,"column":16,"index":54}}, + "imported": { + "type": "Identifier", + "start":47,"end":54,"loc":{"start":{"line":2,"column":9,"index":47},"end":{"line":2,"column":16,"index":54},"identifierName":"Context"}, + "name": "Context" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":47,"end":54,"loc":{"start":{"line":2,"column":9,"index":47},"end":{"line":2,"column":16,"index":54},"identifierName":"Context"}, + "name": "Context" + } + } + ], + "source": { + "type": "StringLiteral", + "start":62,"end":69,"loc":{"start":{"line":2,"column":24,"index":62},"end":{"line":2,"column":31,"index":69}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-let/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-let/input.ts new file mode 100644 index 000000000000..c049d94e8154 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-let/input.ts @@ -0,0 +1,7 @@ +import React, { type Context } from 'react'; +import type { a } from 'react'; +import type { a as b } from 'react'; + +let Context: Context<{}> = React.createContext({}); +let a: a = 1; +let b: b = 1; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-let/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-let/output.json new file mode 100644 index 000000000000..599a584e15ed --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-let/output.json @@ -0,0 +1,257 @@ +{ + "type": "File", + "start":0,"end":194,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":194}}, + "program": { + "type": "Program", + "start":0,"end":194,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":194}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":44,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":44,"index":44}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "local": { + "type": "Identifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12},"identifierName":"React"}, + "name": "React" + } + }, + { + "type": "ImportSpecifier", + "start":16,"end":28,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":28,"index":28}}, + "imported": { + "type": "Identifier", + "start":21,"end":28,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":28,"index":28},"identifierName":"Context"}, + "name": "Context" + }, + "local": { + "type": "Identifier", + "start":21,"end":28,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":28,"index":28},"identifierName":"Context"}, + "name": "Context" + }, + "importKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":36,"end":43,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":45,"end":76,"loc":{"start":{"line":2,"column":0,"index":45},"end":{"line":2,"column":31,"index":76}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":59,"end":60,"loc":{"start":{"line":2,"column":14,"index":59},"end":{"line":2,"column":15,"index":60}}, + "imported": { + "type": "Identifier", + "start":59,"end":60,"loc":{"start":{"line":2,"column":14,"index":59},"end":{"line":2,"column":15,"index":60},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":59,"end":60,"loc":{"start":{"line":2,"column":14,"index":59},"end":{"line":2,"column":15,"index":60},"identifierName":"a"}, + "name": "a" + } + } + ], + "source": { + "type": "StringLiteral", + "start":68,"end":75,"loc":{"start":{"line":2,"column":23,"index":68},"end":{"line":2,"column":30,"index":75}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":77,"end":113,"loc":{"start":{"line":3,"column":0,"index":77},"end":{"line":3,"column":36,"index":113}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":91,"end":97,"loc":{"start":{"line":3,"column":14,"index":91},"end":{"line":3,"column":20,"index":97}}, + "imported": { + "type": "Identifier", + "start":91,"end":92,"loc":{"start":{"line":3,"column":14,"index":91},"end":{"line":3,"column":15,"index":92},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":96,"end":97,"loc":{"start":{"line":3,"column":19,"index":96},"end":{"line":3,"column":20,"index":97},"identifierName":"b"}, + "name": "b" + } + } + ], + "source": { + "type": "StringLiteral", + "start":105,"end":112,"loc":{"start":{"line":3,"column":28,"index":105},"end":{"line":3,"column":35,"index":112}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "VariableDeclaration", + "start":115,"end":166,"loc":{"start":{"line":5,"column":0,"index":115},"end":{"line":5,"column":51,"index":166}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":119,"end":165,"loc":{"start":{"line":5,"column":4,"index":119},"end":{"line":5,"column":50,"index":165}}, + "id": { + "type": "Identifier", + "start":119,"end":139,"loc":{"start":{"line":5,"column":4,"index":119},"end":{"line":5,"column":24,"index":139},"identifierName":"Context"}, + "name": "Context", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":126,"end":139,"loc":{"start":{"line":5,"column":11,"index":126},"end":{"line":5,"column":24,"index":139}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":128,"end":139,"loc":{"start":{"line":5,"column":13,"index":128},"end":{"line":5,"column":24,"index":139}}, + "typeName": { + "type": "Identifier", + "start":128,"end":135,"loc":{"start":{"line":5,"column":13,"index":128},"end":{"line":5,"column":20,"index":135},"identifierName":"Context"}, + "name": "Context" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":135,"end":139,"loc":{"start":{"line":5,"column":20,"index":135},"end":{"line":5,"column":24,"index":139}}, + "params": [ + { + "type": "TSTypeLiteral", + "start":136,"end":138,"loc":{"start":{"line":5,"column":21,"index":136},"end":{"line":5,"column":23,"index":138}}, + "members": [] + } + ] + } + } + } + }, + "init": { + "type": "CallExpression", + "start":142,"end":165,"loc":{"start":{"line":5,"column":27,"index":142},"end":{"line":5,"column":50,"index":165}}, + "callee": { + "type": "MemberExpression", + "start":142,"end":161,"loc":{"start":{"line":5,"column":27,"index":142},"end":{"line":5,"column":46,"index":161}}, + "object": { + "type": "Identifier", + "start":142,"end":147,"loc":{"start":{"line":5,"column":27,"index":142},"end":{"line":5,"column":32,"index":147},"identifierName":"React"}, + "name": "React" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":148,"end":161,"loc":{"start":{"line":5,"column":33,"index":148},"end":{"line":5,"column":46,"index":161},"identifierName":"createContext"}, + "name": "createContext" + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "start":162,"end":164,"loc":{"start":{"line":5,"column":47,"index":162},"end":{"line":5,"column":49,"index":164}}, + "properties": [] + } + ] + } + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start":167,"end":180,"loc":{"start":{"line":6,"column":0,"index":167},"end":{"line":6,"column":13,"index":180}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":171,"end":179,"loc":{"start":{"line":6,"column":4,"index":171},"end":{"line":6,"column":12,"index":179}}, + "id": { + "type": "Identifier", + "start":171,"end":175,"loc":{"start":{"line":6,"column":4,"index":171},"end":{"line":6,"column":8,"index":175},"identifierName":"a"}, + "name": "a", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":172,"end":175,"loc":{"start":{"line":6,"column":5,"index":172},"end":{"line":6,"column":8,"index":175}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":174,"end":175,"loc":{"start":{"line":6,"column":7,"index":174},"end":{"line":6,"column":8,"index":175}}, + "typeName": { + "type": "Identifier", + "start":174,"end":175,"loc":{"start":{"line":6,"column":7,"index":174},"end":{"line":6,"column":8,"index":175},"identifierName":"a"}, + "name": "a" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":178,"end":179,"loc":{"start":{"line":6,"column":11,"index":178},"end":{"line":6,"column":12,"index":179}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start":181,"end":194,"loc":{"start":{"line":7,"column":0,"index":181},"end":{"line":7,"column":13,"index":194}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":185,"end":193,"loc":{"start":{"line":7,"column":4,"index":185},"end":{"line":7,"column":12,"index":193}}, + "id": { + "type": "Identifier", + "start":185,"end":189,"loc":{"start":{"line":7,"column":4,"index":185},"end":{"line":7,"column":8,"index":189},"identifierName":"b"}, + "name": "b", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":186,"end":189,"loc":{"start":{"line":7,"column":5,"index":186},"end":{"line":7,"column":8,"index":189}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":188,"end":189,"loc":{"start":{"line":7,"column":7,"index":188},"end":{"line":7,"column":8,"index":189}}, + "typeName": { + "type": "Identifier", + "start":188,"end":189,"loc":{"start":{"line":7,"column":7,"index":188},"end":{"line":7,"column":8,"index":189},"identifierName":"b"}, + "name": "b" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":192,"end":193,"loc":{"start":{"line":7,"column":11,"index":192},"end":{"line":7,"column":12,"index":193}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-type/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-type/input.ts new file mode 100644 index 000000000000..4518df85466a --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-type/input.ts @@ -0,0 +1,5 @@ +import type {Global} from '@jest/types'; + +type Global = Global.Global; + +var a: Global; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-type/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-type/output.json new file mode 100644 index 000000000000..961b1c064eec --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-type/output.json @@ -0,0 +1,101 @@ +{ + "type": "File", + "start":0,"end":86,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":5,"column":14,"index":86}}, + "program": { + "type": "Program", + "start":0,"end":86,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":5,"column":14,"index":86}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":40,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":40,"index":40}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":13,"end":19,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":19,"index":19}}, + "imported": { + "type": "Identifier", + "start":13,"end":19,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":19,"index":19},"identifierName":"Global"}, + "name": "Global" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":13,"end":19,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":19,"index":19},"identifierName":"Global"}, + "name": "Global" + } + } + ], + "source": { + "type": "StringLiteral", + "start":26,"end":39,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":39,"index":39}}, + "extra": { + "rawValue": "@jest/types", + "raw": "'@jest/types'" + }, + "value": "@jest/types" + } + }, + { + "type": "TSTypeAliasDeclaration", + "start":42,"end":70,"loc":{"start":{"line":3,"column":0,"index":42},"end":{"line":3,"column":28,"index":70}}, + "id": { + "type": "Identifier", + "start":47,"end":53,"loc":{"start":{"line":3,"column":5,"index":47},"end":{"line":3,"column":11,"index":53},"identifierName":"Global"}, + "name": "Global" + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start":56,"end":69,"loc":{"start":{"line":3,"column":14,"index":56},"end":{"line":3,"column":27,"index":69}}, + "typeName": { + "type": "TSQualifiedName", + "start":56,"end":69,"loc":{"start":{"line":3,"column":14,"index":56},"end":{"line":3,"column":27,"index":69}}, + "left": { + "type": "Identifier", + "start":56,"end":62,"loc":{"start":{"line":3,"column":14,"index":56},"end":{"line":3,"column":20,"index":62},"identifierName":"Global"}, + "name": "Global" + }, + "right": { + "type": "Identifier", + "start":63,"end":69,"loc":{"start":{"line":3,"column":21,"index":63},"end":{"line":3,"column":27,"index":69},"identifierName":"Global"}, + "name": "Global" + } + } + } + }, + { + "type": "VariableDeclaration", + "start":72,"end":86,"loc":{"start":{"line":5,"column":0,"index":72},"end":{"line":5,"column":14,"index":86}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":76,"end":85,"loc":{"start":{"line":5,"column":4,"index":76},"end":{"line":5,"column":13,"index":85}}, + "id": { + "type": "Identifier", + "start":76,"end":85,"loc":{"start":{"line":5,"column":4,"index":76},"end":{"line":5,"column":13,"index":85},"identifierName":"a"}, + "name": "a", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":77,"end":85,"loc":{"start":{"line":5,"column":5,"index":77},"end":{"line":5,"column":13,"index":85}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":79,"end":85,"loc":{"start":{"line":5,"column":7,"index":79},"end":{"line":5,"column":13,"index":85}}, + "typeName": { + "type": "Identifier", + "start":79,"end":85,"loc":{"start":{"line":5,"column":7,"index":79},"end":{"line":5,"column":13,"index":85},"identifierName":"Global"}, + "name": "Global" + } + } + } + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-var/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-var/input.ts new file mode 100644 index 000000000000..18630011767e --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-var/input.ts @@ -0,0 +1,7 @@ +import React, { type Context } from 'react'; +import type { a } from 'react'; +import type { a as b } from 'react'; + +var Context: Context<{}> = React.createContext({}); +var a: a = 1; +var b: b = 1; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-var/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-var/output.json new file mode 100644 index 000000000000..1018e2130d74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-type-var/output.json @@ -0,0 +1,257 @@ +{ + "type": "File", + "start":0,"end":194,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":194}}, + "program": { + "type": "Program", + "start":0,"end":194,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":194}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":44,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":44,"index":44}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "local": { + "type": "Identifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12},"identifierName":"React"}, + "name": "React" + } + }, + { + "type": "ImportSpecifier", + "start":16,"end":28,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":28,"index":28}}, + "imported": { + "type": "Identifier", + "start":21,"end":28,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":28,"index":28},"identifierName":"Context"}, + "name": "Context" + }, + "local": { + "type": "Identifier", + "start":21,"end":28,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":28,"index":28},"identifierName":"Context"}, + "name": "Context" + }, + "importKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":36,"end":43,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":45,"end":76,"loc":{"start":{"line":2,"column":0,"index":45},"end":{"line":2,"column":31,"index":76}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":59,"end":60,"loc":{"start":{"line":2,"column":14,"index":59},"end":{"line":2,"column":15,"index":60}}, + "imported": { + "type": "Identifier", + "start":59,"end":60,"loc":{"start":{"line":2,"column":14,"index":59},"end":{"line":2,"column":15,"index":60},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":59,"end":60,"loc":{"start":{"line":2,"column":14,"index":59},"end":{"line":2,"column":15,"index":60},"identifierName":"a"}, + "name": "a" + } + } + ], + "source": { + "type": "StringLiteral", + "start":68,"end":75,"loc":{"start":{"line":2,"column":23,"index":68},"end":{"line":2,"column":30,"index":75}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":77,"end":113,"loc":{"start":{"line":3,"column":0,"index":77},"end":{"line":3,"column":36,"index":113}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":91,"end":97,"loc":{"start":{"line":3,"column":14,"index":91},"end":{"line":3,"column":20,"index":97}}, + "imported": { + "type": "Identifier", + "start":91,"end":92,"loc":{"start":{"line":3,"column":14,"index":91},"end":{"line":3,"column":15,"index":92},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":96,"end":97,"loc":{"start":{"line":3,"column":19,"index":96},"end":{"line":3,"column":20,"index":97},"identifierName":"b"}, + "name": "b" + } + } + ], + "source": { + "type": "StringLiteral", + "start":105,"end":112,"loc":{"start":{"line":3,"column":28,"index":105},"end":{"line":3,"column":35,"index":112}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "VariableDeclaration", + "start":115,"end":166,"loc":{"start":{"line":5,"column":0,"index":115},"end":{"line":5,"column":51,"index":166}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":119,"end":165,"loc":{"start":{"line":5,"column":4,"index":119},"end":{"line":5,"column":50,"index":165}}, + "id": { + "type": "Identifier", + "start":119,"end":139,"loc":{"start":{"line":5,"column":4,"index":119},"end":{"line":5,"column":24,"index":139},"identifierName":"Context"}, + "name": "Context", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":126,"end":139,"loc":{"start":{"line":5,"column":11,"index":126},"end":{"line":5,"column":24,"index":139}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":128,"end":139,"loc":{"start":{"line":5,"column":13,"index":128},"end":{"line":5,"column":24,"index":139}}, + "typeName": { + "type": "Identifier", + "start":128,"end":135,"loc":{"start":{"line":5,"column":13,"index":128},"end":{"line":5,"column":20,"index":135},"identifierName":"Context"}, + "name": "Context" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":135,"end":139,"loc":{"start":{"line":5,"column":20,"index":135},"end":{"line":5,"column":24,"index":139}}, + "params": [ + { + "type": "TSTypeLiteral", + "start":136,"end":138,"loc":{"start":{"line":5,"column":21,"index":136},"end":{"line":5,"column":23,"index":138}}, + "members": [] + } + ] + } + } + } + }, + "init": { + "type": "CallExpression", + "start":142,"end":165,"loc":{"start":{"line":5,"column":27,"index":142},"end":{"line":5,"column":50,"index":165}}, + "callee": { + "type": "MemberExpression", + "start":142,"end":161,"loc":{"start":{"line":5,"column":27,"index":142},"end":{"line":5,"column":46,"index":161}}, + "object": { + "type": "Identifier", + "start":142,"end":147,"loc":{"start":{"line":5,"column":27,"index":142},"end":{"line":5,"column":32,"index":147},"identifierName":"React"}, + "name": "React" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":148,"end":161,"loc":{"start":{"line":5,"column":33,"index":148},"end":{"line":5,"column":46,"index":161},"identifierName":"createContext"}, + "name": "createContext" + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "start":162,"end":164,"loc":{"start":{"line":5,"column":47,"index":162},"end":{"line":5,"column":49,"index":164}}, + "properties": [] + } + ] + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start":167,"end":180,"loc":{"start":{"line":6,"column":0,"index":167},"end":{"line":6,"column":13,"index":180}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":171,"end":179,"loc":{"start":{"line":6,"column":4,"index":171},"end":{"line":6,"column":12,"index":179}}, + "id": { + "type": "Identifier", + "start":171,"end":175,"loc":{"start":{"line":6,"column":4,"index":171},"end":{"line":6,"column":8,"index":175},"identifierName":"a"}, + "name": "a", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":172,"end":175,"loc":{"start":{"line":6,"column":5,"index":172},"end":{"line":6,"column":8,"index":175}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":174,"end":175,"loc":{"start":{"line":6,"column":7,"index":174},"end":{"line":6,"column":8,"index":175}}, + "typeName": { + "type": "Identifier", + "start":174,"end":175,"loc":{"start":{"line":6,"column":7,"index":174},"end":{"line":6,"column":8,"index":175},"identifierName":"a"}, + "name": "a" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":178,"end":179,"loc":{"start":{"line":6,"column":11,"index":178},"end":{"line":6,"column":12,"index":179}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start":181,"end":194,"loc":{"start":{"line":7,"column":0,"index":181},"end":{"line":7,"column":13,"index":194}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":185,"end":193,"loc":{"start":{"line":7,"column":4,"index":185},"end":{"line":7,"column":12,"index":193}}, + "id": { + "type": "Identifier", + "start":185,"end":189,"loc":{"start":{"line":7,"column":4,"index":185},"end":{"line":7,"column":8,"index":189},"identifierName":"b"}, + "name": "b", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":186,"end":189,"loc":{"start":{"line":7,"column":5,"index":186},"end":{"line":7,"column":8,"index":189}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":188,"end":189,"loc":{"start":{"line":7,"column":7,"index":188},"end":{"line":7,"column":8,"index":189}}, + "typeName": { + "type": "Identifier", + "start":188,"end":189,"loc":{"start":{"line":7,"column":7,"index":188},"end":{"line":7,"column":8,"index":189},"identifierName":"b"}, + "name": "b" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":192,"end":193,"loc":{"start":{"line":7,"column":11,"index":192},"end":{"line":7,"column":12,"index":193}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-var/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-var/input.ts new file mode 100644 index 000000000000..6871be72092b --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-var/input.ts @@ -0,0 +1,7 @@ +import React, { Context } from 'react'; +import { a } from 'react'; +import { a as b } from 'react'; + +var Context: Context<{}> = React.createContext({}); +var a: a = 1; +var b: b = 1; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-var/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-var/output.json new file mode 100644 index 000000000000..6aaf30600487 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-import-var/output.json @@ -0,0 +1,257 @@ +{ + "type": "File", + "start":0,"end":179,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":179}}, + "program": { + "type": "Program", + "start":0,"end":179,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":7,"column":13,"index":179}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "local": { + "type": "Identifier", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12},"identifierName":"React"}, + "name": "React" + } + }, + { + "type": "ImportSpecifier", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":23,"index":23}}, + "imported": { + "type": "Identifier", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":23,"index":23},"identifierName":"Context"}, + "name": "Context" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":23,"index":23},"identifierName":"Context"}, + "name": "Context" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":38,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":38,"index":38}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":40,"end":66,"loc":{"start":{"line":2,"column":0,"index":40},"end":{"line":2,"column":26,"index":66}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":49,"end":50,"loc":{"start":{"line":2,"column":9,"index":49},"end":{"line":2,"column":10,"index":50}}, + "imported": { + "type": "Identifier", + "start":49,"end":50,"loc":{"start":{"line":2,"column":9,"index":49},"end":{"line":2,"column":10,"index":50},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":49,"end":50,"loc":{"start":{"line":2,"column":9,"index":49},"end":{"line":2,"column":10,"index":50},"identifierName":"a"}, + "name": "a" + } + } + ], + "source": { + "type": "StringLiteral", + "start":58,"end":65,"loc":{"start":{"line":2,"column":18,"index":58},"end":{"line":2,"column":25,"index":65}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "ImportDeclaration", + "start":67,"end":98,"loc":{"start":{"line":3,"column":0,"index":67},"end":{"line":3,"column":31,"index":98}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":76,"end":82,"loc":{"start":{"line":3,"column":9,"index":76},"end":{"line":3,"column":15,"index":82}}, + "imported": { + "type": "Identifier", + "start":76,"end":77,"loc":{"start":{"line":3,"column":9,"index":76},"end":{"line":3,"column":10,"index":77},"identifierName":"a"}, + "name": "a" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":81,"end":82,"loc":{"start":{"line":3,"column":14,"index":81},"end":{"line":3,"column":15,"index":82},"identifierName":"b"}, + "name": "b" + } + } + ], + "source": { + "type": "StringLiteral", + "start":90,"end":97,"loc":{"start":{"line":3,"column":23,"index":90},"end":{"line":3,"column":30,"index":97}}, + "extra": { + "rawValue": "react", + "raw": "'react'" + }, + "value": "react" + } + }, + { + "type": "VariableDeclaration", + "start":100,"end":151,"loc":{"start":{"line":5,"column":0,"index":100},"end":{"line":5,"column":51,"index":151}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":104,"end":150,"loc":{"start":{"line":5,"column":4,"index":104},"end":{"line":5,"column":50,"index":150}}, + "id": { + "type": "Identifier", + "start":104,"end":124,"loc":{"start":{"line":5,"column":4,"index":104},"end":{"line":5,"column":24,"index":124},"identifierName":"Context"}, + "name": "Context", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":111,"end":124,"loc":{"start":{"line":5,"column":11,"index":111},"end":{"line":5,"column":24,"index":124}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":113,"end":124,"loc":{"start":{"line":5,"column":13,"index":113},"end":{"line":5,"column":24,"index":124}}, + "typeName": { + "type": "Identifier", + "start":113,"end":120,"loc":{"start":{"line":5,"column":13,"index":113},"end":{"line":5,"column":20,"index":120},"identifierName":"Context"}, + "name": "Context" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start":120,"end":124,"loc":{"start":{"line":5,"column":20,"index":120},"end":{"line":5,"column":24,"index":124}}, + "params": [ + { + "type": "TSTypeLiteral", + "start":121,"end":123,"loc":{"start":{"line":5,"column":21,"index":121},"end":{"line":5,"column":23,"index":123}}, + "members": [] + } + ] + } + } + } + }, + "init": { + "type": "CallExpression", + "start":127,"end":150,"loc":{"start":{"line":5,"column":27,"index":127},"end":{"line":5,"column":50,"index":150}}, + "callee": { + "type": "MemberExpression", + "start":127,"end":146,"loc":{"start":{"line":5,"column":27,"index":127},"end":{"line":5,"column":46,"index":146}}, + "object": { + "type": "Identifier", + "start":127,"end":132,"loc":{"start":{"line":5,"column":27,"index":127},"end":{"line":5,"column":32,"index":132},"identifierName":"React"}, + "name": "React" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":133,"end":146,"loc":{"start":{"line":5,"column":33,"index":133},"end":{"line":5,"column":46,"index":146},"identifierName":"createContext"}, + "name": "createContext" + } + }, + "arguments": [ + { + "type": "ObjectExpression", + "start":147,"end":149,"loc":{"start":{"line":5,"column":47,"index":147},"end":{"line":5,"column":49,"index":149}}, + "properties": [] + } + ] + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start":152,"end":165,"loc":{"start":{"line":6,"column":0,"index":152},"end":{"line":6,"column":13,"index":165}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":156,"end":164,"loc":{"start":{"line":6,"column":4,"index":156},"end":{"line":6,"column":12,"index":164}}, + "id": { + "type": "Identifier", + "start":156,"end":160,"loc":{"start":{"line":6,"column":4,"index":156},"end":{"line":6,"column":8,"index":160},"identifierName":"a"}, + "name": "a", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":157,"end":160,"loc":{"start":{"line":6,"column":5,"index":157},"end":{"line":6,"column":8,"index":160}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":159,"end":160,"loc":{"start":{"line":6,"column":7,"index":159},"end":{"line":6,"column":8,"index":160}}, + "typeName": { + "type": "Identifier", + "start":159,"end":160,"loc":{"start":{"line":6,"column":7,"index":159},"end":{"line":6,"column":8,"index":160},"identifierName":"a"}, + "name": "a" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":163,"end":164,"loc":{"start":{"line":6,"column":11,"index":163},"end":{"line":6,"column":12,"index":164}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start":166,"end":179,"loc":{"start":{"line":7,"column":0,"index":166},"end":{"line":7,"column":13,"index":179}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":170,"end":178,"loc":{"start":{"line":7,"column":4,"index":170},"end":{"line":7,"column":12,"index":178}}, + "id": { + "type": "Identifier", + "start":170,"end":174,"loc":{"start":{"line":7,"column":4,"index":170},"end":{"line":7,"column":8,"index":174},"identifierName":"b"}, + "name": "b", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":171,"end":174,"loc":{"start":{"line":7,"column":5,"index":171},"end":{"line":7,"column":8,"index":174}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":173,"end":174,"loc":{"start":{"line":7,"column":7,"index":173},"end":{"line":7,"column":8,"index":174}}, + "typeName": { + "type": "Identifier", + "start":173,"end":174,"loc":{"start":{"line":7,"column":7,"index":173},"end":{"line":7,"column":8,"index":174},"identifierName":"b"}, + "name": "b" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start":177,"end":178,"loc":{"start":{"line":7,"column":11,"index":177},"end":{"line":7,"column":12,"index":178}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module-and-top-level/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module-and-top-level/input.ts new file mode 100644 index 000000000000..053ad89a9295 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module-and-top-level/input.ts @@ -0,0 +1,46 @@ +type T = number; +import { fooBar } from "baz"; +import type { JSONSchema7 } from 'json-schema'; + +export { JSONSchema7 } +export { fooBar } + +export { fooBar2 } from "baz"; +export type { fooBar3 } from "baz"; +export { type fooBar4 } from "baz"; + +export type { fooBar3 as a } from "baz"; +export { type fooBar4 as b} from "baz"; + +let foo: JSONSchema7; + +declare module 'test/submodule' { + export { JSONSchema7 } + export { fooBar } + + export { fooBar2 } from "baz"; + export type { fooBar3 } from "baz"; + export { type fooBar4 } from "baz"; + + export type { fooBar3 as a } from "baz"; + export { type fooBar4 as b} from "baz"; + + let foo: JSONSchema7; +} + +declare module 'test/submodule2' { + import { fooBar } from "baz"; + import type { JSONSchema7 } from 'json-schema'; + + export { JSONSchema7 } + export { fooBar } + + export { fooBar2 } from "baz"; + export type { fooBar3 } from "baz"; + export { type fooBar4 } from "baz"; + + export type { fooBar3 as a } from "baz"; + export { type fooBar4 as b} from "baz"; + + let foo: JSONSchema7; +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module-and-top-level/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module-and-top-level/output.json new file mode 100644 index 000000000000..c740d8563be5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module-and-top-level/output.json @@ -0,0 +1,904 @@ +{ + "type": "File", + "start":0,"end":1035,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":46,"column":1,"index":1035}}, + "program": { + "type": "Program", + "start":0,"end":1035,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":46,"column":1,"index":1035}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":16,"index":16}}, + "id": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":6,"index":6},"identifierName":"T"}, + "name": "T" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":15,"index":15}} + } + }, + { + "type": "ImportDeclaration", + "start":17,"end":46,"loc":{"start":{"line":2,"column":0,"index":17},"end":{"line":2,"column":29,"index":46}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":26,"end":32,"loc":{"start":{"line":2,"column":9,"index":26},"end":{"line":2,"column":15,"index":32}}, + "imported": { + "type": "Identifier", + "start":26,"end":32,"loc":{"start":{"line":2,"column":9,"index":26},"end":{"line":2,"column":15,"index":32},"identifierName":"fooBar"}, + "name": "fooBar" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":26,"end":32,"loc":{"start":{"line":2,"column":9,"index":26},"end":{"line":2,"column":15,"index":32},"identifierName":"fooBar"}, + "name": "fooBar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":40,"end":45,"loc":{"start":{"line":2,"column":23,"index":40},"end":{"line":2,"column":28,"index":45}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + } + }, + { + "type": "ImportDeclaration", + "start":47,"end":94,"loc":{"start":{"line":3,"column":0,"index":47},"end":{"line":3,"column":47,"index":94}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":61,"end":72,"loc":{"start":{"line":3,"column":14,"index":61},"end":{"line":3,"column":25,"index":72}}, + "imported": { + "type": "Identifier", + "start":61,"end":72,"loc":{"start":{"line":3,"column":14,"index":61},"end":{"line":3,"column":25,"index":72},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":61,"end":72,"loc":{"start":{"line":3,"column":14,"index":61},"end":{"line":3,"column":25,"index":72},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": { + "type": "StringLiteral", + "start":80,"end":93,"loc":{"start":{"line":3,"column":33,"index":80},"end":{"line":3,"column":46,"index":93}}, + "extra": { + "rawValue": "json-schema", + "raw": "'json-schema'" + }, + "value": "json-schema" + } + }, + { + "type": "ExportNamedDeclaration", + "start":96,"end":118,"loc":{"start":{"line":5,"column":0,"index":96},"end":{"line":5,"column":22,"index":118}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":105,"end":116,"loc":{"start":{"line":5,"column":9,"index":105},"end":{"line":5,"column":20,"index":116}}, + "local": { + "type": "Identifier", + "start":105,"end":116,"loc":{"start":{"line":5,"column":9,"index":105},"end":{"line":5,"column":20,"index":116},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":105,"end":116,"loc":{"start":{"line":5,"column":9,"index":105},"end":{"line":5,"column":20,"index":116},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":119,"end":136,"loc":{"start":{"line":6,"column":0,"index":119},"end":{"line":6,"column":17,"index":136}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":128,"end":134,"loc":{"start":{"line":6,"column":9,"index":128},"end":{"line":6,"column":15,"index":134}}, + "local": { + "type": "Identifier", + "start":128,"end":134,"loc":{"start":{"line":6,"column":9,"index":128},"end":{"line":6,"column":15,"index":134},"identifierName":"fooBar"}, + "name": "fooBar" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":128,"end":134,"loc":{"start":{"line":6,"column":9,"index":128},"end":{"line":6,"column":15,"index":134},"identifierName":"fooBar"}, + "name": "fooBar" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":138,"end":168,"loc":{"start":{"line":8,"column":0,"index":138},"end":{"line":8,"column":30,"index":168}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":147,"end":154,"loc":{"start":{"line":8,"column":9,"index":147},"end":{"line":8,"column":16,"index":154}}, + "local": { + "type": "Identifier", + "start":147,"end":154,"loc":{"start":{"line":8,"column":9,"index":147},"end":{"line":8,"column":16,"index":154},"identifierName":"fooBar2"}, + "name": "fooBar2" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":147,"end":154,"loc":{"start":{"line":8,"column":9,"index":147},"end":{"line":8,"column":16,"index":154},"identifierName":"fooBar2"}, + "name": "fooBar2" + } + } + ], + "source": { + "type": "StringLiteral", + "start":162,"end":167,"loc":{"start":{"line":8,"column":24,"index":162},"end":{"line":8,"column":29,"index":167}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":169,"end":204,"loc":{"start":{"line":9,"column":0,"index":169},"end":{"line":9,"column":35,"index":204}}, + "exportKind": "type", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":183,"end":190,"loc":{"start":{"line":9,"column":14,"index":183},"end":{"line":9,"column":21,"index":190}}, + "local": { + "type": "Identifier", + "start":183,"end":190,"loc":{"start":{"line":9,"column":14,"index":183},"end":{"line":9,"column":21,"index":190},"identifierName":"fooBar3"}, + "name": "fooBar3" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":183,"end":190,"loc":{"start":{"line":9,"column":14,"index":183},"end":{"line":9,"column":21,"index":190},"identifierName":"fooBar3"}, + "name": "fooBar3" + } + } + ], + "source": { + "type": "StringLiteral", + "start":198,"end":203,"loc":{"start":{"line":9,"column":29,"index":198},"end":{"line":9,"column":34,"index":203}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":205,"end":240,"loc":{"start":{"line":10,"column":0,"index":205},"end":{"line":10,"column":35,"index":240}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":214,"end":226,"loc":{"start":{"line":10,"column":9,"index":214},"end":{"line":10,"column":21,"index":226}}, + "local": { + "type": "Identifier", + "start":219,"end":226,"loc":{"start":{"line":10,"column":14,"index":219},"end":{"line":10,"column":21,"index":226},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exported": { + "type": "Identifier", + "start":219,"end":226,"loc":{"start":{"line":10,"column":14,"index":219},"end":{"line":10,"column":21,"index":226},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exportKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":234,"end":239,"loc":{"start":{"line":10,"column":29,"index":234},"end":{"line":10,"column":34,"index":239}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":242,"end":282,"loc":{"start":{"line":12,"column":0,"index":242},"end":{"line":12,"column":40,"index":282}}, + "exportKind": "type", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":256,"end":268,"loc":{"start":{"line":12,"column":14,"index":256},"end":{"line":12,"column":26,"index":268}}, + "local": { + "type": "Identifier", + "start":256,"end":263,"loc":{"start":{"line":12,"column":14,"index":256},"end":{"line":12,"column":21,"index":263},"identifierName":"fooBar3"}, + "name": "fooBar3" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":267,"end":268,"loc":{"start":{"line":12,"column":25,"index":267},"end":{"line":12,"column":26,"index":268},"identifierName":"a"}, + "name": "a" + } + } + ], + "source": { + "type": "StringLiteral", + "start":276,"end":281,"loc":{"start":{"line":12,"column":34,"index":276},"end":{"line":12,"column":39,"index":281}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":283,"end":322,"loc":{"start":{"line":13,"column":0,"index":283},"end":{"line":13,"column":39,"index":322}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":292,"end":309,"loc":{"start":{"line":13,"column":9,"index":292},"end":{"line":13,"column":26,"index":309}}, + "local": { + "type": "Identifier", + "start":297,"end":304,"loc":{"start":{"line":13,"column":14,"index":297},"end":{"line":13,"column":21,"index":304},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exported": { + "type": "Identifier", + "start":308,"end":309,"loc":{"start":{"line":13,"column":25,"index":308},"end":{"line":13,"column":26,"index":309},"identifierName":"b"}, + "name": "b" + }, + "exportKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":316,"end":321,"loc":{"start":{"line":13,"column":33,"index":316},"end":{"line":13,"column":38,"index":321}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start":324,"end":345,"loc":{"start":{"line":15,"column":0,"index":324},"end":{"line":15,"column":21,"index":345}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":328,"end":344,"loc":{"start":{"line":15,"column":4,"index":328},"end":{"line":15,"column":20,"index":344}}, + "id": { + "type": "Identifier", + "start":328,"end":344,"loc":{"start":{"line":15,"column":4,"index":328},"end":{"line":15,"column":20,"index":344},"identifierName":"foo"}, + "name": "foo", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":331,"end":344,"loc":{"start":{"line":15,"column":7,"index":331},"end":{"line":15,"column":20,"index":344}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":333,"end":344,"loc":{"start":{"line":15,"column":9,"index":333},"end":{"line":15,"column":20,"index":344}}, + "typeName": { + "type": "Identifier", + "start":333,"end":344,"loc":{"start":{"line":15,"column":9,"index":333},"end":{"line":15,"column":20,"index":344},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + } + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "TSModuleDeclaration", + "start":347,"end":648,"loc":{"start":{"line":17,"column":0,"index":347},"end":{"line":29,"column":1,"index":648}}, + "id": { + "type": "StringLiteral", + "start":362,"end":378,"loc":{"start":{"line":17,"column":15,"index":362},"end":{"line":17,"column":31,"index":378}}, + "extra": { + "rawValue": "test/submodule", + "raw": "'test/submodule'" + }, + "value": "test/submodule" + }, + "body": { + "type": "TSModuleBlock", + "start":379,"end":648,"loc":{"start":{"line":17,"column":32,"index":379},"end":{"line":29,"column":1,"index":648}}, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":383,"end":405,"loc":{"start":{"line":18,"column":2,"index":383},"end":{"line":18,"column":24,"index":405}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":392,"end":403,"loc":{"start":{"line":18,"column":11,"index":392},"end":{"line":18,"column":22,"index":403}}, + "local": { + "type": "Identifier", + "start":392,"end":403,"loc":{"start":{"line":18,"column":11,"index":392},"end":{"line":18,"column":22,"index":403},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":392,"end":403,"loc":{"start":{"line":18,"column":11,"index":392},"end":{"line":18,"column":22,"index":403},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":408,"end":425,"loc":{"start":{"line":19,"column":2,"index":408},"end":{"line":19,"column":19,"index":425}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":417,"end":423,"loc":{"start":{"line":19,"column":11,"index":417},"end":{"line":19,"column":17,"index":423}}, + "local": { + "type": "Identifier", + "start":417,"end":423,"loc":{"start":{"line":19,"column":11,"index":417},"end":{"line":19,"column":17,"index":423},"identifierName":"fooBar"}, + "name": "fooBar" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":417,"end":423,"loc":{"start":{"line":19,"column":11,"index":417},"end":{"line":19,"column":17,"index":423},"identifierName":"fooBar"}, + "name": "fooBar" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":429,"end":459,"loc":{"start":{"line":21,"column":2,"index":429},"end":{"line":21,"column":32,"index":459}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":438,"end":445,"loc":{"start":{"line":21,"column":11,"index":438},"end":{"line":21,"column":18,"index":445}}, + "local": { + "type": "Identifier", + "start":438,"end":445,"loc":{"start":{"line":21,"column":11,"index":438},"end":{"line":21,"column":18,"index":445},"identifierName":"fooBar2"}, + "name": "fooBar2" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":438,"end":445,"loc":{"start":{"line":21,"column":11,"index":438},"end":{"line":21,"column":18,"index":445},"identifierName":"fooBar2"}, + "name": "fooBar2" + } + } + ], + "source": { + "type": "StringLiteral", + "start":453,"end":458,"loc":{"start":{"line":21,"column":26,"index":453},"end":{"line":21,"column":31,"index":458}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":462,"end":497,"loc":{"start":{"line":22,"column":2,"index":462},"end":{"line":22,"column":37,"index":497}}, + "exportKind": "type", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":476,"end":483,"loc":{"start":{"line":22,"column":16,"index":476},"end":{"line":22,"column":23,"index":483}}, + "local": { + "type": "Identifier", + "start":476,"end":483,"loc":{"start":{"line":22,"column":16,"index":476},"end":{"line":22,"column":23,"index":483},"identifierName":"fooBar3"}, + "name": "fooBar3" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":476,"end":483,"loc":{"start":{"line":22,"column":16,"index":476},"end":{"line":22,"column":23,"index":483},"identifierName":"fooBar3"}, + "name": "fooBar3" + } + } + ], + "source": { + "type": "StringLiteral", + "start":491,"end":496,"loc":{"start":{"line":22,"column":31,"index":491},"end":{"line":22,"column":36,"index":496}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":500,"end":535,"loc":{"start":{"line":23,"column":2,"index":500},"end":{"line":23,"column":37,"index":535}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":509,"end":521,"loc":{"start":{"line":23,"column":11,"index":509},"end":{"line":23,"column":23,"index":521}}, + "local": { + "type": "Identifier", + "start":514,"end":521,"loc":{"start":{"line":23,"column":16,"index":514},"end":{"line":23,"column":23,"index":521},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exported": { + "type": "Identifier", + "start":514,"end":521,"loc":{"start":{"line":23,"column":16,"index":514},"end":{"line":23,"column":23,"index":521},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exportKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":529,"end":534,"loc":{"start":{"line":23,"column":31,"index":529},"end":{"line":23,"column":36,"index":534}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":539,"end":579,"loc":{"start":{"line":25,"column":2,"index":539},"end":{"line":25,"column":42,"index":579}}, + "exportKind": "type", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":553,"end":565,"loc":{"start":{"line":25,"column":16,"index":553},"end":{"line":25,"column":28,"index":565}}, + "local": { + "type": "Identifier", + "start":553,"end":560,"loc":{"start":{"line":25,"column":16,"index":553},"end":{"line":25,"column":23,"index":560},"identifierName":"fooBar3"}, + "name": "fooBar3" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":564,"end":565,"loc":{"start":{"line":25,"column":27,"index":564},"end":{"line":25,"column":28,"index":565},"identifierName":"a"}, + "name": "a" + } + } + ], + "source": { + "type": "StringLiteral", + "start":573,"end":578,"loc":{"start":{"line":25,"column":36,"index":573},"end":{"line":25,"column":41,"index":578}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":582,"end":621,"loc":{"start":{"line":26,"column":2,"index":582},"end":{"line":26,"column":41,"index":621}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":591,"end":608,"loc":{"start":{"line":26,"column":11,"index":591},"end":{"line":26,"column":28,"index":608}}, + "local": { + "type": "Identifier", + "start":596,"end":603,"loc":{"start":{"line":26,"column":16,"index":596},"end":{"line":26,"column":23,"index":603},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exported": { + "type": "Identifier", + "start":607,"end":608,"loc":{"start":{"line":26,"column":27,"index":607},"end":{"line":26,"column":28,"index":608},"identifierName":"b"}, + "name": "b" + }, + "exportKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":615,"end":620,"loc":{"start":{"line":26,"column":35,"index":615},"end":{"line":26,"column":40,"index":620}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start":625,"end":646,"loc":{"start":{"line":28,"column":2,"index":625},"end":{"line":28,"column":23,"index":646}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":629,"end":645,"loc":{"start":{"line":28,"column":6,"index":629},"end":{"line":28,"column":22,"index":645}}, + "id": { + "type": "Identifier", + "start":629,"end":645,"loc":{"start":{"line":28,"column":6,"index":629},"end":{"line":28,"column":22,"index":645},"identifierName":"foo"}, + "name": "foo", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":632,"end":645,"loc":{"start":{"line":28,"column":9,"index":632},"end":{"line":28,"column":22,"index":645}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":634,"end":645,"loc":{"start":{"line":28,"column":11,"index":634},"end":{"line":28,"column":22,"index":645}}, + "typeName": { + "type": "Identifier", + "start":634,"end":645,"loc":{"start":{"line":28,"column":11,"index":634},"end":{"line":28,"column":22,"index":645},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + } + }, + "init": null + } + ], + "kind": "let" + } + ] + }, + "declare": true + }, + { + "type": "TSModuleDeclaration", + "start":650,"end":1035,"loc":{"start":{"line":31,"column":0,"index":650},"end":{"line":46,"column":1,"index":1035}}, + "id": { + "type": "StringLiteral", + "start":665,"end":682,"loc":{"start":{"line":31,"column":15,"index":665},"end":{"line":31,"column":32,"index":682}}, + "extra": { + "rawValue": "test/submodule2", + "raw": "'test/submodule2'" + }, + "value": "test/submodule2" + }, + "body": { + "type": "TSModuleBlock", + "start":683,"end":1035,"loc":{"start":{"line":31,"column":33,"index":683},"end":{"line":46,"column":1,"index":1035}}, + "body": [ + { + "type": "ImportDeclaration", + "start":687,"end":716,"loc":{"start":{"line":32,"column":2,"index":687},"end":{"line":32,"column":31,"index":716}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":696,"end":702,"loc":{"start":{"line":32,"column":11,"index":696},"end":{"line":32,"column":17,"index":702}}, + "imported": { + "type": "Identifier", + "start":696,"end":702,"loc":{"start":{"line":32,"column":11,"index":696},"end":{"line":32,"column":17,"index":702},"identifierName":"fooBar"}, + "name": "fooBar" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":696,"end":702,"loc":{"start":{"line":32,"column":11,"index":696},"end":{"line":32,"column":17,"index":702},"identifierName":"fooBar"}, + "name": "fooBar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":710,"end":715,"loc":{"start":{"line":32,"column":25,"index":710},"end":{"line":32,"column":30,"index":715}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + } + }, + { + "type": "ImportDeclaration", + "start":719,"end":766,"loc":{"start":{"line":33,"column":2,"index":719},"end":{"line":33,"column":49,"index":766}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":733,"end":744,"loc":{"start":{"line":33,"column":16,"index":733},"end":{"line":33,"column":27,"index":744}}, + "imported": { + "type": "Identifier", + "start":733,"end":744,"loc":{"start":{"line":33,"column":16,"index":733},"end":{"line":33,"column":27,"index":744},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":733,"end":744,"loc":{"start":{"line":33,"column":16,"index":733},"end":{"line":33,"column":27,"index":744},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": { + "type": "StringLiteral", + "start":752,"end":765,"loc":{"start":{"line":33,"column":35,"index":752},"end":{"line":33,"column":48,"index":765}}, + "extra": { + "rawValue": "json-schema", + "raw": "'json-schema'" + }, + "value": "json-schema" + } + }, + { + "type": "ExportNamedDeclaration", + "start":770,"end":792,"loc":{"start":{"line":35,"column":2,"index":770},"end":{"line":35,"column":24,"index":792}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":779,"end":790,"loc":{"start":{"line":35,"column":11,"index":779},"end":{"line":35,"column":22,"index":790}}, + "local": { + "type": "Identifier", + "start":779,"end":790,"loc":{"start":{"line":35,"column":11,"index":779},"end":{"line":35,"column":22,"index":790},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":779,"end":790,"loc":{"start":{"line":35,"column":11,"index":779},"end":{"line":35,"column":22,"index":790},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":795,"end":812,"loc":{"start":{"line":36,"column":2,"index":795},"end":{"line":36,"column":19,"index":812}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":804,"end":810,"loc":{"start":{"line":36,"column":11,"index":804},"end":{"line":36,"column":17,"index":810}}, + "local": { + "type": "Identifier", + "start":804,"end":810,"loc":{"start":{"line":36,"column":11,"index":804},"end":{"line":36,"column":17,"index":810},"identifierName":"fooBar"}, + "name": "fooBar" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":804,"end":810,"loc":{"start":{"line":36,"column":11,"index":804},"end":{"line":36,"column":17,"index":810},"identifierName":"fooBar"}, + "name": "fooBar" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":816,"end":846,"loc":{"start":{"line":38,"column":2,"index":816},"end":{"line":38,"column":32,"index":846}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":825,"end":832,"loc":{"start":{"line":38,"column":11,"index":825},"end":{"line":38,"column":18,"index":832}}, + "local": { + "type": "Identifier", + "start":825,"end":832,"loc":{"start":{"line":38,"column":11,"index":825},"end":{"line":38,"column":18,"index":832},"identifierName":"fooBar2"}, + "name": "fooBar2" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":825,"end":832,"loc":{"start":{"line":38,"column":11,"index":825},"end":{"line":38,"column":18,"index":832},"identifierName":"fooBar2"}, + "name": "fooBar2" + } + } + ], + "source": { + "type": "StringLiteral", + "start":840,"end":845,"loc":{"start":{"line":38,"column":26,"index":840},"end":{"line":38,"column":31,"index":845}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":849,"end":884,"loc":{"start":{"line":39,"column":2,"index":849},"end":{"line":39,"column":37,"index":884}}, + "exportKind": "type", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":863,"end":870,"loc":{"start":{"line":39,"column":16,"index":863},"end":{"line":39,"column":23,"index":870}}, + "local": { + "type": "Identifier", + "start":863,"end":870,"loc":{"start":{"line":39,"column":16,"index":863},"end":{"line":39,"column":23,"index":870},"identifierName":"fooBar3"}, + "name": "fooBar3" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":863,"end":870,"loc":{"start":{"line":39,"column":16,"index":863},"end":{"line":39,"column":23,"index":870},"identifierName":"fooBar3"}, + "name": "fooBar3" + } + } + ], + "source": { + "type": "StringLiteral", + "start":878,"end":883,"loc":{"start":{"line":39,"column":31,"index":878},"end":{"line":39,"column":36,"index":883}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":887,"end":922,"loc":{"start":{"line":40,"column":2,"index":887},"end":{"line":40,"column":37,"index":922}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":896,"end":908,"loc":{"start":{"line":40,"column":11,"index":896},"end":{"line":40,"column":23,"index":908}}, + "local": { + "type": "Identifier", + "start":901,"end":908,"loc":{"start":{"line":40,"column":16,"index":901},"end":{"line":40,"column":23,"index":908},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exported": { + "type": "Identifier", + "start":901,"end":908,"loc":{"start":{"line":40,"column":16,"index":901},"end":{"line":40,"column":23,"index":908},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exportKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":916,"end":921,"loc":{"start":{"line":40,"column":31,"index":916},"end":{"line":40,"column":36,"index":921}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":926,"end":966,"loc":{"start":{"line":42,"column":2,"index":926},"end":{"line":42,"column":42,"index":966}}, + "exportKind": "type", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":940,"end":952,"loc":{"start":{"line":42,"column":16,"index":940},"end":{"line":42,"column":28,"index":952}}, + "local": { + "type": "Identifier", + "start":940,"end":947,"loc":{"start":{"line":42,"column":16,"index":940},"end":{"line":42,"column":23,"index":947},"identifierName":"fooBar3"}, + "name": "fooBar3" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":951,"end":952,"loc":{"start":{"line":42,"column":27,"index":951},"end":{"line":42,"column":28,"index":952},"identifierName":"a"}, + "name": "a" + } + } + ], + "source": { + "type": "StringLiteral", + "start":960,"end":965,"loc":{"start":{"line":42,"column":36,"index":960},"end":{"line":42,"column":41,"index":965}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start":969,"end":1008,"loc":{"start":{"line":43,"column":2,"index":969},"end":{"line":43,"column":41,"index":1008}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":978,"end":995,"loc":{"start":{"line":43,"column":11,"index":978},"end":{"line":43,"column":28,"index":995}}, + "local": { + "type": "Identifier", + "start":983,"end":990,"loc":{"start":{"line":43,"column":16,"index":983},"end":{"line":43,"column":23,"index":990},"identifierName":"fooBar4"}, + "name": "fooBar4" + }, + "exported": { + "type": "Identifier", + "start":994,"end":995,"loc":{"start":{"line":43,"column":27,"index":994},"end":{"line":43,"column":28,"index":995},"identifierName":"b"}, + "name": "b" + }, + "exportKind": "type" + } + ], + "source": { + "type": "StringLiteral", + "start":1002,"end":1007,"loc":{"start":{"line":43,"column":35,"index":1002},"end":{"line":43,"column":40,"index":1007}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start":1012,"end":1033,"loc":{"start":{"line":45,"column":2,"index":1012},"end":{"line":45,"column":23,"index":1033}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":1016,"end":1032,"loc":{"start":{"line":45,"column":6,"index":1016},"end":{"line":45,"column":22,"index":1032}}, + "id": { + "type": "Identifier", + "start":1016,"end":1032,"loc":{"start":{"line":45,"column":6,"index":1016},"end":{"line":45,"column":22,"index":1032},"identifierName":"foo"}, + "name": "foo", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":1019,"end":1032,"loc":{"start":{"line":45,"column":9,"index":1019},"end":{"line":45,"column":22,"index":1032}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":1021,"end":1032,"loc":{"start":{"line":45,"column":11,"index":1021},"end":{"line":45,"column":22,"index":1032}}, + "typeName": { + "type": "Identifier", + "start":1021,"end":1032,"loc":{"start":{"line":45,"column":11,"index":1021},"end":{"line":45,"column":22,"index":1032},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + } + }, + "init": null + } + ], + "kind": "let" + } + ] + }, + "declare": true + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module/input.ts new file mode 100644 index 000000000000..d0085e0209e4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module/input.ts @@ -0,0 +1,18 @@ +// packages\babel-traverse\test\fixtures\regression\duplicate-variable-in-different-module-ts\input.ts + +type T = number; +declare module 'test' { + import type { JSONSchema7 } from 'json-schema'; + import { bar } from "baz"; + export { fooBar } from "baz"; + let foo: JSONSchema7; + // can reference type outsider module + let baz: T; +} + +declare module 'test/submodule' { + import type { JSONSchema7 } from 'json-schema'; + import { bar } from "baz"; + export { fooBar } from "baz"; + let foo: JSONSchema7; +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module/output.json new file mode 100644 index 000000000000..69291765bce5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-different-module/output.json @@ -0,0 +1,377 @@ +{ + "type": "File", + "start":0,"end":507,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":18,"column":1,"index":507}}, + "program": { + "type": "Program", + "start":0,"end":507,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":18,"column":1,"index":507}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start":104,"end":120,"loc":{"start":{"line":3,"column":0,"index":104},"end":{"line":3,"column":16,"index":120}}, + "id": { + "type": "Identifier", + "start":109,"end":110,"loc":{"start":{"line":3,"column":5,"index":109},"end":{"line":3,"column":6,"index":110},"identifierName":"T"}, + "name": "T" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start":113,"end":119,"loc":{"start":{"line":3,"column":9,"index":113},"end":{"line":3,"column":15,"index":119}} + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": " packages\\babel-traverse\\test\\fixtures\\regression\\duplicate-variable-in-different-module-ts\\input.ts", + "start":0,"end":102,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":102,"index":102}} + } + ] + }, + { + "type": "TSModuleDeclaration", + "start":121,"end":335,"loc":{"start":{"line":4,"column":0,"index":121},"end":{"line":11,"column":1,"index":335}}, + "id": { + "type": "StringLiteral", + "start":136,"end":142,"loc":{"start":{"line":4,"column":15,"index":136},"end":{"line":4,"column":21,"index":142}}, + "extra": { + "rawValue": "test", + "raw": "'test'" + }, + "value": "test" + }, + "body": { + "type": "TSModuleBlock", + "start":143,"end":335,"loc":{"start":{"line":4,"column":22,"index":143},"end":{"line":11,"column":1,"index":335}}, + "body": [ + { + "type": "ImportDeclaration", + "start":147,"end":194,"loc":{"start":{"line":5,"column":2,"index":147},"end":{"line":5,"column":49,"index":194}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":161,"end":172,"loc":{"start":{"line":5,"column":16,"index":161},"end":{"line":5,"column":27,"index":172}}, + "imported": { + "type": "Identifier", + "start":161,"end":172,"loc":{"start":{"line":5,"column":16,"index":161},"end":{"line":5,"column":27,"index":172},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":161,"end":172,"loc":{"start":{"line":5,"column":16,"index":161},"end":{"line":5,"column":27,"index":172},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": { + "type": "StringLiteral", + "start":180,"end":193,"loc":{"start":{"line":5,"column":35,"index":180},"end":{"line":5,"column":48,"index":193}}, + "extra": { + "rawValue": "json-schema", + "raw": "'json-schema'" + }, + "value": "json-schema" + } + }, + { + "type": "ImportDeclaration", + "start":197,"end":223,"loc":{"start":{"line":6,"column":2,"index":197},"end":{"line":6,"column":28,"index":223}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":206,"end":209,"loc":{"start":{"line":6,"column":11,"index":206},"end":{"line":6,"column":14,"index":209}}, + "imported": { + "type": "Identifier", + "start":206,"end":209,"loc":{"start":{"line":6,"column":11,"index":206},"end":{"line":6,"column":14,"index":209},"identifierName":"bar"}, + "name": "bar" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":206,"end":209,"loc":{"start":{"line":6,"column":11,"index":206},"end":{"line":6,"column":14,"index":209},"identifierName":"bar"}, + "name": "bar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":217,"end":222,"loc":{"start":{"line":6,"column":22,"index":217},"end":{"line":6,"column":27,"index":222}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + } + }, + { + "type": "ExportNamedDeclaration", + "start":226,"end":255,"loc":{"start":{"line":7,"column":2,"index":226},"end":{"line":7,"column":31,"index":255}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":235,"end":241,"loc":{"start":{"line":7,"column":11,"index":235},"end":{"line":7,"column":17,"index":241}}, + "local": { + "type": "Identifier", + "start":235,"end":241,"loc":{"start":{"line":7,"column":11,"index":235},"end":{"line":7,"column":17,"index":241},"identifierName":"fooBar"}, + "name": "fooBar" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":235,"end":241,"loc":{"start":{"line":7,"column":11,"index":235},"end":{"line":7,"column":17,"index":241},"identifierName":"fooBar"}, + "name": "fooBar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":249,"end":254,"loc":{"start":{"line":7,"column":25,"index":249},"end":{"line":7,"column":30,"index":254}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start":258,"end":279,"loc":{"start":{"line":8,"column":2,"index":258},"end":{"line":8,"column":23,"index":279}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":262,"end":278,"loc":{"start":{"line":8,"column":6,"index":262},"end":{"line":8,"column":22,"index":278}}, + "id": { + "type": "Identifier", + "start":262,"end":278,"loc":{"start":{"line":8,"column":6,"index":262},"end":{"line":8,"column":22,"index":278},"identifierName":"foo"}, + "name": "foo", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":265,"end":278,"loc":{"start":{"line":8,"column":9,"index":265},"end":{"line":8,"column":22,"index":278}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":267,"end":278,"loc":{"start":{"line":8,"column":11,"index":267},"end":{"line":8,"column":22,"index":278}}, + "typeName": { + "type": "Identifier", + "start":267,"end":278,"loc":{"start":{"line":8,"column":11,"index":267},"end":{"line":8,"column":22,"index":278},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + } + }, + "init": null + } + ], + "kind": "let", + "trailingComments": [ + { + "type": "CommentLine", + "value": " can reference type outsider module", + "start":282,"end":319,"loc":{"start":{"line":9,"column":2,"index":282},"end":{"line":9,"column":39,"index":319}} + } + ] + }, + { + "type": "VariableDeclaration", + "start":322,"end":333,"loc":{"start":{"line":10,"column":2,"index":322},"end":{"line":10,"column":13,"index":333}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":326,"end":332,"loc":{"start":{"line":10,"column":6,"index":326},"end":{"line":10,"column":12,"index":332}}, + "id": { + "type": "Identifier", + "start":326,"end":332,"loc":{"start":{"line":10,"column":6,"index":326},"end":{"line":10,"column":12,"index":332},"identifierName":"baz"}, + "name": "baz", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":329,"end":332,"loc":{"start":{"line":10,"column":9,"index":329},"end":{"line":10,"column":12,"index":332}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":331,"end":332,"loc":{"start":{"line":10,"column":11,"index":331},"end":{"line":10,"column":12,"index":332}}, + "typeName": { + "type": "Identifier", + "start":331,"end":332,"loc":{"start":{"line":10,"column":11,"index":331},"end":{"line":10,"column":12,"index":332},"identifierName":"T"}, + "name": "T" + } + } + } + }, + "init": null + } + ], + "kind": "let", + "leadingComments": [ + { + "type": "CommentLine", + "value": " can reference type outsider module", + "start":282,"end":319,"loc":{"start":{"line":9,"column":2,"index":282},"end":{"line":9,"column":39,"index":319}} + } + ] + } + ] + }, + "declare": true + }, + { + "type": "TSModuleDeclaration", + "start":337,"end":507,"loc":{"start":{"line":13,"column":0,"index":337},"end":{"line":18,"column":1,"index":507}}, + "id": { + "type": "StringLiteral", + "start":352,"end":368,"loc":{"start":{"line":13,"column":15,"index":352},"end":{"line":13,"column":31,"index":368}}, + "extra": { + "rawValue": "test/submodule", + "raw": "'test/submodule'" + }, + "value": "test/submodule" + }, + "body": { + "type": "TSModuleBlock", + "start":369,"end":507,"loc":{"start":{"line":13,"column":32,"index":369},"end":{"line":18,"column":1,"index":507}}, + "body": [ + { + "type": "ImportDeclaration", + "start":373,"end":420,"loc":{"start":{"line":14,"column":2,"index":373},"end":{"line":14,"column":49,"index":420}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":387,"end":398,"loc":{"start":{"line":14,"column":16,"index":387},"end":{"line":14,"column":27,"index":398}}, + "imported": { + "type": "Identifier", + "start":387,"end":398,"loc":{"start":{"line":14,"column":16,"index":387},"end":{"line":14,"column":27,"index":398},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":387,"end":398,"loc":{"start":{"line":14,"column":16,"index":387},"end":{"line":14,"column":27,"index":398},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": { + "type": "StringLiteral", + "start":406,"end":419,"loc":{"start":{"line":14,"column":35,"index":406},"end":{"line":14,"column":48,"index":419}}, + "extra": { + "rawValue": "json-schema", + "raw": "'json-schema'" + }, + "value": "json-schema" + } + }, + { + "type": "ImportDeclaration", + "start":423,"end":449,"loc":{"start":{"line":15,"column":2,"index":423},"end":{"line":15,"column":28,"index":449}}, + "importKind": "value", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":432,"end":435,"loc":{"start":{"line":15,"column":11,"index":432},"end":{"line":15,"column":14,"index":435}}, + "imported": { + "type": "Identifier", + "start":432,"end":435,"loc":{"start":{"line":15,"column":11,"index":432},"end":{"line":15,"column":14,"index":435},"identifierName":"bar"}, + "name": "bar" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":432,"end":435,"loc":{"start":{"line":15,"column":11,"index":432},"end":{"line":15,"column":14,"index":435},"identifierName":"bar"}, + "name": "bar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":443,"end":448,"loc":{"start":{"line":15,"column":22,"index":443},"end":{"line":15,"column":27,"index":448}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + } + }, + { + "type": "ExportNamedDeclaration", + "start":452,"end":481,"loc":{"start":{"line":16,"column":2,"index":452},"end":{"line":16,"column":31,"index":481}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":461,"end":467,"loc":{"start":{"line":16,"column":11,"index":461},"end":{"line":16,"column":17,"index":467}}, + "local": { + "type": "Identifier", + "start":461,"end":467,"loc":{"start":{"line":16,"column":11,"index":461},"end":{"line":16,"column":17,"index":467},"identifierName":"fooBar"}, + "name": "fooBar" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":461,"end":467,"loc":{"start":{"line":16,"column":11,"index":461},"end":{"line":16,"column":17,"index":467},"identifierName":"fooBar"}, + "name": "fooBar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":475,"end":480,"loc":{"start":{"line":16,"column":25,"index":475},"end":{"line":16,"column":30,"index":480}}, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + }, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start":484,"end":505,"loc":{"start":{"line":17,"column":2,"index":484},"end":{"line":17,"column":23,"index":505}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":488,"end":504,"loc":{"start":{"line":17,"column":6,"index":488},"end":{"line":17,"column":22,"index":504}}, + "id": { + "type": "Identifier", + "start":488,"end":504,"loc":{"start":{"line":17,"column":6,"index":488},"end":{"line":17,"column":22,"index":504},"identifierName":"foo"}, + "name": "foo", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start":491,"end":504,"loc":{"start":{"line":17,"column":9,"index":491},"end":{"line":17,"column":22,"index":504}}, + "typeAnnotation": { + "type": "TSTypeReference", + "start":493,"end":504,"loc":{"start":{"line":17,"column":11,"index":493},"end":{"line":17,"column":22,"index":504}}, + "typeName": { + "type": "Identifier", + "start":493,"end":504,"loc":{"start":{"line":17,"column":11,"index":493},"end":{"line":17,"column":22,"index":504},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + } + }, + "init": null + } + ], + "kind": "let" + } + ] + }, + "declare": true + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " packages\\babel-traverse\\test\\fixtures\\regression\\duplicate-variable-in-different-module-ts\\input.ts", + "start":0,"end":102,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":102,"index":102}} + }, + { + "type": "CommentLine", + "value": " can reference type outsider module", + "start":282,"end":319,"loc":{"start":{"line":9,"column":2,"index":282},"end":{"line":9,"column":39,"index":319}} + } + ] +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-nested-module/input.ts b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-nested-module/input.ts new file mode 100644 index 000000000000..076d9bcb7343 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-nested-module/input.ts @@ -0,0 +1,6 @@ +declare module 'test/sub1' { + import type { JSONSchema7 } from 'json-schema'; + module 'test/sub2' { + export { JSONSchema7 } + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-nested-module/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-nested-module/output.json new file mode 100644 index 000000000000..6ccb6c188565 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-in-nested-module/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":134,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":6,"column":1,"index":134}}, + "program": { + "type": "Program", + "start":0,"end":134,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":6,"column":1,"index":134}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSModuleDeclaration", + "start":0,"end":134,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":6,"column":1,"index":134}}, + "id": { + "type": "StringLiteral", + "start":15,"end":26,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "test/sub1", + "raw": "'test/sub1'" + }, + "value": "test/sub1" + }, + "body": { + "type": "TSModuleBlock", + "start":27,"end":134,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":6,"column":1,"index":134}}, + "body": [ + { + "type": "ImportDeclaration", + "start":31,"end":78,"loc":{"start":{"line":2,"column":2,"index":31},"end":{"line":2,"column":49,"index":78}}, + "importKind": "type", + "specifiers": [ + { + "type": "ImportSpecifier", + "start":45,"end":56,"loc":{"start":{"line":2,"column":16,"index":45},"end":{"line":2,"column":27,"index":56}}, + "imported": { + "type": "Identifier", + "start":45,"end":56,"loc":{"start":{"line":2,"column":16,"index":45},"end":{"line":2,"column":27,"index":56},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "importKind": "value", + "local": { + "type": "Identifier", + "start":45,"end":56,"loc":{"start":{"line":2,"column":16,"index":45},"end":{"line":2,"column":27,"index":56},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": { + "type": "StringLiteral", + "start":64,"end":77,"loc":{"start":{"line":2,"column":35,"index":64},"end":{"line":2,"column":48,"index":77}}, + "extra": { + "rawValue": "json-schema", + "raw": "'json-schema'" + }, + "value": "json-schema" + } + }, + { + "type": "TSModuleDeclaration", + "start":81,"end":132,"loc":{"start":{"line":3,"column":2,"index":81},"end":{"line":5,"column":3,"index":132}}, + "id": { + "type": "StringLiteral", + "start":88,"end":99,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":20,"index":99}}, + "extra": { + "rawValue": "test/sub2", + "raw": "'test/sub2'" + }, + "value": "test/sub2" + }, + "body": { + "type": "TSModuleBlock", + "start":100,"end":132,"loc":{"start":{"line":3,"column":21,"index":100},"end":{"line":5,"column":3,"index":132}}, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":106,"end":128,"loc":{"start":{"line":4,"column":4,"index":106},"end":{"line":4,"column":26,"index":128}}, + "exportKind": "value", + "specifiers": [ + { + "type": "ExportSpecifier", + "start":115,"end":126,"loc":{"start":{"line":4,"column":13,"index":115},"end":{"line":4,"column":24,"index":126}}, + "local": { + "type": "Identifier", + "start":115,"end":126,"loc":{"start":{"line":4,"column":13,"index":115},"end":{"line":4,"column":24,"index":126},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + }, + "exportKind": "value", + "exported": { + "type": "Identifier", + "start":115,"end":126,"loc":{"start":{"line":4,"column":13,"index":115},"end":{"line":4,"column":24,"index":126},"identifierName":"JSONSchema7"}, + "name": "JSONSchema7" + } + } + ], + "source": null, + "declaration": null + } + ] + } + } + ] + }, + "declare": true + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/helpers/run-fixture-tests.js b/packages/babel-parser/test/helpers/run-fixture-tests.js index 83f8f306e7c0..8e9fe38b1fdb 100644 --- a/packages/babel-parser/test/helpers/run-fixture-tests.js +++ b/packages/babel-parser/test/helpers/run-fixture-tests.js @@ -134,7 +134,11 @@ function runParseTest(parse, test, onlyCompareErrors) { existsSync(extendedLocation); if (CI || (!OVERWRITE && shouldThrow)) { - throw FixtureError.fromDifference(difference, actual); + const err = new Error(); + err.message = `Test Failed: ${testLocation}\nFixtureError.fromDifference: ${ + FixtureError.fromDifference(difference, actual).message + }`; + throw err; } // Store (or overwrite) the options file if there's anything to record, diff --git a/scripts/parser-tests/typescript/allowlist.txt b/scripts/parser-tests/typescript/allowlist.txt index 3849b2f7f42d..5912a0a4fd52 100644 --- a/scripts/parser-tests/typescript/allowlist.txt +++ b/scripts/parser-tests/typescript/allowlist.txt @@ -13,6 +13,21 @@ multipleExports.ts # 143 valid programs produced a parsing error +#invalid programs did not produce a parsing error + +bigintIndex.ts +classExpressionWithDecorator1.ts +collisionArgumentsArrowFunctions.ts # TypeScript doesn't allow a parameter to be named arguments even in non-strict mode, which we don't catch. +collisionArgumentsFunction.ts # TypeScript doesn't allow a parameter to be named arguments even in non-strict mode, which we don't catch. +collisionArgumentsFunctionExpressions.ts # TypeScript doesn't allow a parameter to be named arguments even in non-strict mode, which we don't catch. +dynamicImportTrailingComma.ts +es3-oldStyleOctalLiteralInEnums.ts # We don't support ES3-style octal literal errors. +exportDeclarationsInAmbientNamespaces2.ts +multipleExports.ts + + +#valid programs produced a parsing error + ArrowFunctionExpression1.ts MemberAccessorDeclaration15.ts ParameterList13.ts @@ -64,7 +79,6 @@ emptyTypeArgumentList.ts emptyTypeArgumentListWithNew.ts enumGenericTypeClash.ts es3-oldStyleOctalLiteralTypes.ts -es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts es6ImportDefaultBindingMergeErrors.ts es6ImportNameSpaceImportMergeErrors.ts es6ImportNamedImportMergeErrors.ts @@ -76,19 +90,17 @@ exportAssignmentWithExportModifier.ts exportClassWithoutName.ts exportDeclarationsInAmbientNamespaces.ts exportDefaultAsyncFunction2.ts -exportEqualsOfModule.ts exportInterfaceClassAndValue.ts exportSameNameFuncVar.ts exportSpecifierAndExportedMemberDeclaration.ts exportSpecifierAndLocalMemberDeclaration.ts -exportSpecifierForAGlobal.ts # We handle this fine, but it doesn't consider the different files together -exportSpecifierReferencingOuterDeclaration2.ts # We handle this fine, but it doesn't consider the different files together +exportSpecifierForAGlobal.ts +exportSpecifierReferencingOuterDeclaration2.ts expressionsForbiddenInParameterInitializers.ts extendsClauseAlreadySeen.ts extendsClauseAlreadySeen2.ts fileWithNextLine2.ts funClodule.ts -functionAndImportNameConflict.ts functionCall15.ts gettersAndSettersErrors.ts giant.ts @@ -108,7 +120,7 @@ indexTypeCheck.ts indexWithoutParamType.ts indexerSignatureWithRestParam.ts interfaceMayNotBeExtendedWitACall.ts -interfaceNaming1.ts # We correctly identify this error, but we can't bring it in without bringing a bunch of other tests too. +interfaceNaming1.ts interfaceWithImplements1.ts jsxAttributeMissingInitializer.tsx jsxAttributeWithoutExpressionReact.tsx @@ -139,9 +151,9 @@ parameterInitializerBeforeDestructuringEmit.ts parameterPropertyOutsideConstructor.ts parserConstructorDeclaration12.ts reExportGlobalDeclaration1.ts -reExportGlobalDeclaration2.ts # We handle this fine, but it doesn't consider the different files together -reExportGlobalDeclaration3.ts # We handle this fine, but it doesn't consider the different files together -reExportGlobalDeclaration4.ts # We handle this fine, but it doesn't consider the different files together +reExportGlobalDeclaration2.ts +reExportGlobalDeclaration3.ts +reExportGlobalDeclaration4.ts reExportUndefined1.ts readonlyInNonPropertyParameters.ts redeclareParameterInCatchBlock.ts @@ -154,5 +166,4 @@ staticAsIdentifier.ts staticModifierAlreadySeen.ts strictOptionalProperties1.ts superCallFromClassThatHasNoBaseType1.ts -symbolMergeValueAndImportedType.ts varArgConstructorMemberParameter.ts