From 9c6922793e1211f18972e87d068a1c4870363e24 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 13 Mar 2018 18:17:02 -0700 Subject: [PATCH 01/21] Type side of import types --- src/compiler/checker.ts | 58 +++++++- src/compiler/diagnosticMessages.json | 8 ++ src/compiler/emitter.ts | 13 ++ src/compiler/factory.ts | 14 ++ src/compiler/parser.ts | 18 +++ src/compiler/types.ts | 9 +- src/compiler/visitor.ts | 5 + .../baselines/reference/importTypeAmbient.js | 126 ++++++++++++++++++ .../reference/importTypeAmbient.symbols | 81 +++++++++++ .../reference/importTypeAmbient.types | 89 +++++++++++++ .../types/import/importTypeAmbient.ts | 42 ++++++ 11 files changed, 459 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/importTypeAmbient.js create mode 100644 tests/baselines/reference/importTypeAmbient.symbols create mode 100644 tests/baselines/reference/importTypeAmbient.types create mode 100644 tests/cases/conformance/types/import/importTypeAmbient.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5c85e5872e531..eeb1a32b64703 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2182,15 +2182,15 @@ namespace ts { // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol: Symbol, moduleReferenceExpression: Expression, dontResolveAlias: boolean): Symbol { + function resolveESModuleSymbol(moduleSymbol: Symbol, referencingLocation: Node, dontResolveAlias: boolean): Symbol { const symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) { - error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + error(referencingLocation, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } if (compilerOptions.esModuleInterop) { - const referenceParent = moduleReferenceExpression.parent; + const referenceParent = referencingLocation.parent; if ( (isImportDeclaration(referenceParent) && getNamespaceDeclarationNode(referenceParent)) || isImportCall(referenceParent) @@ -8411,6 +8411,56 @@ namespace ts { return links.resolvedType; } + function getTypeFromImportTypeNode(node: ImportTypeNode): Type { + const links = getNodeLinks(node); + if (!links.resolvedType) { + const argumentType = getTypeFromTypeNode(node.argument); + const targetMeaning = node.parent.kind === SyntaxKind.TypeQuery ? SymbolFlags.Value : SymbolFlags.Type; + // TODO: Future work: support unions/generics/whatever via a deferred import-type + if (!(argumentType.flags & TypeFlags.StringLiteral)) { + return links.resolvedType = neverType; + } + const moduleName = (argumentType as StringLiteralType).value; + const innerModuleSymbol = resolveExternalModule(node, moduleName, Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); + const moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); + if (node.qualifier) { + const nameStack: Identifier[] = []; + let currentNamespace = moduleSymbol; + let current = node.qualifier; + while (true) { + if (current.kind === SyntaxKind.Identifier) { + nameStack.push(current); + break; + } + else { + nameStack.push(current.right); + current = current.left; + } + } + while (current = nameStack.pop()) { + const meaning = nameStack.length ? SymbolFlags.Namespace : targetMeaning; + const next = getSymbol(getExportsOfSymbol(currentNamespace), current.escapedText, meaning); + if (!next) { + error(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current)); + return links.resolvedType = neverType; + } + currentNamespace = next; + } + links.resolvedType = targetMeaning === SymbolFlags.Value ? getTypeOfSymbol(currentNamespace) : getDeclaredTypeOfSymbol(currentNamespace); + } + else { + if (moduleSymbol.flags & targetMeaning) { + links.resolvedType = targetMeaning === SymbolFlags.Value ? getTypeOfSymbol(moduleSymbol) : getDeclaredTypeOfSymbol(moduleSymbol); + } + else { + error(node, targetMeaning & SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + links.resolvedType = neverType; + } + } + } + return links.resolvedType; + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node: TypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { @@ -8704,6 +8754,8 @@ namespace ts { return getTypeFromConditionalTypeNode(node); case SyntaxKind.InferType: return getTypeFromInferTypeNode(node); + case SyntaxKind.ImportTypeNode: + return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case SyntaxKind.Identifier: diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9f95a66711b75..f0b2cdf5b948b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -951,6 +951,14 @@ "category": "Error", "code": 1338 }, + "Module '{0}' does not refer to a value, but is used as a value here.": { + "category": "Error", + "code": 1339 + }, + "Module '{0}' does not refer to a type, but is used as a type here.": { + "category": "Error", + "code": 1340 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 583138e24cfb4..6a5c5802cfbd3 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -618,6 +618,8 @@ namespace ts { return emitMappedType(node); case SyntaxKind.LiteralType: return emitLiteralType(node); + case SyntaxKind.ImportTypeNode: + return emitImportTypeNode(node); case SyntaxKind.JSDocAllType: write("*"); return; @@ -1285,6 +1287,17 @@ namespace ts { emitExpression(node.literal); } + function emitImportTypeNode(node: ImportTypeNode) { + writeKeyword("import"); + writePunctuation("("); + emit(node.argument); + writePunctuation(")"); + if (node.qualifier) { + writePunctuation("."); + emit(node.qualifier); + } + } + // // Binding patterns // diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 507997c346de3..db50ba5077d4d 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -768,6 +768,20 @@ namespace ts { : node; } + export function createImportTypeNode(argument: TypeNode, qualifier?: EntityName) { + const node = createSynthesizedNode(SyntaxKind.ImportTypeNode); + node.argument = argument; + node.qualifier = qualifier; + return node; + } + + export function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName) { + return node.argument !== argument + && node.qualifier !== qualifier + ? updateNode(createImportTypeNode(argument, qualifier), node) + : node; + } + export function createParenthesizedType(type: TypeNode) { const node = createSynthesizedNode(SyntaxKind.ParenthesizedType); node.type = type; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 36b3db49fe0fb..7d72b6ea8db86 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -182,6 +182,9 @@ namespace ts { visitNode(cbNode, (node).falseType); case SyntaxKind.InferType: return visitNode(cbNode, (node).typeParameter); + case SyntaxKind.ImportTypeNode: + return visitNode(cbNode, (node).argument) || + visitNode(cbNode, (node).qualifier); case SyntaxKind.ParenthesizedType: case SyntaxKind.TypeOperator: return visitNode(cbNode, (node).type); @@ -2702,6 +2705,18 @@ namespace ts { return finishNode(node); } + function parseImportType(): ImportTypeNode { + const node = createNode(SyntaxKind.ImportTypeNode) as ImportTypeNode; + nextToken(); + parseExpected(SyntaxKind.OpenParenToken); + node.argument = parseType(); + parseExpected(SyntaxKind.CloseParenToken); + if (parseOptional(SyntaxKind.DotToken)) { + node.qualifier = parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected); + } + return finishNode(node); + } + function nextTokenIsNumericLiteral() { return nextToken() === SyntaxKind.NumericLiteral; } @@ -2754,6 +2769,8 @@ namespace ts { return parseTupleType(); case SyntaxKind.OpenParenToken: return parseParenthesizedType(); + case SyntaxKind.ImportKeyword: + return parseImportType(); default: return parseTypeReference(); } @@ -2789,6 +2806,7 @@ namespace ts { case SyntaxKind.ExclamationToken: case SyntaxKind.DotDotDotToken: case SyntaxKind.InferKeyword: + case SyntaxKind.ImportKeyword: return true; case SyntaxKind.MinusToken: return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 235f5cab674ad..8c23ff1061ca5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -283,6 +283,7 @@ namespace ts { IndexedAccessType, MappedType, LiteralType, + ImportTypeNode, // Binding patterns ObjectBindingPattern, ArrayBindingPattern, @@ -444,7 +445,7 @@ namespace ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypePredicate, - LastTypeNode = LiteralType, + LastTypeNode = ImportTypeNode, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = Unknown, @@ -1063,6 +1064,12 @@ namespace ts { | SyntaxKind.NeverKeyword; } + export interface ImportTypeNode extends TypeNode { + kind: SyntaxKind.ImportTypeNode; + argument: TypeNode; + qualifier?: EntityName; + } + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index dbaf28a23aad7..d4778f3d8ac19 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -398,6 +398,11 @@ namespace ts { return updateInferTypeNode(node, visitNode((node).typeParameter, visitor, isTypeParameterDeclaration)); + case SyntaxKind.ImportTypeNode: + return updateImportTypeNode(node, + visitNode((node).argument, visitor, isTypeNode), + visitNode((node).qualifier, visitor, isEntityName)); + case SyntaxKind.ParenthesizedType: return updateParenthesizedType(node, visitNode((node).type, visitor, isTypeNode)); diff --git a/tests/baselines/reference/importTypeAmbient.js b/tests/baselines/reference/importTypeAmbient.js new file mode 100644 index 0000000000000..290a47fd59e82 --- /dev/null +++ b/tests/baselines/reference/importTypeAmbient.js @@ -0,0 +1,126 @@ +//// [importTypeAmbient.ts] +declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; +} +const x: import("foo") = { x: 0, y: 0 }; + +declare module "foo2" { + namespace Bar { + interface I { + a: string; + b: number; + } + } + + namespace Baz { + interface J { + a: number; + b: string; + } + } + + class Bar { + item: Bar.I; + constructor(input: Baz.J); + } +} + +let y: import("foo2").Bar.I = { a: "", b: 0 }; + +// class Bar2 { +// item: {a: string, b: number, c: object}; +// constructor(input?: any) {} +// } +// +// let shim: typeof import("foo2") = { +// Bar: Bar2 +// }; + + +//// [importTypeAmbient.js] +var x = { x: 0, y: 0 }; +var y = { a: "", b: 0 }; +// class Bar2 { +// item: {a: string, b: number, c: object}; +// constructor(input?: any) {} +// } +// +// let shim: typeof import("foo2") = { +// Bar: Bar2 +// }; + + +//// [importTypeAmbient.d.ts] +declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; +} +declare const x: ; +declare module "foo2" { + namespace Bar { + interface I { + a: string; + b: number; + } + } + namespace Baz { + interface J { + a: number; + b: string; + } + } + class Bar { + item: Bar.I; + constructor(input: Baz.J); + } +} +declare let y: ; + + +//// [DtsFileErrors] + + +tests/cases/conformance/types/import/importTypeAmbient.d.ts(8,18): error TS1110: Type expected. +tests/cases/conformance/types/import/importTypeAmbient.d.ts(27,16): error TS1110: Type expected. + + +==== tests/cases/conformance/types/import/importTypeAmbient.d.ts (2 errors) ==== + declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; + } + declare const x: ; + ~ +!!! error TS1110: Type expected. + declare module "foo2" { + namespace Bar { + interface I { + a: string; + b: number; + } + } + namespace Baz { + interface J { + a: number; + b: string; + } + } + class Bar { + item: Bar.I; + constructor(input: Baz.J); + } + } + declare let y: ; + ~ +!!! error TS1110: Type expected. + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeAmbient.symbols b/tests/baselines/reference/importTypeAmbient.symbols new file mode 100644 index 0000000000000..5721e28dcbcb4 --- /dev/null +++ b/tests/baselines/reference/importTypeAmbient.symbols @@ -0,0 +1,81 @@ +=== tests/cases/conformance/types/import/importTypeAmbient.ts === +declare module "foo" { +>"foo" : Symbol("foo", Decl(importTypeAmbient.ts, 0, 0)) + + interface Point { +>Point : Symbol(Point, Decl(importTypeAmbient.ts, 0, 22)) + + x: number; +>x : Symbol(Point.x, Decl(importTypeAmbient.ts, 1, 21)) + + y: number; +>y : Symbol(Point.y, Decl(importTypeAmbient.ts, 2, 18)) + } + export = Point; +>Point : Symbol(Point, Decl(importTypeAmbient.ts, 0, 22)) +} +const x: import("foo") = { x: 0, y: 0 }; +>x : Symbol(x, Decl(importTypeAmbient.ts, 7, 5)) +>x : Symbol(x, Decl(importTypeAmbient.ts, 7, 26)) +>y : Symbol(y, Decl(importTypeAmbient.ts, 7, 32)) + +declare module "foo2" { +>"foo2" : Symbol("foo2", Decl(importTypeAmbient.ts, 7, 40)) + + namespace Bar { +>Bar : Symbol(Bar, Decl(importTypeAmbient.ts, 9, 23), Decl(importTypeAmbient.ts, 22, 5)) + + interface I { +>I : Symbol(I, Decl(importTypeAmbient.ts, 10, 19)) + + a: string; +>a : Symbol(I.a, Decl(importTypeAmbient.ts, 11, 21)) + + b: number; +>b : Symbol(I.b, Decl(importTypeAmbient.ts, 12, 22)) + } + } + + namespace Baz { +>Baz : Symbol(Baz, Decl(importTypeAmbient.ts, 15, 5)) + + interface J { +>J : Symbol(J, Decl(importTypeAmbient.ts, 17, 19)) + + a: number; +>a : Symbol(J.a, Decl(importTypeAmbient.ts, 18, 21)) + + b: string; +>b : Symbol(J.b, Decl(importTypeAmbient.ts, 19, 22)) + } + } + + class Bar { +>Bar : Symbol(Bar, Decl(importTypeAmbient.ts, 9, 23), Decl(importTypeAmbient.ts, 22, 5)) + + item: Bar.I; +>item : Symbol(Bar.item, Decl(importTypeAmbient.ts, 24, 15)) +>Bar : Symbol(Bar, Decl(importTypeAmbient.ts, 9, 23), Decl(importTypeAmbient.ts, 22, 5)) +>I : Symbol(Bar.I, Decl(importTypeAmbient.ts, 10, 19)) + + constructor(input: Baz.J); +>input : Symbol(input, Decl(importTypeAmbient.ts, 26, 20)) +>Baz : Symbol(Baz, Decl(importTypeAmbient.ts, 15, 5)) +>J : Symbol(Baz.J, Decl(importTypeAmbient.ts, 17, 19)) + } +} + +let y: import("foo2").Bar.I = { a: "", b: 0 }; +>y : Symbol(y, Decl(importTypeAmbient.ts, 30, 3)) +>a : Symbol(a, Decl(importTypeAmbient.ts, 30, 31)) +>b : Symbol(b, Decl(importTypeAmbient.ts, 30, 38)) + +// class Bar2 { +// item: {a: string, b: number, c: object}; +// constructor(input?: any) {} +// } +// +// let shim: typeof import("foo2") = { +// Bar: Bar2 +// }; + diff --git a/tests/baselines/reference/importTypeAmbient.types b/tests/baselines/reference/importTypeAmbient.types new file mode 100644 index 0000000000000..df4d5b0be32af --- /dev/null +++ b/tests/baselines/reference/importTypeAmbient.types @@ -0,0 +1,89 @@ +=== tests/cases/conformance/types/import/importTypeAmbient.ts === +declare module "foo" { +>"foo" : typeof "foo" + + interface Point { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number + } + export = Point; +>Point : Point +} +const x: import("foo") = { x: 0, y: 0 }; +>x : Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +declare module "foo2" { +>"foo2" : typeof "foo2" + + namespace Bar { +>Bar : typeof Bar + + interface I { +>I : I + + a: string; +>a : string + + b: number; +>b : number + } + } + + namespace Baz { +>Baz : any + + interface J { +>J : J + + a: number; +>a : number + + b: string; +>b : string + } + } + + class Bar { +>Bar : Bar + + item: Bar.I; +>item : Bar.I +>Bar : any +>I : Bar.I + + constructor(input: Baz.J); +>input : Baz.J +>Baz : any +>J : Baz.J + } +} + +let y: import("foo2").Bar.I = { a: "", b: 0 }; +>y : Bar.I +>Bar : any +>I : No type information available! +>{ a: "", b: 0 } : { a: string; b: number; } +>a : string +>"" : "" +>b : number +>0 : 0 + +// class Bar2 { +// item: {a: string, b: number, c: object}; +// constructor(input?: any) {} +// } +// +// let shim: typeof import("foo2") = { +// Bar: Bar2 +// }; + diff --git a/tests/cases/conformance/types/import/importTypeAmbient.ts b/tests/cases/conformance/types/import/importTypeAmbient.ts new file mode 100644 index 0000000000000..b58cf293b782c --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeAmbient.ts @@ -0,0 +1,42 @@ +// @declaration: true +// @lib: es6 +declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; +} +const x: import("foo") = { x: 0, y: 0 }; + +declare module "foo2" { + namespace Bar { + interface I { + a: string; + b: number; + } + } + + namespace Baz { + interface J { + a: number; + b: string; + } + } + + class Bar { + item: Bar.I; + constructor(input: Baz.J); + } +} + +let y: import("foo2").Bar.I = { a: "", b: 0 }; + +// class Bar2 { +// item: {a: string, b: number, c: object}; +// constructor(input?: any) {} +// } +// +// let shim: typeof import("foo2") = { +// Bar: Bar2 +// }; From e9d01ceeda8e6bcec4b3ca09ac825c094edccf71 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 14 Mar 2018 14:26:27 -0700 Subject: [PATCH 02/21] Value side of import types --- src/compiler/checker.ts | 2 +- src/compiler/emitter.ts | 4 ++ src/compiler/parser.ts | 12 +++- src/compiler/types.ts | 1 + .../baselines/reference/importTypeAmbient.js | 55 +++++++++++++------ .../reference/importTypeAmbient.symbols | 29 +++++++--- .../reference/importTypeAmbient.types | 30 +++++++--- .../types/import/importTypeAmbient.ts | 16 +++--- 8 files changed, 105 insertions(+), 44 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eeb1a32b64703..2ab7fa6f08625 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8415,7 +8415,7 @@ namespace ts { const links = getNodeLinks(node); if (!links.resolvedType) { const argumentType = getTypeFromTypeNode(node.argument); - const targetMeaning = node.parent.kind === SyntaxKind.TypeQuery ? SymbolFlags.Value : SymbolFlags.Type; + const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; // TODO: Future work: support unions/generics/whatever via a deferred import-type if (!(argumentType.flags & TypeFlags.StringLiteral)) { return links.resolvedType = neverType; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 6a5c5802cfbd3..64f02f478c29a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1288,6 +1288,10 @@ namespace ts { } function emitImportTypeNode(node: ImportTypeNode) { + if (node.isTypeOf) { + writeKeyword("typeof"); + writeSpace(); + } writeKeyword("import"); writePunctuation("("); emit(node.argument); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7d72b6ea8db86..4ac6dfac22e8e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2705,9 +2705,17 @@ namespace ts { return finishNode(node); } + function isStartOfTypeOfImportType() { + nextToken(); + return token() === SyntaxKind.ImportKeyword; + } + function parseImportType(): ImportTypeNode { const node = createNode(SyntaxKind.ImportTypeNode) as ImportTypeNode; - nextToken(); + if (parseOptional(SyntaxKind.TypeOfKeyword)) { + node.isTypeOf = true; + } + parseExpected(SyntaxKind.ImportKeyword); parseExpected(SyntaxKind.OpenParenToken); node.argument = parseType(); parseExpected(SyntaxKind.CloseParenToken); @@ -2762,7 +2770,7 @@ namespace ts { } } case SyntaxKind.TypeOfKeyword: - return parseTypeQuery(); + return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case SyntaxKind.OpenBraceToken: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); case SyntaxKind.OpenBracketToken: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8c23ff1061ca5..6b93913e98fa5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1066,6 +1066,7 @@ namespace ts { export interface ImportTypeNode extends TypeNode { kind: SyntaxKind.ImportTypeNode; + isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } diff --git a/tests/baselines/reference/importTypeAmbient.js b/tests/baselines/reference/importTypeAmbient.js index 290a47fd59e82..3bec3b2ff7e9d 100644 --- a/tests/baselines/reference/importTypeAmbient.js +++ b/tests/baselines/reference/importTypeAmbient.js @@ -31,27 +31,27 @@ declare module "foo2" { let y: import("foo2").Bar.I = { a: "", b: 0 }; -// class Bar2 { -// item: {a: string, b: number, c: object}; -// constructor(input?: any) {} -// } -// -// let shim: typeof import("foo2") = { -// Bar: Bar2 -// }; +class Bar2 { + item: {a: string, b: number, c: object}; + constructor(input?: any) {} +} + +let shim: typeof import("foo2") = { + Bar: Bar2 +}; //// [importTypeAmbient.js] var x = { x: 0, y: 0 }; var y = { a: "", b: 0 }; -// class Bar2 { -// item: {a: string, b: number, c: object}; -// constructor(input?: any) {} -// } -// -// let shim: typeof import("foo2") = { -// Bar: Bar2 -// }; +var Bar2 = /** @class */ (function () { + function Bar2(input) { + } + return Bar2; +}()); +var shim = { + Bar: Bar2 +}; //// [importTypeAmbient.d.ts] @@ -82,6 +82,15 @@ declare module "foo2" { } } declare let y: ; +declare class Bar2 { + item: { + a: string; + b: number; + c: object; + }; + constructor(input?: any); +} +declare let shim: ; //// [DtsFileErrors] @@ -89,9 +98,10 @@ declare let y: ; tests/cases/conformance/types/import/importTypeAmbient.d.ts(8,18): error TS1110: Type expected. tests/cases/conformance/types/import/importTypeAmbient.d.ts(27,16): error TS1110: Type expected. +tests/cases/conformance/types/import/importTypeAmbient.d.ts(36,19): error TS1110: Type expected. -==== tests/cases/conformance/types/import/importTypeAmbient.d.ts (2 errors) ==== +==== tests/cases/conformance/types/import/importTypeAmbient.d.ts (3 errors) ==== declare module "foo" { interface Point { x: number; @@ -123,4 +133,15 @@ tests/cases/conformance/types/import/importTypeAmbient.d.ts(27,16): error TS1110 declare let y: ; ~ !!! error TS1110: Type expected. + declare class Bar2 { + item: { + a: string; + b: number; + c: object; + }; + constructor(input?: any); + } + declare let shim: ; + ~ +!!! error TS1110: Type expected. \ No newline at end of file diff --git a/tests/baselines/reference/importTypeAmbient.symbols b/tests/baselines/reference/importTypeAmbient.symbols index 5721e28dcbcb4..d20bf68a29577 100644 --- a/tests/baselines/reference/importTypeAmbient.symbols +++ b/tests/baselines/reference/importTypeAmbient.symbols @@ -70,12 +70,25 @@ let y: import("foo2").Bar.I = { a: "", b: 0 }; >a : Symbol(a, Decl(importTypeAmbient.ts, 30, 31)) >b : Symbol(b, Decl(importTypeAmbient.ts, 30, 38)) -// class Bar2 { -// item: {a: string, b: number, c: object}; -// constructor(input?: any) {} -// } -// -// let shim: typeof import("foo2") = { -// Bar: Bar2 -// }; +class Bar2 { +>Bar2 : Symbol(Bar2, Decl(importTypeAmbient.ts, 30, 46)) + + item: {a: string, b: number, c: object}; +>item : Symbol(Bar2.item, Decl(importTypeAmbient.ts, 32, 12)) +>a : Symbol(a, Decl(importTypeAmbient.ts, 33, 11)) +>b : Symbol(b, Decl(importTypeAmbient.ts, 33, 21)) +>c : Symbol(c, Decl(importTypeAmbient.ts, 33, 32)) + + constructor(input?: any) {} +>input : Symbol(input, Decl(importTypeAmbient.ts, 34, 16)) +} + +let shim: typeof import("foo2") = { +>shim : Symbol(shim, Decl(importTypeAmbient.ts, 37, 3)) + + Bar: Bar2 +>Bar : Symbol(Bar, Decl(importTypeAmbient.ts, 37, 35)) +>Bar2 : Symbol(Bar2, Decl(importTypeAmbient.ts, 30, 46)) + +}; diff --git a/tests/baselines/reference/importTypeAmbient.types b/tests/baselines/reference/importTypeAmbient.types index df4d5b0be32af..d7b7399d28d7b 100644 --- a/tests/baselines/reference/importTypeAmbient.types +++ b/tests/baselines/reference/importTypeAmbient.types @@ -78,12 +78,26 @@ let y: import("foo2").Bar.I = { a: "", b: 0 }; >b : number >0 : 0 -// class Bar2 { -// item: {a: string, b: number, c: object}; -// constructor(input?: any) {} -// } -// -// let shim: typeof import("foo2") = { -// Bar: Bar2 -// }; +class Bar2 { +>Bar2 : Bar2 + + item: {a: string, b: number, c: object}; +>item : { a: string; b: number; c: object; } +>a : string +>b : number +>c : object + + constructor(input?: any) {} +>input : any +} + +let shim: typeof import("foo2") = { +>shim : typeof "foo2" +>{ Bar: Bar2} : { Bar: typeof Bar2; } + + Bar: Bar2 +>Bar : typeof Bar2 +>Bar2 : typeof Bar2 + +}; diff --git a/tests/cases/conformance/types/import/importTypeAmbient.ts b/tests/cases/conformance/types/import/importTypeAmbient.ts index b58cf293b782c..b1ba4637778eb 100644 --- a/tests/cases/conformance/types/import/importTypeAmbient.ts +++ b/tests/cases/conformance/types/import/importTypeAmbient.ts @@ -32,11 +32,11 @@ declare module "foo2" { let y: import("foo2").Bar.I = { a: "", b: 0 }; -// class Bar2 { -// item: {a: string, b: number, c: object}; -// constructor(input?: any) {} -// } -// -// let shim: typeof import("foo2") = { -// Bar: Bar2 -// }; +class Bar2 { + item: {a: string, b: number, c: object}; + constructor(input?: any) {} +} + +let shim: typeof import("foo2") = { + Bar: Bar2 +}; From 31afd58ccf8f75e3307e9a9c75d9ce86158f6fdb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 14 Mar 2018 14:34:21 -0700 Subject: [PATCH 03/21] Accept library changes --- .../reference/api/tsserverlibrary.d.ts | 263 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 263 +++++++++--------- 2 files changed, 272 insertions(+), 254 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 7034909f6dbaa..1ed148aa4de26 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -240,128 +240,129 @@ declare namespace ts { IndexedAccessType = 175, MappedType = 176, LiteralType = 177, - ObjectBindingPattern = 178, - ArrayBindingPattern = 179, - BindingElement = 180, - ArrayLiteralExpression = 181, - ObjectLiteralExpression = 182, - PropertyAccessExpression = 183, - ElementAccessExpression = 184, - CallExpression = 185, - NewExpression = 186, - TaggedTemplateExpression = 187, - TypeAssertionExpression = 188, - ParenthesizedExpression = 189, - FunctionExpression = 190, - ArrowFunction = 191, - DeleteExpression = 192, - TypeOfExpression = 193, - VoidExpression = 194, - AwaitExpression = 195, - PrefixUnaryExpression = 196, - PostfixUnaryExpression = 197, - BinaryExpression = 198, - ConditionalExpression = 199, - TemplateExpression = 200, - YieldExpression = 201, - SpreadElement = 202, - ClassExpression = 203, - OmittedExpression = 204, - ExpressionWithTypeArguments = 205, - AsExpression = 206, - NonNullExpression = 207, - MetaProperty = 208, - TemplateSpan = 209, - SemicolonClassElement = 210, - Block = 211, - VariableStatement = 212, - EmptyStatement = 213, - ExpressionStatement = 214, - IfStatement = 215, - DoStatement = 216, - WhileStatement = 217, - ForStatement = 218, - ForInStatement = 219, - ForOfStatement = 220, - ContinueStatement = 221, - BreakStatement = 222, - ReturnStatement = 223, - WithStatement = 224, - SwitchStatement = 225, - LabeledStatement = 226, - ThrowStatement = 227, - TryStatement = 228, - DebuggerStatement = 229, - VariableDeclaration = 230, - VariableDeclarationList = 231, - FunctionDeclaration = 232, - ClassDeclaration = 233, - InterfaceDeclaration = 234, - TypeAliasDeclaration = 235, - EnumDeclaration = 236, - ModuleDeclaration = 237, - ModuleBlock = 238, - CaseBlock = 239, - NamespaceExportDeclaration = 240, - ImportEqualsDeclaration = 241, - ImportDeclaration = 242, - ImportClause = 243, - NamespaceImport = 244, - NamedImports = 245, - ImportSpecifier = 246, - ExportAssignment = 247, - ExportDeclaration = 248, - NamedExports = 249, - ExportSpecifier = 250, - MissingDeclaration = 251, - ExternalModuleReference = 252, - JsxElement = 253, - JsxSelfClosingElement = 254, - JsxOpeningElement = 255, - JsxClosingElement = 256, - JsxFragment = 257, - JsxOpeningFragment = 258, - JsxClosingFragment = 259, - JsxAttribute = 260, - JsxAttributes = 261, - JsxSpreadAttribute = 262, - JsxExpression = 263, - CaseClause = 264, - DefaultClause = 265, - HeritageClause = 266, - CatchClause = 267, - PropertyAssignment = 268, - ShorthandPropertyAssignment = 269, - SpreadAssignment = 270, - EnumMember = 271, - SourceFile = 272, - Bundle = 273, - JSDocTypeExpression = 274, - JSDocAllType = 275, - JSDocUnknownType = 276, - JSDocNullableType = 277, - JSDocNonNullableType = 278, - JSDocOptionalType = 279, - JSDocFunctionType = 280, - JSDocVariadicType = 281, - JSDocComment = 282, - JSDocTypeLiteral = 283, - JSDocTag = 284, - JSDocAugmentsTag = 285, - JSDocClassTag = 286, - JSDocParameterTag = 287, - JSDocReturnTag = 288, - JSDocTypeTag = 289, - JSDocTemplateTag = 290, - JSDocTypedefTag = 291, - JSDocPropertyTag = 292, - SyntaxList = 293, - NotEmittedStatement = 294, - PartiallyEmittedExpression = 295, - CommaListExpression = 296, - MergeDeclarationMarker = 297, - EndOfDeclarationMarker = 298, - Count = 299, + ImportTypeNode = 178, + ObjectBindingPattern = 179, + ArrayBindingPattern = 180, + BindingElement = 181, + ArrayLiteralExpression = 182, + ObjectLiteralExpression = 183, + PropertyAccessExpression = 184, + ElementAccessExpression = 185, + CallExpression = 186, + NewExpression = 187, + TaggedTemplateExpression = 188, + TypeAssertionExpression = 189, + ParenthesizedExpression = 190, + FunctionExpression = 191, + ArrowFunction = 192, + DeleteExpression = 193, + TypeOfExpression = 194, + VoidExpression = 195, + AwaitExpression = 196, + PrefixUnaryExpression = 197, + PostfixUnaryExpression = 198, + BinaryExpression = 199, + ConditionalExpression = 200, + TemplateExpression = 201, + YieldExpression = 202, + SpreadElement = 203, + ClassExpression = 204, + OmittedExpression = 205, + ExpressionWithTypeArguments = 206, + AsExpression = 207, + NonNullExpression = 208, + MetaProperty = 209, + TemplateSpan = 210, + SemicolonClassElement = 211, + Block = 212, + VariableStatement = 213, + EmptyStatement = 214, + ExpressionStatement = 215, + IfStatement = 216, + DoStatement = 217, + WhileStatement = 218, + ForStatement = 219, + ForInStatement = 220, + ForOfStatement = 221, + ContinueStatement = 222, + BreakStatement = 223, + ReturnStatement = 224, + WithStatement = 225, + SwitchStatement = 226, + LabeledStatement = 227, + ThrowStatement = 228, + TryStatement = 229, + DebuggerStatement = 230, + VariableDeclaration = 231, + VariableDeclarationList = 232, + FunctionDeclaration = 233, + ClassDeclaration = 234, + InterfaceDeclaration = 235, + TypeAliasDeclaration = 236, + EnumDeclaration = 237, + ModuleDeclaration = 238, + ModuleBlock = 239, + CaseBlock = 240, + NamespaceExportDeclaration = 241, + ImportEqualsDeclaration = 242, + ImportDeclaration = 243, + ImportClause = 244, + NamespaceImport = 245, + NamedImports = 246, + ImportSpecifier = 247, + ExportAssignment = 248, + ExportDeclaration = 249, + NamedExports = 250, + ExportSpecifier = 251, + MissingDeclaration = 252, + ExternalModuleReference = 253, + JsxElement = 254, + JsxSelfClosingElement = 255, + JsxOpeningElement = 256, + JsxClosingElement = 257, + JsxFragment = 258, + JsxOpeningFragment = 259, + JsxClosingFragment = 260, + JsxAttribute = 261, + JsxAttributes = 262, + JsxSpreadAttribute = 263, + JsxExpression = 264, + CaseClause = 265, + DefaultClause = 266, + HeritageClause = 267, + CatchClause = 268, + PropertyAssignment = 269, + ShorthandPropertyAssignment = 270, + SpreadAssignment = 271, + EnumMember = 272, + SourceFile = 273, + Bundle = 274, + JSDocTypeExpression = 275, + JSDocAllType = 276, + JSDocUnknownType = 277, + JSDocNullableType = 278, + JSDocNonNullableType = 279, + JSDocOptionalType = 280, + JSDocFunctionType = 281, + JSDocVariadicType = 282, + JSDocComment = 283, + JSDocTypeLiteral = 284, + JSDocTag = 285, + JSDocAugmentsTag = 286, + JSDocClassTag = 287, + JSDocParameterTag = 288, + JSDocReturnTag = 289, + JSDocTypeTag = 290, + JSDocTemplateTag = 291, + JSDocTypedefTag = 292, + JSDocPropertyTag = 293, + SyntaxList = 294, + NotEmittedStatement = 295, + PartiallyEmittedExpression = 296, + CommaListExpression = 297, + MergeDeclarationMarker = 298, + EndOfDeclarationMarker = 299, + Count = 300, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -373,7 +374,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 160, - LastTypeNode = 177, + LastTypeNode = 178, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -387,10 +388,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 145, - FirstJSDocNode = 274, - LastJSDocNode = 292, - FirstJSDocTagNode = 284, - LastJSDocTagNode = 292, + FirstJSDocNode = 275, + LastJSDocNode = 293, + FirstJSDocTagNode = 285, + LastJSDocTagNode = 293, } enum NodeFlags { None = 0, @@ -696,6 +697,12 @@ declare namespace ts { interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } + interface ImportTypeNode extends TypeNode { + kind: SyntaxKind.ImportTypeNode; + isTypeOf?: boolean; + argument: TypeNode; + qualifier?: EntityName; + } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } @@ -3501,6 +3508,8 @@ declare namespace ts { function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 1908eb1114a27..968fd74ae2b1e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -240,128 +240,129 @@ declare namespace ts { IndexedAccessType = 175, MappedType = 176, LiteralType = 177, - ObjectBindingPattern = 178, - ArrayBindingPattern = 179, - BindingElement = 180, - ArrayLiteralExpression = 181, - ObjectLiteralExpression = 182, - PropertyAccessExpression = 183, - ElementAccessExpression = 184, - CallExpression = 185, - NewExpression = 186, - TaggedTemplateExpression = 187, - TypeAssertionExpression = 188, - ParenthesizedExpression = 189, - FunctionExpression = 190, - ArrowFunction = 191, - DeleteExpression = 192, - TypeOfExpression = 193, - VoidExpression = 194, - AwaitExpression = 195, - PrefixUnaryExpression = 196, - PostfixUnaryExpression = 197, - BinaryExpression = 198, - ConditionalExpression = 199, - TemplateExpression = 200, - YieldExpression = 201, - SpreadElement = 202, - ClassExpression = 203, - OmittedExpression = 204, - ExpressionWithTypeArguments = 205, - AsExpression = 206, - NonNullExpression = 207, - MetaProperty = 208, - TemplateSpan = 209, - SemicolonClassElement = 210, - Block = 211, - VariableStatement = 212, - EmptyStatement = 213, - ExpressionStatement = 214, - IfStatement = 215, - DoStatement = 216, - WhileStatement = 217, - ForStatement = 218, - ForInStatement = 219, - ForOfStatement = 220, - ContinueStatement = 221, - BreakStatement = 222, - ReturnStatement = 223, - WithStatement = 224, - SwitchStatement = 225, - LabeledStatement = 226, - ThrowStatement = 227, - TryStatement = 228, - DebuggerStatement = 229, - VariableDeclaration = 230, - VariableDeclarationList = 231, - FunctionDeclaration = 232, - ClassDeclaration = 233, - InterfaceDeclaration = 234, - TypeAliasDeclaration = 235, - EnumDeclaration = 236, - ModuleDeclaration = 237, - ModuleBlock = 238, - CaseBlock = 239, - NamespaceExportDeclaration = 240, - ImportEqualsDeclaration = 241, - ImportDeclaration = 242, - ImportClause = 243, - NamespaceImport = 244, - NamedImports = 245, - ImportSpecifier = 246, - ExportAssignment = 247, - ExportDeclaration = 248, - NamedExports = 249, - ExportSpecifier = 250, - MissingDeclaration = 251, - ExternalModuleReference = 252, - JsxElement = 253, - JsxSelfClosingElement = 254, - JsxOpeningElement = 255, - JsxClosingElement = 256, - JsxFragment = 257, - JsxOpeningFragment = 258, - JsxClosingFragment = 259, - JsxAttribute = 260, - JsxAttributes = 261, - JsxSpreadAttribute = 262, - JsxExpression = 263, - CaseClause = 264, - DefaultClause = 265, - HeritageClause = 266, - CatchClause = 267, - PropertyAssignment = 268, - ShorthandPropertyAssignment = 269, - SpreadAssignment = 270, - EnumMember = 271, - SourceFile = 272, - Bundle = 273, - JSDocTypeExpression = 274, - JSDocAllType = 275, - JSDocUnknownType = 276, - JSDocNullableType = 277, - JSDocNonNullableType = 278, - JSDocOptionalType = 279, - JSDocFunctionType = 280, - JSDocVariadicType = 281, - JSDocComment = 282, - JSDocTypeLiteral = 283, - JSDocTag = 284, - JSDocAugmentsTag = 285, - JSDocClassTag = 286, - JSDocParameterTag = 287, - JSDocReturnTag = 288, - JSDocTypeTag = 289, - JSDocTemplateTag = 290, - JSDocTypedefTag = 291, - JSDocPropertyTag = 292, - SyntaxList = 293, - NotEmittedStatement = 294, - PartiallyEmittedExpression = 295, - CommaListExpression = 296, - MergeDeclarationMarker = 297, - EndOfDeclarationMarker = 298, - Count = 299, + ImportTypeNode = 178, + ObjectBindingPattern = 179, + ArrayBindingPattern = 180, + BindingElement = 181, + ArrayLiteralExpression = 182, + ObjectLiteralExpression = 183, + PropertyAccessExpression = 184, + ElementAccessExpression = 185, + CallExpression = 186, + NewExpression = 187, + TaggedTemplateExpression = 188, + TypeAssertionExpression = 189, + ParenthesizedExpression = 190, + FunctionExpression = 191, + ArrowFunction = 192, + DeleteExpression = 193, + TypeOfExpression = 194, + VoidExpression = 195, + AwaitExpression = 196, + PrefixUnaryExpression = 197, + PostfixUnaryExpression = 198, + BinaryExpression = 199, + ConditionalExpression = 200, + TemplateExpression = 201, + YieldExpression = 202, + SpreadElement = 203, + ClassExpression = 204, + OmittedExpression = 205, + ExpressionWithTypeArguments = 206, + AsExpression = 207, + NonNullExpression = 208, + MetaProperty = 209, + TemplateSpan = 210, + SemicolonClassElement = 211, + Block = 212, + VariableStatement = 213, + EmptyStatement = 214, + ExpressionStatement = 215, + IfStatement = 216, + DoStatement = 217, + WhileStatement = 218, + ForStatement = 219, + ForInStatement = 220, + ForOfStatement = 221, + ContinueStatement = 222, + BreakStatement = 223, + ReturnStatement = 224, + WithStatement = 225, + SwitchStatement = 226, + LabeledStatement = 227, + ThrowStatement = 228, + TryStatement = 229, + DebuggerStatement = 230, + VariableDeclaration = 231, + VariableDeclarationList = 232, + FunctionDeclaration = 233, + ClassDeclaration = 234, + InterfaceDeclaration = 235, + TypeAliasDeclaration = 236, + EnumDeclaration = 237, + ModuleDeclaration = 238, + ModuleBlock = 239, + CaseBlock = 240, + NamespaceExportDeclaration = 241, + ImportEqualsDeclaration = 242, + ImportDeclaration = 243, + ImportClause = 244, + NamespaceImport = 245, + NamedImports = 246, + ImportSpecifier = 247, + ExportAssignment = 248, + ExportDeclaration = 249, + NamedExports = 250, + ExportSpecifier = 251, + MissingDeclaration = 252, + ExternalModuleReference = 253, + JsxElement = 254, + JsxSelfClosingElement = 255, + JsxOpeningElement = 256, + JsxClosingElement = 257, + JsxFragment = 258, + JsxOpeningFragment = 259, + JsxClosingFragment = 260, + JsxAttribute = 261, + JsxAttributes = 262, + JsxSpreadAttribute = 263, + JsxExpression = 264, + CaseClause = 265, + DefaultClause = 266, + HeritageClause = 267, + CatchClause = 268, + PropertyAssignment = 269, + ShorthandPropertyAssignment = 270, + SpreadAssignment = 271, + EnumMember = 272, + SourceFile = 273, + Bundle = 274, + JSDocTypeExpression = 275, + JSDocAllType = 276, + JSDocUnknownType = 277, + JSDocNullableType = 278, + JSDocNonNullableType = 279, + JSDocOptionalType = 280, + JSDocFunctionType = 281, + JSDocVariadicType = 282, + JSDocComment = 283, + JSDocTypeLiteral = 284, + JSDocTag = 285, + JSDocAugmentsTag = 286, + JSDocClassTag = 287, + JSDocParameterTag = 288, + JSDocReturnTag = 289, + JSDocTypeTag = 290, + JSDocTemplateTag = 291, + JSDocTypedefTag = 292, + JSDocPropertyTag = 293, + SyntaxList = 294, + NotEmittedStatement = 295, + PartiallyEmittedExpression = 296, + CommaListExpression = 297, + MergeDeclarationMarker = 298, + EndOfDeclarationMarker = 299, + Count = 300, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -373,7 +374,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 160, - LastTypeNode = 177, + LastTypeNode = 178, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -387,10 +388,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 145, - FirstJSDocNode = 274, - LastJSDocNode = 292, - FirstJSDocTagNode = 284, - LastJSDocTagNode = 292, + FirstJSDocNode = 275, + LastJSDocNode = 293, + FirstJSDocTagNode = 285, + LastJSDocTagNode = 293, } enum NodeFlags { None = 0, @@ -696,6 +697,12 @@ declare namespace ts { interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } + interface ImportTypeNode extends TypeNode { + kind: SyntaxKind.ImportTypeNode; + isTypeOf?: boolean; + argument: TypeNode; + qualifier?: EntityName; + } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } @@ -3448,6 +3455,8 @@ declare namespace ts { function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; From 6ceaee0ca14af08c836fcd240818281c522bf0d4 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 14 Mar 2018 16:50:44 -0700 Subject: [PATCH 04/21] Refined implementation, more tests --- src/compiler/checker.ts | 28 ++++- src/compiler/declarationEmitter.ts | 15 +++ src/compiler/diagnosticMessages.json | 4 + src/compiler/parser.ts | 1 + src/compiler/program.ts | 3 + src/compiler/types.ts | 3 + src/compiler/utilities.ts | 6 + .../baselines/reference/importTypeAmbient.js | 60 +--------- .../importTypeAmbientMissing.errors.txt | 16 +++ .../reference/importTypeAmbientMissing.js | 25 ++++ .../importTypeAmbientMissing.symbols | 22 ++++ .../reference/importTypeAmbientMissing.types | 25 ++++ .../reference/importTypeGeneric.errors.txt | 25 ++++ .../baselines/reference/importTypeGeneric.js | 32 +++++ .../reference/importTypeGeneric.symbols | 37 ++++++ .../reference/importTypeGeneric.types | 41 +++++++ tests/baselines/reference/importTypeLocal.js | 108 +++++++++++++++++ .../reference/importTypeLocal.symbols | 91 ++++++++++++++ .../baselines/reference/importTypeLocal.types | 100 ++++++++++++++++ .../importTypeLocalMissing.errors.txt | 56 +++++++++ .../reference/importTypeLocalMissing.js | 111 ++++++++++++++++++ .../reference/importTypeLocalMissing.symbols | 96 +++++++++++++++ .../reference/importTypeLocalMissing.types | 110 +++++++++++++++++ .../reference/importTypeNested.errors.txt | 12 ++ tests/baselines/reference/importTypeNested.js | 16 +++ .../reference/importTypeNested.symbols | 12 ++ .../reference/importTypeNested.types | 15 +++ .../reference/importTypeNonString.errors.txt | 8 ++ .../reference/importTypeNonString.js | 12 ++ .../reference/importTypeNonString.symbols | 6 + .../reference/importTypeNonString.types | 7 ++ .../types/import/importTypeAmbientMissing.ts | 11 ++ .../types/import/importTypeGeneric.ts | 18 +++ .../types/import/importTypeLocal.ts | 42 +++++++ .../types/import/importTypeLocalMissing.ts | 43 +++++++ .../types/import/importTypeNested.ts | 8 ++ .../types/import/importTypeNonString.ts | 3 + 37 files changed, 1165 insertions(+), 63 deletions(-) create mode 100644 tests/baselines/reference/importTypeAmbientMissing.errors.txt create mode 100644 tests/baselines/reference/importTypeAmbientMissing.js create mode 100644 tests/baselines/reference/importTypeAmbientMissing.symbols create mode 100644 tests/baselines/reference/importTypeAmbientMissing.types create mode 100644 tests/baselines/reference/importTypeGeneric.errors.txt create mode 100644 tests/baselines/reference/importTypeGeneric.js create mode 100644 tests/baselines/reference/importTypeGeneric.symbols create mode 100644 tests/baselines/reference/importTypeGeneric.types create mode 100644 tests/baselines/reference/importTypeLocal.js create mode 100644 tests/baselines/reference/importTypeLocal.symbols create mode 100644 tests/baselines/reference/importTypeLocal.types create mode 100644 tests/baselines/reference/importTypeLocalMissing.errors.txt create mode 100644 tests/baselines/reference/importTypeLocalMissing.js create mode 100644 tests/baselines/reference/importTypeLocalMissing.symbols create mode 100644 tests/baselines/reference/importTypeLocalMissing.types create mode 100644 tests/baselines/reference/importTypeNested.errors.txt create mode 100644 tests/baselines/reference/importTypeNested.js create mode 100644 tests/baselines/reference/importTypeNested.symbols create mode 100644 tests/baselines/reference/importTypeNested.types create mode 100644 tests/baselines/reference/importTypeNonString.errors.txt create mode 100644 tests/baselines/reference/importTypeNonString.js create mode 100644 tests/baselines/reference/importTypeNonString.symbols create mode 100644 tests/baselines/reference/importTypeNonString.types create mode 100644 tests/cases/conformance/types/import/importTypeAmbientMissing.ts create mode 100644 tests/cases/conformance/types/import/importTypeGeneric.ts create mode 100644 tests/cases/conformance/types/import/importTypeLocal.ts create mode 100644 tests/cases/conformance/types/import/importTypeLocalMissing.ts create mode 100644 tests/cases/conformance/types/import/importTypeNested.ts create mode 100644 tests/cases/conformance/types/import/importTypeNonString.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2ab7fa6f08625..9c572bea194fb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8417,12 +8417,21 @@ namespace ts { const argumentType = getTypeFromTypeNode(node.argument); const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; // TODO: Future work: support unions/generics/whatever via a deferred import-type - if (!(argumentType.flags & TypeFlags.StringLiteral)) { - return links.resolvedType = neverType; + if (!argumentType || !(argumentType.flags & TypeFlags.StringLiteral)) { + error(node.argument, Diagnostics.Import_specifier_must_be_a_string_literal_type_but_here_is_0, argumentType ? typeToString(argumentType) : "undefined"); + return links.resolvedType = anyType; } const moduleName = (argumentType as StringLiteralType).value; const innerModuleSymbol = resolveExternalModule(node, moduleName, Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); + if (!innerModuleSymbol) { + error(node, Diagnostics.Cannot_find_module_0, moduleName); + return links.resolvedType = anyType; + } const moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); + if (!moduleSymbol) { + error(node, Diagnostics.Cannot_find_module_0, moduleName); + return links.resolvedType = anyType; + } if (node.qualifier) { const nameStack: Identifier[] = []; let currentNamespace = moduleSymbol; @@ -8439,10 +8448,10 @@ namespace ts { } while (current = nameStack.pop()) { const meaning = nameStack.length ? SymbolFlags.Namespace : targetMeaning; - const next = getSymbol(getExportsOfSymbol(currentNamespace), current.escapedText, meaning); + const next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current)); - return links.resolvedType = neverType; + return links.resolvedType = anyType; } currentNamespace = next; } @@ -8453,8 +8462,8 @@ namespace ts { links.resolvedType = targetMeaning === SymbolFlags.Value ? getTypeOfSymbol(moduleSymbol) : getDeclaredTypeOfSymbol(moduleSymbol); } else { - error(node, targetMeaning & SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); - links.resolvedType = neverType; + error(node, targetMeaning === SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + links.resolvedType = anyType; } } } @@ -20661,6 +20670,11 @@ namespace ts { checkSourceElement(node.typeParameter); } + function checkImportType(node: ImportTypeNode) { + checkSourceElement(node.argument); + getTypeFromTypeNode(node); + } + function isPrivateWithinAmbient(node: Node): boolean { return hasModifier(node, ModifierFlags.Private) && !!(node.flags & NodeFlags.Ambient); } @@ -24408,6 +24422,8 @@ namespace ts { return checkConditionalType(node); case SyntaxKind.InferType: return checkInferType(node); + case SyntaxKind.ImportTypeNode: + return checkImportType(node); case SyntaxKind.JSDocAugmentsTag: return checkJSDocAugmentsTag(node as JSDocAugmentsTag); case SyntaxKind.JSDocTypedefTag: diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 43c635db2f20c..e3e3615e959c2 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -454,6 +454,8 @@ namespace ts { return emitConditionalType(type); case SyntaxKind.InferType: return emitInferType(type); + case SyntaxKind.ImportTypeNode: + return emitImportType(type); case SyntaxKind.ParenthesizedType: return emitParenType(type); case SyntaxKind.TypeOperator: @@ -567,6 +569,19 @@ namespace ts { writeTextOfNode(currentText, node.typeParameter.name); } + function emitImportType(node: ImportTypeNode) { + if (node.isTypeOf) { + write("typeof "); + } + write("import("); + emitType(node.argument); + write(")"); + if(node.qualifier) { + write("."); + writeEntityName(node.qualifier); // Don't do visibility checking; this entity name is _not_ looked up like a type query is + } + } + function emitParenType(type: ParenthesizedTypeNode) { write("("); emitType(type.type); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f0b2cdf5b948b..ea551077e7c8d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -959,6 +959,10 @@ "category": "Error", "code": 1340 }, + "Import specifier must be a string literal type, but here is '{0}'.": { + "category": "Error", + "code": 1341 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4ac6dfac22e8e..adeef7cc929a4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2711,6 +2711,7 @@ namespace ts { } function parseImportType(): ImportTypeNode { + sourceFile.flags |= NodeFlags.PossiblyContainsDynamicImport; const node = createNode(SyntaxKind.ImportTypeNode) as ImportTypeNode; if (parseOptional(SyntaxKind.TypeOfKeyword)) { node.isTypeOf = true; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 35772b2f04086..7c8b835d20c11 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1682,6 +1682,9 @@ namespace ts { else if (isImportCall(node) && node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) { (imports || (imports = [])).push((node).arguments[0]); } + else if (isLiteralImportTypeNode(node)) { + (imports || (imports = [])).push(node.argument.literal); + } else { forEachChild(node, collectDynamicImportOrRequireCalls); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6b93913e98fa5..aef985f935944 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1071,6 +1071,9 @@ namespace ts { qualifier?: EntityName; } + /* @internal */ + export type LiteralImportTypeNode = ImportTypeNode & { argument: LiteralTypeNode & { literal: StringLiteral } } + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fa0aa2d4e02f6..4ac5ceb9e367b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -722,6 +722,12 @@ namespace ts { return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.ImportKeyword; } + export function isLiteralImportTypeNode(n: Node): n is LiteralImportTypeNode { + return n.kind === SyntaxKind.ImportTypeNode && + (n as ImportTypeNode).argument.kind === SyntaxKind.LiteralType && + isStringLiteral(((n as ImportTypeNode).argument as LiteralTypeNode).literal); + } + export function isPrologueDirective(node: Node): node is PrologueDirective { return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; diff --git a/tests/baselines/reference/importTypeAmbient.js b/tests/baselines/reference/importTypeAmbient.js index 3bec3b2ff7e9d..2aeed00c6cfc5 100644 --- a/tests/baselines/reference/importTypeAmbient.js +++ b/tests/baselines/reference/importTypeAmbient.js @@ -62,7 +62,7 @@ declare module "foo" { } export = Point; } -declare const x: ; +declare const x: import("foo"); declare module "foo2" { namespace Bar { interface I { @@ -81,7 +81,7 @@ declare module "foo2" { constructor(input: Baz.J); } } -declare let y: ; +declare let y: import("foo2").Bar.I; declare class Bar2 { item: { a: string; @@ -90,58 +90,4 @@ declare class Bar2 { }; constructor(input?: any); } -declare let shim: ; - - -//// [DtsFileErrors] - - -tests/cases/conformance/types/import/importTypeAmbient.d.ts(8,18): error TS1110: Type expected. -tests/cases/conformance/types/import/importTypeAmbient.d.ts(27,16): error TS1110: Type expected. -tests/cases/conformance/types/import/importTypeAmbient.d.ts(36,19): error TS1110: Type expected. - - -==== tests/cases/conformance/types/import/importTypeAmbient.d.ts (3 errors) ==== - declare module "foo" { - interface Point { - x: number; - y: number; - } - export = Point; - } - declare const x: ; - ~ -!!! error TS1110: Type expected. - declare module "foo2" { - namespace Bar { - interface I { - a: string; - b: number; - } - } - namespace Baz { - interface J { - a: number; - b: string; - } - } - class Bar { - item: Bar.I; - constructor(input: Baz.J); - } - } - declare let y: ; - ~ -!!! error TS1110: Type expected. - declare class Bar2 { - item: { - a: string; - b: number; - c: object; - }; - constructor(input?: any); - } - declare let shim: ; - ~ -!!! error TS1110: Type expected. - \ No newline at end of file +declare let shim: typeof import("foo2"); diff --git a/tests/baselines/reference/importTypeAmbientMissing.errors.txt b/tests/baselines/reference/importTypeAmbientMissing.errors.txt new file mode 100644 index 0000000000000..99743a05100f0 --- /dev/null +++ b/tests/baselines/reference/importTypeAmbientMissing.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/types/import/importTypeAmbientMissing.ts(8,10): error TS2307: Cannot find module 'fo'. + + +==== tests/cases/conformance/types/import/importTypeAmbientMissing.ts (1 errors) ==== + declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; + } + const x: import("fo") = { x: 0, y: 0 }; // typo, error + ~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'fo'. + + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeAmbientMissing.js b/tests/baselines/reference/importTypeAmbientMissing.js new file mode 100644 index 0000000000000..7ed0a18eb2db7 --- /dev/null +++ b/tests/baselines/reference/importTypeAmbientMissing.js @@ -0,0 +1,25 @@ +//// [importTypeAmbientMissing.ts] +declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; +} +const x: import("fo") = { x: 0, y: 0 }; // typo, error + + + +//// [importTypeAmbientMissing.js] +var x = { x: 0, y: 0 }; // typo, error + + +//// [importTypeAmbientMissing.d.ts] +declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; +} +declare const x: import("fo"); diff --git a/tests/baselines/reference/importTypeAmbientMissing.symbols b/tests/baselines/reference/importTypeAmbientMissing.symbols new file mode 100644 index 0000000000000..5caeb1cc0e822 --- /dev/null +++ b/tests/baselines/reference/importTypeAmbientMissing.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/types/import/importTypeAmbientMissing.ts === +declare module "foo" { +>"foo" : Symbol("foo", Decl(importTypeAmbientMissing.ts, 0, 0)) + + interface Point { +>Point : Symbol(Point, Decl(importTypeAmbientMissing.ts, 0, 22)) + + x: number; +>x : Symbol(Point.x, Decl(importTypeAmbientMissing.ts, 1, 21)) + + y: number; +>y : Symbol(Point.y, Decl(importTypeAmbientMissing.ts, 2, 18)) + } + export = Point; +>Point : Symbol(Point, Decl(importTypeAmbientMissing.ts, 0, 22)) +} +const x: import("fo") = { x: 0, y: 0 }; // typo, error +>x : Symbol(x, Decl(importTypeAmbientMissing.ts, 7, 5)) +>x : Symbol(x, Decl(importTypeAmbientMissing.ts, 7, 25)) +>y : Symbol(y, Decl(importTypeAmbientMissing.ts, 7, 31)) + + diff --git a/tests/baselines/reference/importTypeAmbientMissing.types b/tests/baselines/reference/importTypeAmbientMissing.types new file mode 100644 index 0000000000000..975f0f83a7b63 --- /dev/null +++ b/tests/baselines/reference/importTypeAmbientMissing.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/types/import/importTypeAmbientMissing.ts === +declare module "foo" { +>"foo" : typeof "foo" + + interface Point { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number + } + export = Point; +>Point : Point +} +const x: import("fo") = { x: 0, y: 0 }; // typo, error +>x : any +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + + diff --git a/tests/baselines/reference/importTypeGeneric.errors.txt b/tests/baselines/reference/importTypeGeneric.errors.txt new file mode 100644 index 0000000000000..1efbbd38615a0 --- /dev/null +++ b/tests/baselines/reference/importTypeGeneric.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/types/import/usage.ts(1,67): error TS1341: Import specifier must be a string literal type, but here is 'T'. +tests/cases/conformance/types/import/usage.ts(5,72): error TS1341: Import specifier must be a string literal type, but here is 'T'. + + +==== tests/cases/conformance/types/import/a.d.ts (0 errors) ==== + export interface Foo { + a: string; + } +==== tests/cases/conformance/types/import/b.d.ts (0 errors) ==== + export interface Foo { + a: number; + } +==== tests/cases/conformance/types/import/usage.ts (2 errors) ==== + export function getFooFrom(v: T): import(T).Foo { + ~ +!!! error TS1341: Import specifier must be a string literal type, but here is 'T'. + return undefined as any; + } + + export function getFooValueFrom(v: T): import(T).Foo["a"] { + ~ +!!! error TS1341: Import specifier must be a string literal type, but here is 'T'. + return undefined as any; + } + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeGeneric.js b/tests/baselines/reference/importTypeGeneric.js new file mode 100644 index 0000000000000..996ee7a78dbda --- /dev/null +++ b/tests/baselines/reference/importTypeGeneric.js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/types/import/importTypeGeneric.ts] //// + +//// [a.d.ts] +export interface Foo { + a: string; +} +//// [b.d.ts] +export interface Foo { + a: number; +} +//// [usage.ts] +export function getFooFrom(v: T): import(T).Foo { + return undefined as any; +} + +export function getFooValueFrom(v: T): import(T).Foo["a"] { + return undefined as any; +} + + +//// [usage.js] +export function getFooFrom(v) { + return undefined; +} +export function getFooValueFrom(v) { + return undefined; +} + + +//// [usage.d.ts] +export declare function getFooFrom(v: T): import(T).Foo; +export declare function getFooValueFrom(v: T): import(T).Foo["a"]; diff --git a/tests/baselines/reference/importTypeGeneric.symbols b/tests/baselines/reference/importTypeGeneric.symbols new file mode 100644 index 0000000000000..08e55a40c5983 --- /dev/null +++ b/tests/baselines/reference/importTypeGeneric.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/types/import/a.d.ts === +export interface Foo { +>Foo : Symbol(Foo, Decl(a.d.ts, 0, 0)) + + a: string; +>a : Symbol(Foo.a, Decl(a.d.ts, 0, 22)) +} +=== tests/cases/conformance/types/import/b.d.ts === +export interface Foo { +>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) + + a: number; +>a : Symbol(Foo.a, Decl(b.d.ts, 0, 22)) +} +=== tests/cases/conformance/types/import/usage.ts === +export function getFooFrom(v: T): import(T).Foo { +>getFooFrom : Symbol(getFooFrom, Decl(usage.ts, 0, 0)) +>T : Symbol(T, Decl(usage.ts, 0, 27)) +>v : Symbol(v, Decl(usage.ts, 0, 52)) +>T : Symbol(T, Decl(usage.ts, 0, 27)) +>T : Symbol(T, Decl(usage.ts, 0, 27)) + + return undefined as any; +>undefined : Symbol(undefined) +} + +export function getFooValueFrom(v: T): import(T).Foo["a"] { +>getFooValueFrom : Symbol(getFooValueFrom, Decl(usage.ts, 2, 1)) +>T : Symbol(T, Decl(usage.ts, 4, 32)) +>v : Symbol(v, Decl(usage.ts, 4, 57)) +>T : Symbol(T, Decl(usage.ts, 4, 32)) +>T : Symbol(T, Decl(usage.ts, 4, 32)) + + return undefined as any; +>undefined : Symbol(undefined) +} + diff --git a/tests/baselines/reference/importTypeGeneric.types b/tests/baselines/reference/importTypeGeneric.types new file mode 100644 index 0000000000000..609b82c9139d0 --- /dev/null +++ b/tests/baselines/reference/importTypeGeneric.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/types/import/a.d.ts === +export interface Foo { +>Foo : Foo + + a: string; +>a : string +} +=== tests/cases/conformance/types/import/b.d.ts === +export interface Foo { +>Foo : Foo + + a: number; +>a : number +} +=== tests/cases/conformance/types/import/usage.ts === +export function getFooFrom(v: T): import(T).Foo { +>getFooFrom : (v: T) => any +>T : T +>v : T +>T : T +>T : T +>Foo : No type information available! + + return undefined as any; +>undefined as any : any +>undefined : undefined +} + +export function getFooValueFrom(v: T): import(T).Foo["a"] { +>getFooValueFrom : (v: T) => any +>T : T +>v : T +>T : T +>T : T +>Foo : No type information available! + + return undefined as any; +>undefined as any : any +>undefined : undefined +} + diff --git a/tests/baselines/reference/importTypeLocal.js b/tests/baselines/reference/importTypeLocal.js new file mode 100644 index 0000000000000..1b470617396a6 --- /dev/null +++ b/tests/baselines/reference/importTypeLocal.js @@ -0,0 +1,108 @@ +//// [tests/cases/conformance/types/import/importTypeLocal.ts] //// + +//// [foo.ts] +interface Point { + x: number; + y: number; +} +export = Point; + +//// [foo2.ts] +namespace Bar { + export interface I { + a: string; + b: number; + } +} + +export namespace Baz { + export interface J { + a: number; + b: string; + } +} + +class Bar { + item: Bar.I; + constructor(input: Baz.J) {} +} +export { Bar } + +//// [usage.ts] +export const x: import("./foo") = { x: 0, y: 0 }; +export let y: import("./foo2").Bar.I = { a: "", b: 0 }; + +export class Bar2 { + item: {a: string, b: number, c: object}; + constructor(input?: any) {} +} + +export let shim: typeof import("./foo2") = { + Bar: Bar2 +}; + + +//// [foo.js] +"use strict"; +exports.__esModule = true; +//// [foo2.js] +"use strict"; +exports.__esModule = true; +var Bar = /** @class */ (function () { + function Bar(input) { + } + return Bar; +}()); +exports.Bar = Bar; +//// [usage.js] +"use strict"; +exports.__esModule = true; +exports.x = { x: 0, y: 0 }; +exports.y = { a: "", b: 0 }; +var Bar2 = /** @class */ (function () { + function Bar2(input) { + } + return Bar2; +}()); +exports.Bar2 = Bar2; +exports.shim = { + Bar: Bar2 +}; + + +//// [foo.d.ts] +interface Point { + x: number; + y: number; +} +export = Point; +//// [foo2.d.ts] +declare namespace Bar { + interface I { + a: string; + b: number; + } +} +export declare namespace Baz { + interface J { + a: number; + b: string; + } +} +declare class Bar { + item: Bar.I; + constructor(input: Baz.J); +} +export { Bar }; +//// [usage.d.ts] +export declare const x: import("./foo"); +export declare let y: import("./foo2").Bar.I; +export declare class Bar2 { + item: { + a: string; + b: number; + c: object; + }; + constructor(input?: any); +} +export declare let shim: typeof import("./foo2"); diff --git a/tests/baselines/reference/importTypeLocal.symbols b/tests/baselines/reference/importTypeLocal.symbols new file mode 100644 index 0000000000000..385a6794d37d9 --- /dev/null +++ b/tests/baselines/reference/importTypeLocal.symbols @@ -0,0 +1,91 @@ +=== tests/cases/conformance/types/import/foo.ts === +interface Point { +>Point : Symbol(Point, Decl(foo.ts, 0, 0)) + + x: number; +>x : Symbol(Point.x, Decl(foo.ts, 0, 17)) + + y: number; +>y : Symbol(Point.y, Decl(foo.ts, 1, 14)) +} +export = Point; +>Point : Symbol(Point, Decl(foo.ts, 0, 0)) + +=== tests/cases/conformance/types/import/foo2.ts === +namespace Bar { +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 12, 1)) + + export interface I { +>I : Symbol(I, Decl(foo2.ts, 0, 15)) + + a: string; +>a : Symbol(I.a, Decl(foo2.ts, 1, 24)) + + b: number; +>b : Symbol(I.b, Decl(foo2.ts, 2, 18)) + } +} + +export namespace Baz { +>Baz : Symbol(Baz, Decl(foo2.ts, 5, 1)) + + export interface J { +>J : Symbol(J, Decl(foo2.ts, 7, 22)) + + a: number; +>a : Symbol(J.a, Decl(foo2.ts, 8, 24)) + + b: string; +>b : Symbol(J.b, Decl(foo2.ts, 9, 18)) + } +} + +class Bar { +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 12, 1)) + + item: Bar.I; +>item : Symbol(Bar.item, Decl(foo2.ts, 14, 11)) +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 12, 1)) +>I : Symbol(Bar.I, Decl(foo2.ts, 0, 15)) + + constructor(input: Baz.J) {} +>input : Symbol(input, Decl(foo2.ts, 16, 16)) +>Baz : Symbol(Baz, Decl(foo2.ts, 5, 1)) +>J : Symbol(Baz.J, Decl(foo2.ts, 7, 22)) +} +export { Bar } +>Bar : Symbol(Bar, Decl(foo2.ts, 18, 8)) + +=== tests/cases/conformance/types/import/usage.ts === +export const x: import("./foo") = { x: 0, y: 0 }; +>x : Symbol(x, Decl(usage.ts, 0, 12)) +>x : Symbol(x, Decl(usage.ts, 0, 35)) +>y : Symbol(y, Decl(usage.ts, 0, 41)) + +export let y: import("./foo2").Bar.I = { a: "", b: 0 }; +>y : Symbol(y, Decl(usage.ts, 1, 10)) +>a : Symbol(a, Decl(usage.ts, 1, 40)) +>b : Symbol(b, Decl(usage.ts, 1, 47)) + +export class Bar2 { +>Bar2 : Symbol(Bar2, Decl(usage.ts, 1, 55)) + + item: {a: string, b: number, c: object}; +>item : Symbol(Bar2.item, Decl(usage.ts, 3, 19)) +>a : Symbol(a, Decl(usage.ts, 4, 11)) +>b : Symbol(b, Decl(usage.ts, 4, 21)) +>c : Symbol(c, Decl(usage.ts, 4, 32)) + + constructor(input?: any) {} +>input : Symbol(input, Decl(usage.ts, 5, 16)) +} + +export let shim: typeof import("./foo2") = { +>shim : Symbol(shim, Decl(usage.ts, 8, 10)) + + Bar: Bar2 +>Bar : Symbol(Bar, Decl(usage.ts, 8, 44)) +>Bar2 : Symbol(Bar2, Decl(usage.ts, 1, 55)) + +}; + diff --git a/tests/baselines/reference/importTypeLocal.types b/tests/baselines/reference/importTypeLocal.types new file mode 100644 index 0000000000000..8969260819d71 --- /dev/null +++ b/tests/baselines/reference/importTypeLocal.types @@ -0,0 +1,100 @@ +=== tests/cases/conformance/types/import/foo.ts === +interface Point { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number +} +export = Point; +>Point : Point + +=== tests/cases/conformance/types/import/foo2.ts === +namespace Bar { +>Bar : typeof Bar + + export interface I { +>I : I + + a: string; +>a : string + + b: number; +>b : number + } +} + +export namespace Baz { +>Baz : any + + export interface J { +>J : J + + a: number; +>a : number + + b: string; +>b : string + } +} + +class Bar { +>Bar : Bar + + item: Bar.I; +>item : Bar.I +>Bar : any +>I : Bar.I + + constructor(input: Baz.J) {} +>input : Baz.J +>Baz : any +>J : Baz.J +} +export { Bar } +>Bar : typeof Bar + +=== tests/cases/conformance/types/import/usage.ts === +export const x: import("./foo") = { x: 0, y: 0 }; +>x : Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +export let y: import("./foo2").Bar.I = { a: "", b: 0 }; +>y : Bar.I +>Bar : any +>I : No type information available! +>{ a: "", b: 0 } : { a: string; b: number; } +>a : string +>"" : "" +>b : number +>0 : 0 + +export class Bar2 { +>Bar2 : Bar2 + + item: {a: string, b: number, c: object}; +>item : { a: string; b: number; c: object; } +>a : string +>b : number +>c : object + + constructor(input?: any) {} +>input : any +} + +export let shim: typeof import("./foo2") = { +>shim : typeof "tests/cases/conformance/types/import/foo2" +>{ Bar: Bar2} : { Bar: typeof Bar2; } + + Bar: Bar2 +>Bar : typeof Bar2 +>Bar2 : typeof Bar2 + +}; + diff --git a/tests/baselines/reference/importTypeLocalMissing.errors.txt b/tests/baselines/reference/importTypeLocalMissing.errors.txt new file mode 100644 index 0000000000000..82b813668eaf6 --- /dev/null +++ b/tests/baselines/reference/importTypeLocalMissing.errors.txt @@ -0,0 +1,56 @@ +tests/cases/conformance/types/import/usage.ts(1,17): error TS2307: Cannot find module './fo'. +tests/cases/conformance/types/import/usage.ts(2,15): error TS2307: Cannot find module './fo2'. +tests/cases/conformance/types/import/usage.ts(3,36): error TS2694: Namespace '"tests/cases/conformance/types/import/foo2".Bar' has no exported member 'Q'. +tests/cases/conformance/types/import/usage.ts(10,18): error TS2307: Cannot find module './fo2'. + + +==== tests/cases/conformance/types/import/foo.ts (0 errors) ==== + interface Point { + x: number; + y: number; + } + export = Point; + +==== tests/cases/conformance/types/import/foo2.ts (0 errors) ==== + namespace Bar { + export interface I { + a: string; + b: number; + } + } + + export namespace Baz { + export interface J { + a: number; + b: string; + } + } + + class Bar { + item: Bar.I; + constructor(input: Baz.J) {} + } + export { Bar } + +==== tests/cases/conformance/types/import/usage.ts (4 errors) ==== + export const x: import("./fo") = { x: 0, y: 0 }; + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './fo'. + export let y: import("./fo2").Bar.I = { a: "", b: 0 }; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './fo2'. + export let z: import("./foo2").Bar.Q = { a: "", b: 0 }; + ~ +!!! error TS2694: Namespace '"tests/cases/conformance/types/import/foo2".Bar' has no exported member 'Q'. + + export class Bar2 { + item: {a: string, b: number, c: object}; + constructor(input?: any) {} + } + + export let shim: typeof import("./fo2") = { + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './fo2'. + Bar: Bar2 + }; + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeLocalMissing.js b/tests/baselines/reference/importTypeLocalMissing.js new file mode 100644 index 0000000000000..4ee8b2a45a4a9 --- /dev/null +++ b/tests/baselines/reference/importTypeLocalMissing.js @@ -0,0 +1,111 @@ +//// [tests/cases/conformance/types/import/importTypeLocalMissing.ts] //// + +//// [foo.ts] +interface Point { + x: number; + y: number; +} +export = Point; + +//// [foo2.ts] +namespace Bar { + export interface I { + a: string; + b: number; + } +} + +export namespace Baz { + export interface J { + a: number; + b: string; + } +} + +class Bar { + item: Bar.I; + constructor(input: Baz.J) {} +} +export { Bar } + +//// [usage.ts] +export const x: import("./fo") = { x: 0, y: 0 }; +export let y: import("./fo2").Bar.I = { a: "", b: 0 }; +export let z: import("./foo2").Bar.Q = { a: "", b: 0 }; + +export class Bar2 { + item: {a: string, b: number, c: object}; + constructor(input?: any) {} +} + +export let shim: typeof import("./fo2") = { + Bar: Bar2 +}; + + +//// [foo.js] +"use strict"; +exports.__esModule = true; +//// [foo2.js] +"use strict"; +exports.__esModule = true; +var Bar = /** @class */ (function () { + function Bar(input) { + } + return Bar; +}()); +exports.Bar = Bar; +//// [usage.js] +"use strict"; +exports.__esModule = true; +exports.x = { x: 0, y: 0 }; +exports.y = { a: "", b: 0 }; +exports.z = { a: "", b: 0 }; +var Bar2 = /** @class */ (function () { + function Bar2(input) { + } + return Bar2; +}()); +exports.Bar2 = Bar2; +exports.shim = { + Bar: Bar2 +}; + + +//// [foo.d.ts] +interface Point { + x: number; + y: number; +} +export = Point; +//// [foo2.d.ts] +declare namespace Bar { + interface I { + a: string; + b: number; + } +} +export declare namespace Baz { + interface J { + a: number; + b: string; + } +} +declare class Bar { + item: Bar.I; + constructor(input: Baz.J); +} +export { Bar }; +//// [usage.d.ts] +export declare const x: import("./fo"); +export declare let y: import("./fo2").Bar.I; +export declare let z: import("./foo2").Bar.Q; +export declare class Bar2 { + item: { + a: string; + b: number; + c: object; + }; + constructor(input?: any); +} +export declare let shim: typeof import("./fo2"); diff --git a/tests/baselines/reference/importTypeLocalMissing.symbols b/tests/baselines/reference/importTypeLocalMissing.symbols new file mode 100644 index 0000000000000..9dd63ef30997d --- /dev/null +++ b/tests/baselines/reference/importTypeLocalMissing.symbols @@ -0,0 +1,96 @@ +=== tests/cases/conformance/types/import/foo.ts === +interface Point { +>Point : Symbol(Point, Decl(foo.ts, 0, 0)) + + x: number; +>x : Symbol(Point.x, Decl(foo.ts, 0, 17)) + + y: number; +>y : Symbol(Point.y, Decl(foo.ts, 1, 14)) +} +export = Point; +>Point : Symbol(Point, Decl(foo.ts, 0, 0)) + +=== tests/cases/conformance/types/import/foo2.ts === +namespace Bar { +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 12, 1)) + + export interface I { +>I : Symbol(I, Decl(foo2.ts, 0, 15)) + + a: string; +>a : Symbol(I.a, Decl(foo2.ts, 1, 24)) + + b: number; +>b : Symbol(I.b, Decl(foo2.ts, 2, 18)) + } +} + +export namespace Baz { +>Baz : Symbol(Baz, Decl(foo2.ts, 5, 1)) + + export interface J { +>J : Symbol(J, Decl(foo2.ts, 7, 22)) + + a: number; +>a : Symbol(J.a, Decl(foo2.ts, 8, 24)) + + b: string; +>b : Symbol(J.b, Decl(foo2.ts, 9, 18)) + } +} + +class Bar { +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 12, 1)) + + item: Bar.I; +>item : Symbol(Bar.item, Decl(foo2.ts, 14, 11)) +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 12, 1)) +>I : Symbol(Bar.I, Decl(foo2.ts, 0, 15)) + + constructor(input: Baz.J) {} +>input : Symbol(input, Decl(foo2.ts, 16, 16)) +>Baz : Symbol(Baz, Decl(foo2.ts, 5, 1)) +>J : Symbol(Baz.J, Decl(foo2.ts, 7, 22)) +} +export { Bar } +>Bar : Symbol(Bar, Decl(foo2.ts, 18, 8)) + +=== tests/cases/conformance/types/import/usage.ts === +export const x: import("./fo") = { x: 0, y: 0 }; +>x : Symbol(x, Decl(usage.ts, 0, 12)) +>x : Symbol(x, Decl(usage.ts, 0, 34)) +>y : Symbol(y, Decl(usage.ts, 0, 40)) + +export let y: import("./fo2").Bar.I = { a: "", b: 0 }; +>y : Symbol(y, Decl(usage.ts, 1, 10)) +>a : Symbol(a, Decl(usage.ts, 1, 39)) +>b : Symbol(b, Decl(usage.ts, 1, 46)) + +export let z: import("./foo2").Bar.Q = { a: "", b: 0 }; +>z : Symbol(z, Decl(usage.ts, 2, 10)) +>a : Symbol(a, Decl(usage.ts, 2, 40)) +>b : Symbol(b, Decl(usage.ts, 2, 47)) + +export class Bar2 { +>Bar2 : Symbol(Bar2, Decl(usage.ts, 2, 55)) + + item: {a: string, b: number, c: object}; +>item : Symbol(Bar2.item, Decl(usage.ts, 4, 19)) +>a : Symbol(a, Decl(usage.ts, 5, 11)) +>b : Symbol(b, Decl(usage.ts, 5, 21)) +>c : Symbol(c, Decl(usage.ts, 5, 32)) + + constructor(input?: any) {} +>input : Symbol(input, Decl(usage.ts, 6, 16)) +} + +export let shim: typeof import("./fo2") = { +>shim : Symbol(shim, Decl(usage.ts, 9, 10)) + + Bar: Bar2 +>Bar : Symbol(Bar, Decl(usage.ts, 9, 43)) +>Bar2 : Symbol(Bar2, Decl(usage.ts, 2, 55)) + +}; + diff --git a/tests/baselines/reference/importTypeLocalMissing.types b/tests/baselines/reference/importTypeLocalMissing.types new file mode 100644 index 0000000000000..aa7d227f98e42 --- /dev/null +++ b/tests/baselines/reference/importTypeLocalMissing.types @@ -0,0 +1,110 @@ +=== tests/cases/conformance/types/import/foo.ts === +interface Point { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number +} +export = Point; +>Point : Point + +=== tests/cases/conformance/types/import/foo2.ts === +namespace Bar { +>Bar : typeof Bar + + export interface I { +>I : I + + a: string; +>a : string + + b: number; +>b : number + } +} + +export namespace Baz { +>Baz : any + + export interface J { +>J : J + + a: number; +>a : number + + b: string; +>b : string + } +} + +class Bar { +>Bar : Bar + + item: Bar.I; +>item : Bar.I +>Bar : any +>I : Bar.I + + constructor(input: Baz.J) {} +>input : Baz.J +>Baz : any +>J : Baz.J +} +export { Bar } +>Bar : typeof Bar + +=== tests/cases/conformance/types/import/usage.ts === +export const x: import("./fo") = { x: 0, y: 0 }; +>x : any +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + +export let y: import("./fo2").Bar.I = { a: "", b: 0 }; +>y : any +>Bar : any +>I : No type information available! +>{ a: "", b: 0 } : { a: string; b: number; } +>a : string +>"" : "" +>b : number +>0 : 0 + +export let z: import("./foo2").Bar.Q = { a: "", b: 0 }; +>z : any +>Bar : any +>Q : No type information available! +>{ a: "", b: 0 } : { a: string; b: number; } +>a : string +>"" : "" +>b : number +>0 : 0 + +export class Bar2 { +>Bar2 : Bar2 + + item: {a: string, b: number, c: object}; +>item : { a: string; b: number; c: object; } +>a : string +>b : number +>c : object + + constructor(input?: any) {} +>input : any +} + +export let shim: typeof import("./fo2") = { +>shim : any +>{ Bar: Bar2} : { Bar: typeof Bar2; } + + Bar: Bar2 +>Bar : typeof Bar2 +>Bar2 : typeof Bar2 + +}; + diff --git a/tests/baselines/reference/importTypeNested.errors.txt b/tests/baselines/reference/importTypeNested.errors.txt new file mode 100644 index 0000000000000..cf30ccf797e6d --- /dev/null +++ b/tests/baselines/reference/importTypeNested.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/types/import/chainer.ts(1,17): error TS2307: Cannot find module './b'. + + +==== tests/cases/conformance/types/import/a.d.ts (0 errors) ==== + export type LookAt = "./b"; +==== tests/cases/conformance/types/import/b.d.ts (0 errors) ==== + export type Value = "yes"; +==== tests/cases/conformance/types/import/chainer.ts (1 errors) ==== + export const x: import(import("./a").LookAt).Value = "yes"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './b'. + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeNested.js b/tests/baselines/reference/importTypeNested.js new file mode 100644 index 0000000000000..94f4ce13f11fa --- /dev/null +++ b/tests/baselines/reference/importTypeNested.js @@ -0,0 +1,16 @@ +//// [tests/cases/conformance/types/import/importTypeNested.ts] //// + +//// [a.d.ts] +export type LookAt = "./b"; +//// [b.d.ts] +export type Value = "yes"; +//// [chainer.ts] +export const x: import(import("./a").LookAt).Value = "yes"; + + +//// [chainer.js] +export const x = "yes"; + + +//// [chainer.d.ts] +export declare const x: import(import("./a").LookAt).Value; diff --git a/tests/baselines/reference/importTypeNested.symbols b/tests/baselines/reference/importTypeNested.symbols new file mode 100644 index 0000000000000..ba72e64ad3736 --- /dev/null +++ b/tests/baselines/reference/importTypeNested.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/types/import/a.d.ts === +export type LookAt = "./b"; +>LookAt : Symbol(LookAt, Decl(a.d.ts, 0, 0)) + +=== tests/cases/conformance/types/import/b.d.ts === +export type Value = "yes"; +>Value : Symbol(Value, Decl(b.d.ts, 0, 0)) + +=== tests/cases/conformance/types/import/chainer.ts === +export const x: import(import("./a").LookAt).Value = "yes"; +>x : Symbol(x, Decl(chainer.ts, 0, 12)) + diff --git a/tests/baselines/reference/importTypeNested.types b/tests/baselines/reference/importTypeNested.types new file mode 100644 index 0000000000000..45bac0b37b0b0 --- /dev/null +++ b/tests/baselines/reference/importTypeNested.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/types/import/a.d.ts === +export type LookAt = "./b"; +>LookAt : "./b" + +=== tests/cases/conformance/types/import/b.d.ts === +export type Value = "yes"; +>Value : "yes" + +=== tests/cases/conformance/types/import/chainer.ts === +export const x: import(import("./a").LookAt).Value = "yes"; +>x : any +>LookAt : No type information available! +>Value : No type information available! +>"yes" : "yes" + diff --git a/tests/baselines/reference/importTypeNonString.errors.txt b/tests/baselines/reference/importTypeNonString.errors.txt new file mode 100644 index 0000000000000..cd723d6cf77f6 --- /dev/null +++ b/tests/baselines/reference/importTypeNonString.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/types/import/importTypeNonString.ts(1,24): error TS1341: Import specifier must be a string literal type, but here is '{ x: 12; }'. + + +==== tests/cases/conformance/types/import/importTypeNonString.ts (1 errors) ==== + export const x: import({x: 12}) = undefined as any; + ~~~~~~~ +!!! error TS1341: Import specifier must be a string literal type, but here is '{ x: 12; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeNonString.js b/tests/baselines/reference/importTypeNonString.js new file mode 100644 index 0000000000000..bd42b584dec1b --- /dev/null +++ b/tests/baselines/reference/importTypeNonString.js @@ -0,0 +1,12 @@ +//// [importTypeNonString.ts] +export const x: import({x: 12}) = undefined as any; + + +//// [importTypeNonString.js] +export const x = undefined; + + +//// [importTypeNonString.d.ts] +export declare const x: import({ + x: 12; +}); diff --git a/tests/baselines/reference/importTypeNonString.symbols b/tests/baselines/reference/importTypeNonString.symbols new file mode 100644 index 0000000000000..5ad2a2c6be914 --- /dev/null +++ b/tests/baselines/reference/importTypeNonString.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/types/import/importTypeNonString.ts === +export const x: import({x: 12}) = undefined as any; +>x : Symbol(x, Decl(importTypeNonString.ts, 0, 12)) +>x : Symbol(x, Decl(importTypeNonString.ts, 0, 24)) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/importTypeNonString.types b/tests/baselines/reference/importTypeNonString.types new file mode 100644 index 0000000000000..75dc42e09a769 --- /dev/null +++ b/tests/baselines/reference/importTypeNonString.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/types/import/importTypeNonString.ts === +export const x: import({x: 12}) = undefined as any; +>x : any +>x : 12 +>undefined as any : any +>undefined : undefined + diff --git a/tests/cases/conformance/types/import/importTypeAmbientMissing.ts b/tests/cases/conformance/types/import/importTypeAmbientMissing.ts new file mode 100644 index 0000000000000..1b61a58bfc1f3 --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeAmbientMissing.ts @@ -0,0 +1,11 @@ +// @declaration: true +// @lib: es6 +declare module "foo" { + interface Point { + x: number; + y: number; + } + export = Point; +} +const x: import("fo") = { x: 0, y: 0 }; // typo, error + diff --git a/tests/cases/conformance/types/import/importTypeGeneric.ts b/tests/cases/conformance/types/import/importTypeGeneric.ts new file mode 100644 index 0000000000000..61373219c9591 --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeGeneric.ts @@ -0,0 +1,18 @@ +// @declaration: true +// @target: es6 +// @filename: a.d.ts +export interface Foo { + a: string; +} +// @filename: b.d.ts +export interface Foo { + a: number; +} +// @filename: usage.ts +export function getFooFrom(v: T): import(T).Foo { + return undefined as any; +} + +export function getFooValueFrom(v: T): import(T).Foo["a"] { + return undefined as any; +} diff --git a/tests/cases/conformance/types/import/importTypeLocal.ts b/tests/cases/conformance/types/import/importTypeLocal.ts new file mode 100644 index 0000000000000..4f29a222853e5 --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeLocal.ts @@ -0,0 +1,42 @@ +// @declaration: true +// @lib: es6 +// @filename: foo.ts +interface Point { + x: number; + y: number; +} +export = Point; + +// @filename: foo2.ts +namespace Bar { + export interface I { + a: string; + b: number; + } +} + +export namespace Baz { + export interface J { + a: number; + b: string; + } +} + +class Bar { + item: Bar.I; + constructor(input: Baz.J) {} +} +export { Bar } + +// @filename: usage.ts +export const x: import("./foo") = { x: 0, y: 0 }; +export let y: import("./foo2").Bar.I = { a: "", b: 0 }; + +export class Bar2 { + item: {a: string, b: number, c: object}; + constructor(input?: any) {} +} + +export let shim: typeof import("./foo2") = { + Bar: Bar2 +}; diff --git a/tests/cases/conformance/types/import/importTypeLocalMissing.ts b/tests/cases/conformance/types/import/importTypeLocalMissing.ts new file mode 100644 index 0000000000000..f7a2eb4448bf6 --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeLocalMissing.ts @@ -0,0 +1,43 @@ +// @declaration: true +// @lib: es6 +// @filename: foo.ts +interface Point { + x: number; + y: number; +} +export = Point; + +// @filename: foo2.ts +namespace Bar { + export interface I { + a: string; + b: number; + } +} + +export namespace Baz { + export interface J { + a: number; + b: string; + } +} + +class Bar { + item: Bar.I; + constructor(input: Baz.J) {} +} +export { Bar } + +// @filename: usage.ts +export const x: import("./fo") = { x: 0, y: 0 }; +export let y: import("./fo2").Bar.I = { a: "", b: 0 }; +export let z: import("./foo2").Bar.Q = { a: "", b: 0 }; + +export class Bar2 { + item: {a: string, b: number, c: object}; + constructor(input?: any) {} +} + +export let shim: typeof import("./fo2") = { + Bar: Bar2 +}; diff --git a/tests/cases/conformance/types/import/importTypeNested.ts b/tests/cases/conformance/types/import/importTypeNested.ts new file mode 100644 index 0000000000000..e412add906b70 --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeNested.ts @@ -0,0 +1,8 @@ +// @declaration: true +// @target: es6 +// @filename: a.d.ts +export type LookAt = "./b"; +// @filename: b.d.ts +export type Value = "yes"; +// @filename: chainer.ts +export const x: import(import("./a").LookAt).Value = "yes"; diff --git a/tests/cases/conformance/types/import/importTypeNonString.ts b/tests/cases/conformance/types/import/importTypeNonString.ts new file mode 100644 index 0000000000000..77dc2d1ad2c91 --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeNonString.ts @@ -0,0 +1,3 @@ +// @declaration: true +// @target: es6 +export const x: import({x: 12}) = undefined as any; From fa9fe502d906fcc64a4c712e0f1c58b4257eea80 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 14 Mar 2018 18:13:18 -0700 Subject: [PATCH 05/21] Allow resolutions to be performed late if the resolution still results in a file already in the build --- src/compiler/checker.ts | 12 +++++++++- src/compiler/declarationEmitter.ts | 2 +- src/compiler/program.ts | 13 ++++++----- src/compiler/types.ts | 12 ++++++++-- src/compiler/utilities.ts | 21 ++++++++++++------ .../unittests/reuseProgramStructure.ts | 14 +++++++++++- src/server/project.ts | 2 +- src/services/codefixes/convertToEs6Module.ts | 2 +- src/services/codefixes/importFixes.ts | 6 +++-- src/services/services.ts | 2 +- src/services/suggestionDiagnostics.ts | 2 +- .../reference/importTypeNested.errors.txt | 12 ---------- .../reference/importTypeNested.types | 2 +- ...ugmentationDisallowedExtensions.errors.txt | 14 +----------- ...duleAugmentationDisallowedExtensions.types | 6 ++--- ...eAugmentationImportsAndExports2.errors.txt | 8 +------ ...moduleAugmentationImportsAndExports2.types | 8 +++---- ...eAugmentationImportsAndExports3.errors.txt | 5 +---- ...duleAugmentationImportsAndExports3.symbols | 2 ++ ...moduleAugmentationImportsAndExports3.types | 22 +++++++++---------- 20 files changed, 88 insertions(+), 79 deletions(-) delete mode 100644 tests/baselines/reference/importTypeNested.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9c572bea194fb..123a274fc88f3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2104,7 +2104,17 @@ namespace ts { if (ambientModule) { return ambientModule; } - const resolvedModule = getResolvedModule(getSourceFileOfNode(location), moduleReference); + const currentSourceFile = getSourceFileOfNode(location); + const resolvedModuleState = getResolvedModule(currentSourceFile, moduleReference); + let resolvedModule: ResolvedModuleFull; + if (currentSourceFile && resolvedModuleState === undefined) { + // Fallback to uncached lookup for late-bound module names which have not been resolved + const resolutions = host.resolveModuleName([moduleReference], currentSourceFile.fileName); + resolvedModule = firstOrUndefined(resolutions); + } + else { + resolvedModule = getResolvedModuleFromState(resolvedModuleState); + } const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule); const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index e3e3615e959c2..f76380eec1812 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -576,7 +576,7 @@ namespace ts { write("import("); emitType(node.argument); write(")"); - if(node.qualifier) { + if (node.qualifier) { write("."); writeEntityName(node.qualifier); // Don't do visibility checking; this entity name is _not_ looked up like a type query is } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7c8b835d20c11..8592194bbd8b2 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -665,7 +665,8 @@ namespace ts { getSourceFileFromReference, sourceFileToPackageName, redirectTargetsSet, - isEmittedFile + isEmittedFile, + resolveModuleName: resolveModuleNamesWorker }; verifyCompilerOptions(); @@ -739,7 +740,7 @@ namespace ts { const result: ResolvedModuleFull[] = []; for (const moduleName of moduleNames) { const resolvedModule = file.resolvedModules.get(moduleName); - result.push(resolvedModule); + result.push(getResolvedModuleFromState(resolvedModule)); } return result; } @@ -768,7 +769,7 @@ namespace ts { const moduleName = moduleNames[i]; // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) { - const oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName); + const oldResolvedModule = getResolvedModuleFromState(oldSourceFile && oldSourceFile.resolvedModules.get(moduleName)); if (oldResolvedModule) { if (isTraceEnabled(options, host)) { trace(host, Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile); @@ -834,7 +835,7 @@ namespace ts { // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState: OldProgramState): boolean { - const resolutionToFile = getResolvedModule(oldProgramState.oldSourceFile, moduleName); + const resolutionToFile = getResolvedModuleFromState(getResolvedModule(oldProgramState.oldSourceFile, moduleName)); const resolvedFile = resolutionToFile && oldProgramState.program && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same @@ -1017,10 +1018,10 @@ namespace ts { const oldProgramState: OldProgramState = { program: oldProgram, oldSourceFile, modifiedFilePaths }; const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); // ensure that module resolution results are still correct - const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo); + const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo, getResolvedModuleFromState); if (resolutionsChanged) { oldProgram.structureIsReused = StructureIsReused.SafeModules; - newSourceFile.resolvedModules = zipToMap(moduleNames, resolutions); + newSourceFile.resolvedModules = zipToMap(moduleNames, map(resolutions, r => ({ tag: "success" as "success", data: r }))); } else { newSourceFile.resolvedModules = oldSourceFile.resolvedModules; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index aef985f935944..8cd94e2efb2bc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1072,7 +1072,7 @@ namespace ts { } /* @internal */ - export type LiteralImportTypeNode = ImportTypeNode & { argument: LiteralTypeNode & { literal: StringLiteral } } + export type LiteralImportTypeNode = ImportTypeNode & { argument: LiteralTypeNode & { literal: StringLiteral } }; export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; @@ -2575,7 +2575,7 @@ namespace ts { // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead - /* @internal */ resolvedModules: Map; + /* @internal */ resolvedModules: Map; /* @internal */ resolvedTypeReferenceDirectiveNames: Map; /* @internal */ imports: ReadonlyArray; // Identifier only if `declare global` @@ -2589,6 +2589,9 @@ namespace ts { /* @internal */ localJsxFactory?: EntityName; } + /* @internal */ + export type ResolvedModuleState = { tag: "success", data: ResolvedModuleFull } | { tag: "fail" }; + export interface Bundle extends Node { kind: SyntaxKind.Bundle; sourceFiles: ReadonlyArray; @@ -2709,6 +2712,9 @@ namespace ts { /* @internal */ redirectTargetsSet: Map; /** Is the file emitted file */ /* @internal */ isEmittedFile(file: string): boolean; + + /* Used by the type checker to resolve module names which are encountered late */ + /* @internal */ resolveModuleName(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModuleFull[]; } /* @internal */ @@ -2782,6 +2788,8 @@ namespace ts { getSourceFiles(): ReadonlyArray; getSourceFile(fileName: string): SourceFile; getResolvedTypeReferenceDirectives(): ReadonlyMap; + + resolveModuleName(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModuleFull[]; } export interface TypeChecker { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4ac5ceb9e367b..693b2a890932d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -83,16 +83,21 @@ namespace ts { return node.end - node.pos; } - export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull | undefined { + export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleState { return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText); } + export function getResolvedModuleFromState(state: ResolvedModuleState): ResolvedModuleFull | undefined { + return state && state.tag === "success" ? state.data : undefined; + } + + const failedLookup: { tag: "fail" } = { tag: "fail" }; export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void { if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = createMap(); + sourceFile.resolvedModules = createMap(); } - sourceFile.resolvedModules.set(moduleNameText, resolvedModule); + sourceFile.resolvedModules.set(moduleNameText, resolvedModule ? { tag: "success", data: resolvedModule } : failedLookup); } export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void { @@ -124,16 +129,18 @@ namespace ts { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } - export function hasChangesInResolutions( + export function hasChangesInResolutions( names: ReadonlyArray, newResolutions: ReadonlyArray, - oldResolutions: ReadonlyMap, - comparer: (oldResolution: T, newResolution: T) => boolean): boolean { + oldResolutions: ReadonlyMap, + comparer: (oldResolution: T, newResolution: T) => boolean, + oldMapper?: (x: U) => T): boolean { Debug.assert(names.length === newResolutions.length); for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; - const oldResolution = oldResolutions && oldResolutions.get(names[i]); + const oldRes = oldResolutions && oldResolutions.get(names[i]); + const oldResolution = oldMapper ? oldMapper(oldRes) : oldRes as {} as T; const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 0ba9e6f63518c..0eecb13d2a2e8 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -219,7 +219,19 @@ namespace ts { } function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { - checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule); + checkCache("resolved modules", program, fileName, expectedContent, f => { + if (!f.resolvedModules) return undefined; + const mapped: Map = createMap(); + forEachEntry(f.resolvedModules, (value, key) => { + if (value.tag === "success") { + mapped.set(key, value.data); + } + else { + mapped.set(key, undefined); + } + }); + return mapped; + }, checkResolvedModule); } function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: Map): void { diff --git a/src/server/project.ts b/src/server/project.ts index c7239fdc94d66..6775de3228084 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -780,7 +780,7 @@ namespace ts.server { if (file.resolvedModules) { file.resolvedModules.forEach((resolvedModule, name) => { // pick unresolved non-relative names - if (!resolvedModule && !isExternalModuleNameRelative(name) && !isAmbientlyDeclaredModule(name)) { + if (!getResolvedModuleFromState(resolvedModule) && !isExternalModuleNameRelative(name) && !isAmbientlyDeclaredModule(name)) { // for non-scoped names extract part up-to the first slash // for scoped names - extract up to the second slash let trimmed = name.trim(); diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts index fcde80e81fbf0..af7be34f9f441 100644 --- a/src/services/codefixes/convertToEs6Module.ts +++ b/src/services/codefixes/convertToEs6Module.ts @@ -20,7 +20,7 @@ namespace ts.codefix { function fixImportOfModuleExports(importingFile: SourceFile, exportingFile: SourceFile, changes: textChanges.ChangeTracker) { for (const moduleSpecifier of importingFile.imports) { - const imported = getResolvedModule(importingFile, moduleSpecifier.text); + const imported = getResolvedModuleFromState(getResolvedModule(importingFile, moduleSpecifier.text)); if (!imported || imported.resolvedFileName !== exportingFile.fileName) { continue; } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 5368a36346b77..80b49efd8f582 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -325,8 +325,10 @@ namespace ts.codefix { */ function getAllModulePaths(program: Program, { fileName }: SourceFile): ReadonlyArray { const symlinks = mapDefined(program.getSourceFiles(), sf => - sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => - res && res.resolvedFileName === fileName ? res.originalPath : undefined)); + sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), state => { + const res = getResolvedModuleFromState(state); + return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + })); return symlinks.length === 0 ? [fileName] : symlinks; } diff --git a/src/services/services.ts b/src/services/services.ts index ed8e79a9069ee..51907d9cc7bb1 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -644,7 +644,7 @@ namespace ts { public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: UnderscoreEscapedMap; - public resolvedModules: Map; + public resolvedModules: Map; public resolvedTypeReferenceDirectiveNames: Map; public imports: StringLiteral[]; public moduleAugmentations: StringLiteral[]; diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 3de43d7d40f92..7223a446e8473 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -36,7 +36,7 @@ namespace ts { for (const importNode of sourceFile.imports) { const name = importNameForConvertToDefaultImport(importNode.parent); if (!name) continue; - const module = getResolvedModule(sourceFile, importNode.text); + const module = getResolvedModuleFromState(getResolvedModule(sourceFile, importNode.text)); const resolvedFile = module && program.getSourceFile(module.resolvedFileName); if (resolvedFile && resolvedFile.externalModuleIndicator && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) { diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import)); diff --git a/tests/baselines/reference/importTypeNested.errors.txt b/tests/baselines/reference/importTypeNested.errors.txt deleted file mode 100644 index cf30ccf797e6d..0000000000000 --- a/tests/baselines/reference/importTypeNested.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/types/import/chainer.ts(1,17): error TS2307: Cannot find module './b'. - - -==== tests/cases/conformance/types/import/a.d.ts (0 errors) ==== - export type LookAt = "./b"; -==== tests/cases/conformance/types/import/b.d.ts (0 errors) ==== - export type Value = "yes"; -==== tests/cases/conformance/types/import/chainer.ts (1 errors) ==== - export const x: import(import("./a").LookAt).Value = "yes"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module './b'. - \ No newline at end of file diff --git a/tests/baselines/reference/importTypeNested.types b/tests/baselines/reference/importTypeNested.types index 45bac0b37b0b0..f04cb4d92a723 100644 --- a/tests/baselines/reference/importTypeNested.types +++ b/tests/baselines/reference/importTypeNested.types @@ -8,7 +8,7 @@ export type Value = "yes"; === tests/cases/conformance/types/import/chainer.ts === export const x: import(import("./a").LookAt).Value = "yes"; ->x : any +>x : "yes" >LookAt : No type information available! >Value : No type information available! >"yes" : "yes" diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt index cacd821168cd8..5104e9dca5da4 100644 --- a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt @@ -1,18 +1,14 @@ tests/cases/compiler/x.ts(17,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. -tests/cases/compiler/x.ts(17,26): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(18,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. -tests/cases/compiler/x.ts(18,21): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(19,5): error TS2666: Exports and export assignments are not permitted in module augmentations. -tests/cases/compiler/x.ts(19,19): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(20,5): error TS2666: Exports and export assignments are not permitted in module augmentations. -tests/cases/compiler/x.ts(20,21): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(24,5): error TS2666: Exports and export assignments are not permitted in module augmentations. ==== tests/cases/compiler/x0.ts (0 errors) ==== export let a = 1; -==== tests/cases/compiler/x.ts (9 errors) ==== +==== tests/cases/compiler/x.ts (5 errors) ==== namespace N1 { export let x = 1; } @@ -32,23 +28,15 @@ tests/cases/compiler/x.ts(24,5): error TS2666: Exports and export assignments ar import * as all from "./x0"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. - ~~~~~~ -!!! error TS2307: Cannot find module './x0'. import {a} from "./x0"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. - ~~~~~~ -!!! error TS2307: Cannot find module './x0'. export * from "./x0"; ~~~~~~ !!! error TS2666: Exports and export assignments are not permitted in module augmentations. - ~~~~~~ -!!! error TS2307: Cannot find module './x0'. export {a} from "./x0"; ~~~~~~ !!! error TS2666: Exports and export assignments are not permitted in module augmentations. - ~~~~~~ -!!! error TS2307: Cannot find module './x0'. } declare module "./test" { diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types index ca439263aac0c..a179b0e06565b 100644 --- a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types @@ -61,14 +61,14 @@ declare module "./observable" { >T : number import * as all from "./x0"; ->all : any +>all : typeof all import {a} from "./x0"; ->a : any +>a : number export * from "./x0"; export {a} from "./x0"; ->a : any +>a : number } declare module "./test" { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt index 5f57081357e8a..12bc41512efb3 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt @@ -1,8 +1,6 @@ tests/cases/compiler/f3.ts(3,13): error TS2339: Property 'foo' does not exist on type 'A'. tests/cases/compiler/f3.ts(11,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. -tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'. tests/cases/compiler/f3.ts(12,5): error TS2666: Exports and export assignments are not permitted in module augmentations. -tests/cases/compiler/f3.ts(12,21): error TS2307: Cannot find module './f2'. tests/cases/compiler/f3.ts(13,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'I' is using private name 'N'. tests/cases/compiler/f3.ts(14,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. @@ -18,7 +16,7 @@ tests/cases/compiler/f4.ts(5,11): error TS2339: Property 'foo' does not exist on n: number; } -==== tests/cases/compiler/f3.ts (9 errors) ==== +==== tests/cases/compiler/f3.ts (7 errors) ==== import {A} from "./f1"; A.prototype.foo = function () { return undefined; } @@ -34,13 +32,9 @@ tests/cases/compiler/f4.ts(5,11): error TS2339: Property 'foo' does not exist on import {B} from "./f2"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. - ~~~~~~ -!!! error TS2307: Cannot find module './f2'. export {B} from "./f2"; ~~~~~~ !!! error TS2666: Exports and export assignments are not permitted in module augmentations. - ~~~~~~ -!!! error TS2307: Cannot find module './f2'. import I = N.Ifc; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.types b/tests/baselines/reference/moduleAugmentationImportsAndExports2.types index becef65c2fc48..22ae1b1e79fa9 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.types @@ -40,10 +40,10 @@ declare module "./f1" { >"./f1" : typeof "tests/cases/compiler/f1" import {B} from "./f2"; ->B : any +>B : typeof B export {B} from "./f2"; ->B : any +>B : typeof B import I = N.Ifc; >I : any @@ -60,8 +60,8 @@ declare module "./f1" { >A : A foo(): B; ->foo : () => any ->B : any +>foo : () => B +>B : B bar(): I; >bar : () => I diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt index 33732c0552f34..e386914992d31 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/f3.ts(11,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. -tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'. tests/cases/compiler/f3.ts(12,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. tests/cases/compiler/f3.ts(12,16): error TS4000: Import declaration 'I' is using private name 'N'. tests/cases/compiler/f3.ts(13,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. @@ -14,7 +13,7 @@ tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'C' is using n: number; } -==== tests/cases/compiler/f3.ts (6 errors) ==== +==== tests/cases/compiler/f3.ts (5 errors) ==== import {A} from "./f1"; A.prototype.foo = function () { return undefined; } @@ -28,8 +27,6 @@ tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'C' is using import {B} from "./f2"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. - ~~~~~~ -!!! error TS2307: Cannot find module './f2'. import I = N.Ifc; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols index f28f846de189a..3506042d8b291 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols @@ -79,7 +79,9 @@ let a: A; let b = a.foo().n; >b : Symbol(b, Decl(f4.ts, 4, 3)) +>a.foo().n : Symbol(B.n, Decl(f2.ts, 0, 16)) >a.foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) >a : Symbol(a, Decl(f4.ts, 3, 3)) >foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) +>n : Symbol(B.n, Decl(f2.ts, 0, 16)) diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types index ef956ef5e91f1..de54c32c22be1 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types @@ -16,11 +16,11 @@ import {A} from "./f1"; A.prototype.foo = function () { return undefined; } >A.prototype.foo = function () { return undefined; } : () => any ->A.prototype.foo : () => any +>A.prototype.foo : () => B >A.prototype : A >A : typeof A >prototype : A ->foo : () => any +>foo : () => B >function () { return undefined; } : () => any >undefined : undefined @@ -40,7 +40,7 @@ declare module "./f1" { >"./f1" : typeof "tests/cases/compiler/f1" import {B} from "./f2"; ->B : any +>B : typeof B import I = N.Ifc; >I : any @@ -56,8 +56,8 @@ declare module "./f1" { >A : A foo(): B; ->foo : () => any ->B : any +>foo : () => B +>B : B bar(): I; >bar : () => I @@ -80,11 +80,11 @@ let a: A; >A : A let b = a.foo().n; ->b : any ->a.foo().n : any ->a.foo() : any ->a.foo : () => any +>b : number +>a.foo().n : number +>a.foo() : B +>a.foo : () => B >a : A ->foo : () => any ->n : any +>foo : () => B +>n : number From 5d2715c9bca519b16e912360cf75900b0d6a604b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 14 Mar 2018 18:19:13 -0700 Subject: [PATCH 06/21] Add another test case --- .../reference/importTypeNestedNoRef.errors.txt | 12 ++++++++++++ .../baselines/reference/importTypeNestedNoRef.js | 16 ++++++++++++++++ .../reference/importTypeNestedNoRef.symbols | 8 ++++++++ .../reference/importTypeNestedNoRef.types | 11 +++++++++++ .../types/import/importTypeNestedNoRef.ts | 9 +++++++++ 5 files changed, 56 insertions(+) create mode 100644 tests/baselines/reference/importTypeNestedNoRef.errors.txt create mode 100644 tests/baselines/reference/importTypeNestedNoRef.js create mode 100644 tests/baselines/reference/importTypeNestedNoRef.symbols create mode 100644 tests/baselines/reference/importTypeNestedNoRef.types create mode 100644 tests/cases/conformance/types/import/importTypeNestedNoRef.ts diff --git a/tests/baselines/reference/importTypeNestedNoRef.errors.txt b/tests/baselines/reference/importTypeNestedNoRef.errors.txt new file mode 100644 index 0000000000000..51b03a4f7c47a --- /dev/null +++ b/tests/baselines/reference/importTypeNestedNoRef.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/types/import/chainer.ts(1,17): error TS2307: Cannot find module './b'. + + +==== tests/cases/conformance/types/import/chainer.ts (1 errors) ==== + export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './b'. + +==== tests/cases/conformance/types/import/a.d.ts (0 errors) ==== + export type LookAt = "./b"; +==== tests/cases/conformance/types/import/b.d.ts (0 errors) ==== + export type Value = "yes"; \ No newline at end of file diff --git a/tests/baselines/reference/importTypeNestedNoRef.js b/tests/baselines/reference/importTypeNestedNoRef.js new file mode 100644 index 0000000000000..2508c075430c5 --- /dev/null +++ b/tests/baselines/reference/importTypeNestedNoRef.js @@ -0,0 +1,16 @@ +//// [tests/cases/conformance/types/import/importTypeNestedNoRef.ts] //// + +//// [a.d.ts] +export type LookAt = "./b"; +//// [b.d.ts] +export type Value = "yes"; +//// [chainer.ts] +export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build + + +//// [chainer.js] +export const x = "yes"; // expect outter import to fail, since b.d.ts isn't in the build + + +//// [chainer.d.ts] +export declare const x: import(import("./a").LookAt).Value; diff --git a/tests/baselines/reference/importTypeNestedNoRef.symbols b/tests/baselines/reference/importTypeNestedNoRef.symbols new file mode 100644 index 0000000000000..832fbba020ba9 --- /dev/null +++ b/tests/baselines/reference/importTypeNestedNoRef.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/types/import/chainer.ts === +export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build +>x : Symbol(x, Decl(chainer.ts, 0, 12)) + +=== tests/cases/conformance/types/import/a.d.ts === +export type LookAt = "./b"; +>LookAt : Symbol(LookAt, Decl(a.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/importTypeNestedNoRef.types b/tests/baselines/reference/importTypeNestedNoRef.types new file mode 100644 index 0000000000000..899ebb198400f --- /dev/null +++ b/tests/baselines/reference/importTypeNestedNoRef.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/types/import/chainer.ts === +export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build +>x : any +>LookAt : No type information available! +>Value : No type information available! +>"yes" : "yes" + +=== tests/cases/conformance/types/import/a.d.ts === +export type LookAt = "./b"; +>LookAt : "./b" + diff --git a/tests/cases/conformance/types/import/importTypeNestedNoRef.ts b/tests/cases/conformance/types/import/importTypeNestedNoRef.ts new file mode 100644 index 0000000000000..512e3ad49c5ba --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeNestedNoRef.ts @@ -0,0 +1,9 @@ +// @declaration: true +// @target: es6 +// @noImplicitReferences: true +// @filename: a.d.ts +export type LookAt = "./b"; +// @filename: b.d.ts +export type Value = "yes"; +// @filename: chainer.ts +export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build From 79c472910ffd272738626a3f421d8a257e33d6c5 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 14 Mar 2018 18:32:55 -0700 Subject: [PATCH 07/21] Add some jsdoc usages --- .../baselines/reference/importTypeInJSDoc.js | 36 +++++++++ .../reference/importTypeInJSDoc.symbols | 66 ++++++++++++++++ .../reference/importTypeInJSDoc.types | 76 +++++++++++++++++++ .../types/import/importTypeInJSDoc.ts | 29 +++++++ 4 files changed, 207 insertions(+) create mode 100644 tests/baselines/reference/importTypeInJSDoc.js create mode 100644 tests/baselines/reference/importTypeInJSDoc.symbols create mode 100644 tests/baselines/reference/importTypeInJSDoc.types create mode 100644 tests/cases/conformance/types/import/importTypeInJSDoc.ts diff --git a/tests/baselines/reference/importTypeInJSDoc.js b/tests/baselines/reference/importTypeInJSDoc.js new file mode 100644 index 0000000000000..53a521c6062c2 --- /dev/null +++ b/tests/baselines/reference/importTypeInJSDoc.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/types/import/importTypeInJSDoc.ts] //// + +//// [externs.d.ts] +declare namespace MyClass { + export interface Bar { + doer: (x: string) => void; + } +} +declare class MyClass { + field: string; + static Bar: (x: string, y?: number) => void; + constructor(x: MyClass.Bar); +} +declare global { + const Foo: typeof MyClass; +} +export = MyClass; +//// [index.js] +/** + * @typedef {import("./externs")} Foo + */ + +let a = /** @type {Foo} */(/** @type {*} */(undefined)); +a = new Foo({doer: Foo.Bar}); +const q = /** @type {import("./externs").Bar} */({ doer: q => q }); +const r = /** @type {typeof import("./externs").Bar} */(r => r); + + +//// [index.js] +/** + * @typedef {import("./externs")} Foo + */ +let a = /** @type {Foo} */ ( /** @type {*} */(undefined)); +a = new Foo({ doer: Foo.Bar }); +const q = /** @type {import("./externs").Bar} */ ({ doer: q => q }); +const r = /** @type {typeof import("./externs").Bar} */ (r => r); diff --git a/tests/baselines/reference/importTypeInJSDoc.symbols b/tests/baselines/reference/importTypeInJSDoc.symbols new file mode 100644 index 0000000000000..d00eab51a1856 --- /dev/null +++ b/tests/baselines/reference/importTypeInJSDoc.symbols @@ -0,0 +1,66 @@ +=== tests/cases/conformance/types/import/externs.d.ts === +declare namespace MyClass { +>MyClass : Symbol(MyClass, Decl(externs.d.ts, 0, 0), Decl(externs.d.ts, 4, 1)) + + export interface Bar { +>Bar : Symbol(Bar, Decl(externs.d.ts, 0, 27), Decl(externs.d.ts, 6, 18)) + + doer: (x: string) => void; +>doer : Symbol(Bar.doer, Decl(externs.d.ts, 1, 26)) +>x : Symbol(x, Decl(externs.d.ts, 2, 15)) + } +} +declare class MyClass { +>MyClass : Symbol(MyClass, Decl(externs.d.ts, 0, 0), Decl(externs.d.ts, 4, 1)) + + field: string; +>field : Symbol(MyClass.field, Decl(externs.d.ts, 5, 23)) + + static Bar: (x: string, y?: number) => void; +>Bar : Symbol(MyClass.Bar, Decl(externs.d.ts, 0, 27), Decl(externs.d.ts, 6, 18)) +>x : Symbol(x, Decl(externs.d.ts, 7, 17)) +>y : Symbol(y, Decl(externs.d.ts, 7, 27)) + + constructor(x: MyClass.Bar); +>x : Symbol(x, Decl(externs.d.ts, 8, 16)) +>MyClass : Symbol(MyClass, Decl(externs.d.ts, 0, 0), Decl(externs.d.ts, 4, 1)) +>Bar : Symbol(MyClass.Bar, Decl(externs.d.ts, 0, 27), Decl(externs.d.ts, 6, 18)) +} +declare global { +>global : Symbol(global, Decl(externs.d.ts, 9, 1)) + + const Foo: typeof MyClass; +>Foo : Symbol(Foo, Decl(index.js, 1, 3), Decl(externs.d.ts, 11, 9)) +>MyClass : Symbol(MyClass, Decl(externs.d.ts, 0, 0), Decl(externs.d.ts, 4, 1)) +} +export = MyClass; +>MyClass : Symbol(MyClass, Decl(externs.d.ts, 0, 0), Decl(externs.d.ts, 4, 1)) + +=== tests/cases/conformance/types/import/index.js === +/** + * @typedef {import("./externs")} Foo + */ + +let a = /** @type {Foo} */(/** @type {*} */(undefined)); +>a : Symbol(a, Decl(index.js, 4, 3)) +>undefined : Symbol(undefined) + +a = new Foo({doer: Foo.Bar}); +>a : Symbol(a, Decl(index.js, 4, 3)) +>Foo : Symbol(Foo, Decl(index.js, 1, 3), Decl(externs.d.ts, 11, 9)) +>doer : Symbol(doer, Decl(index.js, 5, 13)) +>Foo.Bar : Symbol(MyClass.Bar, Decl(externs.d.ts, 0, 27), Decl(externs.d.ts, 6, 18)) +>Foo : Symbol(Foo, Decl(index.js, 1, 3), Decl(externs.d.ts, 11, 9)) +>Bar : Symbol(MyClass.Bar, Decl(externs.d.ts, 0, 27), Decl(externs.d.ts, 6, 18)) + +const q = /** @type {import("./externs").Bar} */({ doer: q => q }); +>q : Symbol(q, Decl(index.js, 6, 5)) +>doer : Symbol(doer, Decl(index.js, 6, 50)) +>q : Symbol(q, Decl(index.js, 6, 56)) +>q : Symbol(q, Decl(index.js, 6, 56)) + +const r = /** @type {typeof import("./externs").Bar} */(r => r); +>r : Symbol(r, Decl(index.js, 7, 5)) +>r : Symbol(r, Decl(index.js, 7, 56)) +>r : Symbol(r, Decl(index.js, 7, 56)) + diff --git a/tests/baselines/reference/importTypeInJSDoc.types b/tests/baselines/reference/importTypeInJSDoc.types new file mode 100644 index 0000000000000..d76f7aac6f614 --- /dev/null +++ b/tests/baselines/reference/importTypeInJSDoc.types @@ -0,0 +1,76 @@ +=== tests/cases/conformance/types/import/externs.d.ts === +declare namespace MyClass { +>MyClass : typeof MyClass + + export interface Bar { +>Bar : Bar + + doer: (x: string) => void; +>doer : (x: string) => void +>x : string + } +} +declare class MyClass { +>MyClass : MyClass + + field: string; +>field : string + + static Bar: (x: string, y?: number) => void; +>Bar : (x: string, y?: number) => void +>x : string +>y : number + + constructor(x: MyClass.Bar); +>x : MyClass.Bar +>MyClass : any +>Bar : MyClass.Bar +} +declare global { +>global : typeof global + + const Foo: typeof MyClass; +>Foo : typeof MyClass +>MyClass : typeof MyClass +} +export = MyClass; +>MyClass : MyClass + +=== tests/cases/conformance/types/import/index.js === +/** + * @typedef {import("./externs")} Foo + */ + +let a = /** @type {Foo} */(/** @type {*} */(undefined)); +>a : MyClass +>(/** @type {*} */(undefined)) : MyClass +>(undefined) : any +>undefined : undefined + +a = new Foo({doer: Foo.Bar}); +>a = new Foo({doer: Foo.Bar}) : MyClass +>a : MyClass +>new Foo({doer: Foo.Bar}) : MyClass +>Foo : typeof MyClass +>{doer: Foo.Bar} : { doer: (x: string, y?: number) => void; } +>doer : (x: string, y?: number) => void +>Foo.Bar : (x: string, y?: number) => void +>Foo : typeof MyClass +>Bar : (x: string, y?: number) => void + +const q = /** @type {import("./externs").Bar} */({ doer: q => q }); +>q : MyClass.Bar +>({ doer: q => q }) : MyClass.Bar +>{ doer: q => q } : { doer: (q: string) => string; } +>doer : (q: string) => string +>q => q : (q: string) => string +>q : string +>q : string + +const r = /** @type {typeof import("./externs").Bar} */(r => r); +>r : (x: string, y?: number) => void +>(r => r) : (x: string, y?: number) => void +>r => r : (r: string) => string +>r : string +>r : string + diff --git a/tests/cases/conformance/types/import/importTypeInJSDoc.ts b/tests/cases/conformance/types/import/importTypeInJSDoc.ts new file mode 100644 index 0000000000000..4e7de38a4201c --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeInJSDoc.ts @@ -0,0 +1,29 @@ +// @target: es6 +// @outDir: ./out +// @allowJs: true +// @checkJs: true +// @filename: externs.d.ts +declare namespace MyClass { + export interface Bar { + doer: (x: string) => void; + } +} +declare class MyClass { + field: string; + static Bar: (x: string, y?: number) => void; + constructor(x: MyClass.Bar); +} +declare global { + const Foo: typeof MyClass; +} +export = MyClass; +// @filename: index.js + +/** + * @typedef {import("./externs")} Foo + */ + +let a = /** @type {Foo} */(/** @type {*} */(undefined)); +a = new Foo({doer: Foo.Bar}); +const q = /** @type {import("./externs").Bar} */({ doer: q => q }); +const r = /** @type {typeof import("./externs").Bar} */(r => r); From 080ba6ff155152602d054f3f028dbe37765b2117 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 23 Mar 2018 14:19:24 -0700 Subject: [PATCH 08/21] Allow nodebuilder to use import types where appropriate --- src/compiler/checker.ts | 47 +++++++++++++++++++++++++++++++++-------- src/compiler/factory.ts | 10 +++++---- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a2f861eecbacd..1b7d6e9334477 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2953,7 +2953,7 @@ namespace ts { if (type.flags & TypeFlags.UniqueESSymbol) { if (!(context.flags & NodeBuilderFlags.AllowUniqueESSymbolType)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { - return createTypeQueryNode(symbolToName(type.symbol, context, SymbolFlags.Value, /*expectsIdentifier*/ false)); + return symbolToTypeNode(type.symbol, context, SymbolFlags.Value); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); @@ -3072,15 +3072,14 @@ namespace ts { if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === SyntaxKind.ClassExpression && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || shouldWriteTypeOfFunctionSymbol()) { - return createTypeQueryNodeFromSymbol(symbol, SymbolFlags.Value); + return symbolToTypeNode(symbol, context, SymbolFlags.Value); } else if (contains(context.symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - const entityName = symbolToName(typeAlias, context, SymbolFlags.Type, /*expectsIdentifier*/ false); - return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + return symbolToTypeNode(typeAlias, context, SymbolFlags.Type); } else { return createKeywordTypeNode(SyntaxKind.AnyKeyword); @@ -3158,11 +3157,6 @@ namespace ts { return setEmitFlags(typeLiteralNode, (context.flags & NodeBuilderFlags.MultilineObjectLiterals) ? 0 : EmitFlags.SingleLine); } - function createTypeQueryNodeFromSymbol(symbol: Symbol, symbolFlags: SymbolFlags) { - const entityName = symbolToName(symbol, context, symbolFlags, /*expectsIdentifier*/ false); - return createTypeQueryNode(entityName); - } - function symbolToTypeReferenceName(symbol: Symbol) { // Unnamed function expressions and arrow functions have reserved names that we don't want to display const entityName = symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false) : createIdentifier(""); @@ -3559,6 +3553,41 @@ namespace ts { return typeParameterNodes; } + function symbolToTypeNode(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags): TypeQueryNode | TypeReferenceNode | ImportTypeNode { + const chain = lookupSymbolChain(symbol, context, meaning); + + context.flags |= NodeBuilderFlags.InInitialEntityName; + const rootName = getNameOfSymbolAsWritten(chain[0], context); + context.flags ^= NodeBuilderFlags.InInitialEntityName; + + const isTypeOf = meaning === SymbolFlags.Value; + if (ambientModuleSymbolRegex.test(rootName)) { + // module is root, must use `ImportTypeNode` + const nonRootParts = chain.length > 1 ? createEntityNameFromSymbolChain(chain, chain.length - 1, 1) : undefined; + return createImportTypeNode(createLiteralTypeNode(createLiteral(rootName.substring(1, rootName.length - 1))), nonRootParts, isTypeOf); + } + + const entityName = createEntityNameFromSymbolChain(chain, chain.length - 1, 0); + return isTypeOf ? createTypeQueryNode(entityName) : createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + + function createEntityNameFromSymbolChain(chain: Symbol[], index: number, stopper: number): EntityName { + const typeParameterNodes = lookupTypeParameterNodes(chain, index, context); + const symbol = chain[index]; + + if (index === 0) { + context.flags |= NodeBuilderFlags.InInitialEntityName; + } + const symbolName = getNameOfSymbolAsWritten(symbol, context); + if (index === 0) { + context.flags ^= NodeBuilderFlags.InInitialEntityName; + } + const identifier = setEmitFlags(createIdentifier(symbolName, typeParameterNodes), EmitFlags.NoAsciiEscaping); + identifier.symbol = symbol; + + return index > stopper ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1, stopper), identifier) : identifier; + } + } + function symbolToName(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, expectsIdentifier: true): Identifier; function symbolToName(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, expectsIdentifier: false): EntityName; function symbolToName(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, expectsIdentifier: boolean): EntityName { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 4dbde40f5e73b..7e139ba34c407 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -802,17 +802,19 @@ namespace ts { : node; } - export function createImportTypeNode(argument: TypeNode, qualifier?: EntityName) { + export function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, isTypeOf?: boolean) { const node = createSynthesizedNode(SyntaxKind.ImportTypeNode); node.argument = argument; node.qualifier = qualifier; + node.isTypeOf = isTypeOf; return node; } - export function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName) { + export function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, isTypeOf?: boolean) { return node.argument !== argument - && node.qualifier !== qualifier - ? updateNode(createImportTypeNode(argument, qualifier), node) + || node.qualifier !== qualifier + || !!node.isTypeOf !== !!isTypeOf + ? updateNode(createImportTypeNode(argument, qualifier, isTypeOf), node) : node; } From 0be6ce479436a63a1c84ad1d47080da8cb4c3542 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 23 Mar 2018 15:22:48 -0700 Subject: [PATCH 09/21] Parse & check generic instantiations --- src/compiler/checker.ts | 42 +++-- src/compiler/factory.ts | 10 +- src/compiler/parser.ts | 4 +- src/compiler/types.ts | 12 +- src/compiler/visitor.ts | 5 +- .../reference/api/tsserverlibrary.d.ts | 15 +- tests/baselines/reference/api/typescript.d.ts | 15 +- .../reference/importTypeGenericTypes.js | 171 ++++++++++++++++++ .../reference/importTypeGenericTypes.symbols | 118 ++++++++++++ .../reference/importTypeGenericTypes.types | 131 ++++++++++++++ .../types/import/importTypeGenericTypes.ts | 45 +++++ 11 files changed, 532 insertions(+), 36 deletions(-) create mode 100644 tests/baselines/reference/importTypeGenericTypes.js create mode 100644 tests/baselines/reference/importTypeGenericTypes.symbols create mode 100644 tests/baselines/reference/importTypeGenericTypes.types create mode 100644 tests/cases/conformance/types/import/importTypeGenericTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b7d6e9334477..0737f030b0d84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3564,7 +3564,8 @@ namespace ts { if (ambientModuleSymbolRegex.test(rootName)) { // module is root, must use `ImportTypeNode` const nonRootParts = chain.length > 1 ? createEntityNameFromSymbolChain(chain, chain.length - 1, 1) : undefined; - return createImportTypeNode(createLiteralTypeNode(createLiteral(rootName.substring(1, rootName.length - 1))), nonRootParts, isTypeOf); + const typeParameterNodes = lookupTypeParameterNodes(chain, 0, context); + return createImportTypeNode(createLiteralTypeNode(createLiteral(rootName.substring(1, rootName.length - 1))), nonRootParts, typeParameterNodes as ReadonlyArray, isTypeOf); } const entityName = createEntityNameFromSymbolChain(chain, chain.length - 1, 0); @@ -7234,7 +7235,7 @@ namespace ts { /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node: TypeReferenceType, symbol: Symbol, typeArgs: Type[]): Type { + function getTypeFromClassOrInterfaceReference(node: NodeWithTypeArguments, symbol: Symbol, typeArgs: Type[]): Type { const type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); const typeParameters = type.localTypeParameters; if (typeParameters) { @@ -7284,7 +7285,7 @@ namespace ts { * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node: TypeReferenceType, symbol: Symbol, typeArguments: Type[]): Type { + function getTypeFromTypeAliasReference(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[]): Type { const type = getDeclaredTypeOfSymbol(symbol); const typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { @@ -7330,7 +7331,7 @@ namespace ts { return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; } - function getTypeReferenceType(node: TypeReferenceType, symbol: Symbol) { + function getTypeReferenceType(node: NodeWithTypeArguments, symbol: Symbol) { const typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return unknownType; @@ -7368,7 +7369,7 @@ namespace ts { return valueType; } - function getTypeReferenceTypeWorker(node: TypeReferenceType, symbol: Symbol, typeArguments: Type[]): Type | undefined { + function getTypeReferenceTypeWorker(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[]): Type | undefined { if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } @@ -7416,13 +7417,13 @@ namespace ts { return constraints ? getSubstitutionType(typeVariable, getIntersectionType(append(constraints, typeVariable))) : typeVariable; } - function isJSDocTypeReference(node: TypeReferenceType): node is TypeReferenceNode { + function isJSDocTypeReference(node: NodeWithTypeArguments): node is TypeReferenceNode { return node.flags & NodeFlags.JSDoc && node.kind === SyntaxKind.TypeReference; } - function checkNoTypeArguments(node: TypeReferenceType, symbol?: Symbol) { + function checkNoTypeArguments(node: NodeWithTypeArguments, symbol?: Symbol) { if (node.typeArguments) { - error(node, Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : declarationNameToString((node).typeName)); + error(node, Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : (node).typeName ? declarationNameToString((node).typeName) : "(anonymous)"); return false; } return true; @@ -7503,7 +7504,7 @@ namespace ts { return links.resolvedType; } - function typeArgumentsFromTypeReferenceNode(node: TypeReferenceType): Type[] { + function typeArgumentsFromTypeReferenceNode(node: NodeWithTypeArguments): Type[] { return map(node.typeArguments, getTypeFromTypeNode); } @@ -8451,22 +8452,30 @@ namespace ts { function getTypeFromImportTypeNode(node: ImportTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { + if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments + error(node, Diagnostics.type_arguments_can_only_be_used_in_a_ts_file); + links.resolvedSymbol = unknownSymbol; + return links.resolvedType = anyType; + } const argumentType = getTypeFromTypeNode(node.argument); const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; // TODO: Future work: support unions/generics/whatever via a deferred import-type if (!argumentType || !(argumentType.flags & TypeFlags.StringLiteral)) { error(node.argument, Diagnostics.Import_specifier_must_be_a_string_literal_type_but_here_is_0, argumentType ? typeToString(argumentType) : "undefined"); + links.resolvedSymbol = unknownSymbol; return links.resolvedType = anyType; } const moduleName = (argumentType as StringLiteralType).value; const innerModuleSymbol = resolveExternalModule(node, moduleName, Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); if (!innerModuleSymbol) { error(node, Diagnostics.Cannot_find_module_0, moduleName); + links.resolvedSymbol = unknownSymbol; return links.resolvedType = anyType; } const moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!moduleSymbol) { error(node, Diagnostics.Cannot_find_module_0, moduleName); + links.resolvedSymbol = unknownSymbol; return links.resolvedType = anyType; } if (node.qualifier) { @@ -8492,14 +8501,15 @@ namespace ts { } currentNamespace = next; } - links.resolvedType = targetMeaning === SymbolFlags.Value ? getTypeOfSymbol(currentNamespace) : getDeclaredTypeOfSymbol(currentNamespace); + resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - links.resolvedType = targetMeaning === SymbolFlags.Value ? getTypeOfSymbol(moduleSymbol) : getDeclaredTypeOfSymbol(moduleSymbol); + resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { error(node, targetMeaning === SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + links.resolvedSymbol = unknownSymbol; links.resolvedType = anyType; } } @@ -8507,6 +8517,16 @@ namespace ts { return links.resolvedType; } + function resolveImportSymbolType(node: ImportTypeNode, links: NodeLinks, symbol: Symbol, meaning: SymbolFlags) { + links.resolvedSymbol = symbol; + if (meaning === SymbolFlags.Value) { + return links.resolvedType = getTypeOfSymbol(symbol); + } + else { + return links.resolvedType = getTypeReferenceType(node, symbol); + } + } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node: TypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 7e139ba34c407..4ba0b44a057c6 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -802,19 +802,21 @@ namespace ts { : node; } - export function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, isTypeOf?: boolean) { + export function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean) { const node = createSynthesizedNode(SyntaxKind.ImportTypeNode); node.argument = argument; node.qualifier = qualifier; + node.typeArguments = asNodeArray(typeArguments); node.isTypeOf = isTypeOf; return node; } - export function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, isTypeOf?: boolean) { + export function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean) { return node.argument !== argument || node.qualifier !== qualifier - || !!node.isTypeOf !== !!isTypeOf - ? updateNode(createImportTypeNode(argument, qualifier, isTypeOf), node) + || node.typeArguments !== typeArguments + || node.isTypeOf !== isTypeOf + ? updateNode(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node) : node; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 803d2a4deb797..75da40c4d0f20 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -191,7 +191,8 @@ namespace ts { return visitNode(cbNode, (node).typeParameter); case SyntaxKind.ImportTypeNode: return visitNode(cbNode, (node).argument) || - visitNode(cbNode, (node).qualifier); + visitNode(cbNode, (node).qualifier) || + visitNodes(cbNode, cbNodes, (node).typeArguments); case SyntaxKind.ParenthesizedType: case SyntaxKind.TypeOperator: return visitNode(cbNode, (node).type); @@ -2754,6 +2755,7 @@ namespace ts { if (parseOptional(SyntaxKind.DotToken)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected); } + node.typeArguments = tryParseTypeArguments(); return finishNode(node); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5faaed3991218..96498320e0e98 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1067,7 +1067,7 @@ namespace ts { | SyntaxKind.NeverKeyword; } - export interface ImportTypeNode extends TypeNode { + export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportTypeNode; isTypeOf?: boolean; argument: TypeNode; @@ -1091,12 +1091,15 @@ namespace ts { kind: SyntaxKind.ConstructorType; } + export interface NodeWithTypeArguments extends TypeNode { + typeArguments?: NodeArray; + } + export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - export interface TypeReferenceNode extends TypeNode { + export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; - typeArguments?: NodeArray; } export interface TypePredicateNode extends TypeNode { @@ -1706,11 +1709,10 @@ namespace ts { expression: ImportExpression; } - export interface ExpressionWithTypeArguments extends TypeNode { + export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent?: HeritageClause; expression: LeftHandSideExpression; - typeArguments?: NodeArray; } export interface NewExpression extends PrimaryExpression, Declaration { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index e45d38140c5af..2835a102ce458 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -401,7 +401,10 @@ namespace ts { case SyntaxKind.ImportTypeNode: return updateImportTypeNode(node, visitNode((node).argument, visitor, isTypeNode), - visitNode((node).qualifier, visitor, isEntityName)); + visitNode((node).qualifier, visitor, isEntityName), + visitNodes((node).typeArguments, visitor, isTypeNode), + (node).isTypeOf + ); case SyntaxKind.ParenthesizedType: return updateParenthesizedType(node, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index dbdd50ab43c97..744dde9ad3db4 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -698,7 +698,7 @@ declare namespace ts { interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } - interface ImportTypeNode extends TypeNode { + interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportTypeNode; isTypeOf?: boolean; argument: TypeNode; @@ -714,11 +714,13 @@ declare namespace ts { interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } + interface NodeWithTypeArguments extends TypeNode { + typeArguments?: NodeArray; + } type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends TypeNode { + interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; - typeArguments?: NodeArray; } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; @@ -1034,11 +1036,10 @@ declare namespace ts { interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends TypeNode { + interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent?: HeritageClause; expression: LeftHandSideExpression; - typeArguments?: NodeArray; } interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; @@ -3518,8 +3519,8 @@ declare namespace ts { function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 32319d82f75b6..95fa5421a7f3e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -698,7 +698,7 @@ declare namespace ts { interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } - interface ImportTypeNode extends TypeNode { + interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportTypeNode; isTypeOf?: boolean; argument: TypeNode; @@ -714,11 +714,13 @@ declare namespace ts { interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } + interface NodeWithTypeArguments extends TypeNode { + typeArguments?: NodeArray; + } type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends TypeNode { + interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; - typeArguments?: NodeArray; } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; @@ -1034,11 +1036,10 @@ declare namespace ts { interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends TypeNode { + interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent?: HeritageClause; expression: LeftHandSideExpression; - typeArguments?: NodeArray; } interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; @@ -3465,8 +3466,8 @@ declare namespace ts { function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; diff --git a/tests/baselines/reference/importTypeGenericTypes.js b/tests/baselines/reference/importTypeGenericTypes.js new file mode 100644 index 0000000000000..5222f7ff678bd --- /dev/null +++ b/tests/baselines/reference/importTypeGenericTypes.js @@ -0,0 +1,171 @@ +//// [tests/cases/conformance/types/import/importTypeGenericTypes.ts] //// + +//// [foo.ts] +interface Point { + x: number; + y: number; + data: T; +} +export = Point; + +//// [foo2.ts] +namespace Bar { + export interface I { + a: string; + b: number; + data: T; + } +} + +export namespace Baz { + export interface J { + a: number; + b: string; + data: T; + } +} + +class Bar { + item: Bar.I; + constructor(input: Baz.J) {} +} +export { Bar } + +//// [usage.ts] +export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} }; +export let y: import("./foo2").Bar.I<{x: number}> = { a: "", b: 0, data: {x: 12} }; + +export class Bar2 { + item: {a: string, b: number, c: object, data: T}; + constructor(input?: any) {} +} + +export let shim: typeof import("./foo2") = { + Bar: Bar2 +}; + + +//// [foo.js] +"use strict"; +exports.__esModule = true; +//// [foo2.js] +"use strict"; +exports.__esModule = true; +var Bar = /** @class */ (function () { + function Bar(input) { + } + return Bar; +}()); +exports.Bar = Bar; +//// [usage.js] +"use strict"; +exports.__esModule = true; +exports.x = { x: 0, y: 0, data: { x: 12 } }; +exports.y = { a: "", b: 0, data: { x: 12 } }; +var Bar2 = /** @class */ (function () { + function Bar2(input) { + } + return Bar2; +}()); +exports.Bar2 = Bar2; +exports.shim = { + Bar: Bar2 +}; + + +//// [foo.d.ts] +interface Point { + x: number; + y: number; + data: T; +} +export = Point; +//// [foo2.d.ts] +declare namespace Bar { + interface I { + a: string; + b: number; + data: T; + } +} +export declare namespace Baz { + interface J { + a: number; + b: string; + data: T; + } +} +declare class Bar { + item: Bar.I; + constructor(input: Baz.J); +} +export { Bar }; +//// [usage.d.ts] +export declare const x: import("./foo"); +export declare let y: import("./foo2").Bar.I; +export declare class Bar2 { + item: { + a: string; + b: number; + c: object; + data: T; + }; + constructor(input?: any); +} +export declare let shim: typeof import("./foo2"); + + +//// [DtsFileErrors] + + +tests/cases/conformance/types/import/usage.d.ts(1,25): error TS2314: Generic type 'Point' requires 1 type argument(s). +tests/cases/conformance/types/import/usage.d.ts(2,23): error TS2314: Generic type 'I' requires 1 type argument(s). + + +==== tests/cases/conformance/types/import/foo.d.ts (0 errors) ==== + interface Point { + x: number; + y: number; + data: T; + } + export = Point; + +==== tests/cases/conformance/types/import/foo2.d.ts (0 errors) ==== + declare namespace Bar { + interface I { + a: string; + b: number; + data: T; + } + } + export declare namespace Baz { + interface J { + a: number; + b: string; + data: T; + } + } + declare class Bar { + item: Bar.I; + constructor(input: Baz.J); + } + export { Bar }; + +==== tests/cases/conformance/types/import/usage.d.ts (2 errors) ==== + export declare const x: import("./foo"); + ~~~~~~~~~~~~~~~ +!!! error TS2314: Generic type 'Point' requires 1 type argument(s). + export declare let y: import("./foo2").Bar.I; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2314: Generic type 'I' requires 1 type argument(s). + export declare class Bar2 { + item: { + a: string; + b: number; + c: object; + data: T; + }; + constructor(input?: any); + } + export declare let shim: typeof import("./foo2"); + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeGenericTypes.symbols b/tests/baselines/reference/importTypeGenericTypes.symbols new file mode 100644 index 0000000000000..1413fc64bc069 --- /dev/null +++ b/tests/baselines/reference/importTypeGenericTypes.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/types/import/foo.ts === +interface Point { +>Point : Symbol(Point, Decl(foo.ts, 0, 0)) +>T : Symbol(T, Decl(foo.ts, 0, 16)) + + x: number; +>x : Symbol(Point.x, Decl(foo.ts, 0, 20)) + + y: number; +>y : Symbol(Point.y, Decl(foo.ts, 1, 14)) + + data: T; +>data : Symbol(Point.data, Decl(foo.ts, 2, 14)) +>T : Symbol(T, Decl(foo.ts, 0, 16)) +} +export = Point; +>Point : Symbol(Point, Decl(foo.ts, 0, 0)) + +=== tests/cases/conformance/types/import/foo2.ts === +namespace Bar { +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 14, 1)) + + export interface I { +>I : Symbol(I, Decl(foo2.ts, 0, 15)) +>T : Symbol(T, Decl(foo2.ts, 1, 23)) + + a: string; +>a : Symbol(I.a, Decl(foo2.ts, 1, 27)) + + b: number; +>b : Symbol(I.b, Decl(foo2.ts, 2, 18)) + + data: T; +>data : Symbol(I.data, Decl(foo2.ts, 3, 18)) +>T : Symbol(T, Decl(foo2.ts, 1, 23)) + } +} + +export namespace Baz { +>Baz : Symbol(Baz, Decl(foo2.ts, 6, 1)) + + export interface J { +>J : Symbol(J, Decl(foo2.ts, 8, 22)) +>T : Symbol(T, Decl(foo2.ts, 9, 23)) + + a: number; +>a : Symbol(J.a, Decl(foo2.ts, 9, 27)) + + b: string; +>b : Symbol(J.b, Decl(foo2.ts, 10, 18)) + + data: T; +>data : Symbol(J.data, Decl(foo2.ts, 11, 18)) +>T : Symbol(T, Decl(foo2.ts, 9, 23)) + } +} + +class Bar { +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 14, 1)) +>T : Symbol(T, Decl(foo2.ts, 16, 10)) + + item: Bar.I; +>item : Symbol(Bar.item, Decl(foo2.ts, 16, 14)) +>Bar : Symbol(Bar, Decl(foo2.ts, 0, 0), Decl(foo2.ts, 14, 1)) +>I : Symbol(Bar.I, Decl(foo2.ts, 0, 15)) +>T : Symbol(T, Decl(foo2.ts, 16, 10)) + + constructor(input: Baz.J) {} +>input : Symbol(input, Decl(foo2.ts, 18, 16)) +>Baz : Symbol(Baz, Decl(foo2.ts, 6, 1)) +>J : Symbol(Baz.J, Decl(foo2.ts, 8, 22)) +>T : Symbol(T, Decl(foo2.ts, 16, 10)) +} +export { Bar } +>Bar : Symbol(Bar, Decl(foo2.ts, 20, 8)) + +=== tests/cases/conformance/types/import/usage.ts === +export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} }; +>x : Symbol(x, Decl(usage.ts, 0, 12)) +>x : Symbol(x, Decl(usage.ts, 0, 33)) +>x : Symbol(x, Decl(usage.ts, 0, 48)) +>y : Symbol(y, Decl(usage.ts, 0, 54)) +>data : Symbol(data, Decl(usage.ts, 0, 60)) +>x : Symbol(x, Decl(usage.ts, 0, 68)) + +export let y: import("./foo2").Bar.I<{x: number}> = { a: "", b: 0, data: {x: 12} }; +>y : Symbol(y, Decl(usage.ts, 1, 10)) +>x : Symbol(x, Decl(usage.ts, 1, 38)) +>a : Symbol(a, Decl(usage.ts, 1, 53)) +>b : Symbol(b, Decl(usage.ts, 1, 60)) +>data : Symbol(data, Decl(usage.ts, 1, 66)) +>x : Symbol(x, Decl(usage.ts, 1, 74)) + +export class Bar2 { +>Bar2 : Symbol(Bar2, Decl(usage.ts, 1, 83)) +>T : Symbol(T, Decl(usage.ts, 3, 18)) + + item: {a: string, b: number, c: object, data: T}; +>item : Symbol(Bar2.item, Decl(usage.ts, 3, 22)) +>a : Symbol(a, Decl(usage.ts, 4, 11)) +>b : Symbol(b, Decl(usage.ts, 4, 21)) +>c : Symbol(c, Decl(usage.ts, 4, 32)) +>data : Symbol(data, Decl(usage.ts, 4, 43)) +>T : Symbol(T, Decl(usage.ts, 3, 18)) + + constructor(input?: any) {} +>input : Symbol(input, Decl(usage.ts, 5, 16)) +} + +export let shim: typeof import("./foo2") = { +>shim : Symbol(shim, Decl(usage.ts, 8, 10)) + + Bar: Bar2 +>Bar : Symbol(Bar, Decl(usage.ts, 8, 44)) +>Bar2 : Symbol(Bar2, Decl(usage.ts, 1, 83)) + +}; + diff --git a/tests/baselines/reference/importTypeGenericTypes.types b/tests/baselines/reference/importTypeGenericTypes.types new file mode 100644 index 0000000000000..6eb17e2a183c5 --- /dev/null +++ b/tests/baselines/reference/importTypeGenericTypes.types @@ -0,0 +1,131 @@ +=== tests/cases/conformance/types/import/foo.ts === +interface Point { +>Point : Point +>T : T + + x: number; +>x : number + + y: number; +>y : number + + data: T; +>data : T +>T : T +} +export = Point; +>Point : Point + +=== tests/cases/conformance/types/import/foo2.ts === +namespace Bar { +>Bar : typeof Bar + + export interface I { +>I : I +>T : T + + a: string; +>a : string + + b: number; +>b : number + + data: T; +>data : T +>T : T + } +} + +export namespace Baz { +>Baz : any + + export interface J { +>J : J +>T : T + + a: number; +>a : number + + b: string; +>b : string + + data: T; +>data : T +>T : T + } +} + +class Bar { +>Bar : Bar +>T : T + + item: Bar.I; +>item : Bar.I +>Bar : any +>I : Bar.I +>T : T + + constructor(input: Baz.J) {} +>input : Baz.J +>Baz : any +>J : Baz.J +>T : T +} +export { Bar } +>Bar : typeof Bar + +=== tests/cases/conformance/types/import/usage.ts === +export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} }; +>x : Point<{ x: number; }> +>x : number +>{ x: 0, y: 0, data: {x: 12} } : { x: number; y: number; data: { x: number; }; } +>x : number +>0 : 0 +>y : number +>0 : 0 +>data : { x: number; } +>{x: 12} : { x: number; } +>x : number +>12 : 12 + +export let y: import("./foo2").Bar.I<{x: number}> = { a: "", b: 0, data: {x: 12} }; +>y : Bar.I<{ x: number; }> +>Bar : any +>I : No type information available! +>x : number +>{ a: "", b: 0, data: {x: 12} } : { a: string; b: number; data: { x: number; }; } +>a : string +>"" : "" +>b : number +>0 : 0 +>data : { x: number; } +>{x: 12} : { x: number; } +>x : number +>12 : 12 + +export class Bar2 { +>Bar2 : Bar2 +>T : T + + item: {a: string, b: number, c: object, data: T}; +>item : { a: string; b: number; c: object; data: T; } +>a : string +>b : number +>c : object +>data : T +>T : T + + constructor(input?: any) {} +>input : any +} + +export let shim: typeof import("./foo2") = { +>shim : typeof import("tests/cases/conformance/types/import/foo2") +>{ Bar: Bar2} : { Bar: typeof Bar2; } + + Bar: Bar2 +>Bar : typeof Bar2 +>Bar2 : typeof Bar2 + +}; + diff --git a/tests/cases/conformance/types/import/importTypeGenericTypes.ts b/tests/cases/conformance/types/import/importTypeGenericTypes.ts new file mode 100644 index 0000000000000..5bc3aa7802087 --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeGenericTypes.ts @@ -0,0 +1,45 @@ +// @declaration: true +// @lib: es6 +// @filename: foo.ts +interface Point { + x: number; + y: number; + data: T; +} +export = Point; + +// @filename: foo2.ts +namespace Bar { + export interface I { + a: string; + b: number; + data: T; + } +} + +export namespace Baz { + export interface J { + a: number; + b: string; + data: T; + } +} + +class Bar { + item: Bar.I; + constructor(input: Baz.J) {} +} +export { Bar } + +// @filename: usage.ts +export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} }; +export let y: import("./foo2").Bar.I<{x: number}> = { a: "", b: 0, data: {x: 12} }; + +export class Bar2 { + item: {a: string, b: number, c: object, data: T}; + constructor(input?: any) {} +} + +export let shim: typeof import("./foo2") = { + Bar: Bar2 +}; From 73075dd5d0624dbf569039cceba12a8d68e59ff1 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 23 Mar 2018 15:24:20 -0700 Subject: [PATCH 10/21] use import types in nodebuilder for typeof module symbols --- src/compiler/checker.ts | 2 +- .../reference/aliasAssignments.errors.txt | 8 +-- .../aliasOnMergedModuleInterface.types | 2 +- .../allowSyntheticDefaultImports10.errors.txt | 8 +-- .../ambientDeclarationsPatterns.types | 8 +-- ...eclarationsPatterns_tooManyAsterisks.types | 2 +- .../ambientExportDefaultErrors.types | 6 +- ...xternalModuleInAnotherExternalModule.types | 2 +- ...mbientExternalModuleInsideNonAmbient.types | 2 +- .../ambientExternalModuleMerging.types | 4 +- .../ambientExternalModuleReopen.types | 4 +- ...ithRelativeExternalImportDeclaration.types | 2 +- ...ExternalModuleWithRelativeModuleName.types | 4 +- .../reference/ambientRequireFunction.types | 8 +-- .../reference/augmentExportEquals1_1.types | 2 +- .../reference/augmentExportEquals2_1.types | 2 +- .../reference/augmentExportEquals3_1.types | 2 +- .../reference/augmentExportEquals4_1.types | 2 +- .../reference/augmentExportEquals5.types | 2 +- .../reference/augmentExportEquals6_1.types | 2 +- .../reference/augmentExportEquals7.types | 2 +- .../reference/bangInModuleName.types | 2 +- .../reference/commonJsUnusedLocals.types | 2 +- .../reference/commonSourceDirectory.types | 2 +- .../reference/commonjsAccessExports.types | 8 +-- .../complexRecursiveCollections.types | 2 +- ...structorWithIncompleteTypeAnnotation.types | 2 +- .../reference/cyclicModuleImport.types | 4 +- .../declFileAliasUseBeforeDeclaration2.types | 2 +- ...ternalModuleWithSingleExportedModule.types | 2 +- .../declarationEmitRelativeModuleError.types | 4 +- .../reference/declarationMerging2.types | 2 +- ...ernalModuleWithExportAssignedFundule.types | 2 +- .../es5ExportDefaultClassDeclaration4.types | 2 +- ...es5ExportDefaultFunctionDeclaration4.types | 2 +- .../reference/es6ExportAssignment4.types | 2 +- .../reference/es6ExportEqualsInterop.types | 20 +++---- .../es6ImportEqualsDeclaration2.types | 4 +- .../reference/exportAsNamespace.d.types | 2 +- ...portDeclarationsInAmbientNamespaces2.types | 2 +- .../reference/exportDefaultProperty.types | 4 +- .../reference/exportEqualsProperty.types | 4 +- .../reference/exportNestedNamespaces.types | 6 +- .../exportNestedNamespaces2.errors.txt | 8 +-- .../reference/exportNestedNamespaces2.types | 14 ++--- ...pecifierAndExportedMemberDeclaration.types | 4 +- ...rtSpecifierAndLocalMemberDeclaration.types | 4 +- ...pecifierReferencingOuterDeclaration1.types | 2 +- ...pecifierReferencingOuterDeclaration3.types | 2 +- .../reference/exportsInAmbientModules1.types | 2 +- .../reference/exportsInAmbientModules2.types | 2 +- ...ionsForbiddenInParameterInitializers.types | 8 +-- ...externalModuleImmutableBindings.errors.txt | 24 ++++---- ...olutionOrderInImportDeclaration.errors.txt | 4 +- ...ceResolutionOrderInImportDeclaration.types | 2 +- .../reference/importAsBaseClass.errors.txt | 4 +- .../importCallExpression1ESNext.types | 26 ++++---- .../importCallExpression2ESNext.types | 2 +- .../importCallExpression3ESNext.types | 6 +- .../importCallExpression4ESNext.types | 30 +++++----- .../importCallExpressionAsyncES3AMD.types | 30 +++++----- .../importCallExpressionAsyncES3CJS.types | 30 +++++----- .../importCallExpressionAsyncES3System.types | 30 +++++----- .../importCallExpressionAsyncES3UMD.types | 30 +++++----- .../importCallExpressionAsyncES5AMD.types | 30 +++++----- .../importCallExpressionAsyncES5CJS.types | 30 +++++----- .../importCallExpressionAsyncES5System.types | 30 +++++----- .../importCallExpressionAsyncES5UMD.types | 30 +++++----- .../importCallExpressionAsyncES6AMD.types | 30 +++++----- .../importCallExpressionAsyncES6CJS.types | 30 +++++----- .../importCallExpressionAsyncES6System.types | 30 +++++----- .../importCallExpressionAsyncES6UMD.types | 30 +++++----- .../importCallExpressionAsyncESNext.types | 30 +++++----- ...tCallExpressionCheckReturntype1.errors.txt | 24 ++++---- ...importCallExpressionDeclarationEmit2.types | 4 +- .../importCallExpressionES5AMD.types | 34 +++++------ .../importCallExpressionES5CJS.types | 34 +++++------ .../importCallExpressionES5System.types | 34 +++++------ .../importCallExpressionES5UMD.types | 34 +++++------ .../importCallExpressionES6AMD.types | 34 +++++------ .../importCallExpressionES6CJS.types | 34 +++++------ .../importCallExpressionES6System.types | 34 +++++------ .../importCallExpressionES6UMD.types | 34 +++++------ .../importCallExpressionErrorInES2015.types | 22 +++---- .../importCallExpressionInAMD1.types | 26 ++++---- .../importCallExpressionInAMD2.types | 2 +- .../importCallExpressionInAMD3.types | 6 +- .../importCallExpressionInAMD4.types | 60 +++++++++---------- .../importCallExpressionInCJS1.types | 26 ++++---- .../importCallExpressionInCJS2.types | 8 +-- .../importCallExpressionInCJS3.types | 2 +- .../importCallExpressionInCJS4.types | 6 +- .../importCallExpressionInCJS5.types | 60 +++++++++---------- ...importCallExpressionInScriptContext1.types | 4 +- ...importCallExpressionInScriptContext2.types | 4 +- .../importCallExpressionInSystem1.types | 26 ++++---- .../importCallExpressionInSystem2.types | 2 +- .../importCallExpressionInSystem3.types | 6 +- .../importCallExpressionInSystem4.types | 60 +++++++++---------- .../importCallExpressionInUMD1.types | 26 ++++---- .../importCallExpressionInUMD2.types | 2 +- .../importCallExpressionInUMD3.types | 6 +- .../importCallExpressionInUMD4.types | 60 +++++++++---------- .../importCallExpressionNestedAMD.types | 6 +- .../importCallExpressionNestedAMD2.types | 6 +- .../importCallExpressionNestedCJS.types | 6 +- .../importCallExpressionNestedCJS2.types | 6 +- .../importCallExpressionNestedES2015.types | 6 +- .../importCallExpressionNestedES20152.types | 6 +- .../importCallExpressionNestedESNext.types | 6 +- .../importCallExpressionNestedESNext2.types | 6 +- .../importCallExpressionNestedSystem.types | 6 +- .../importCallExpressionNestedSystem2.types | 6 +- .../importCallExpressionNestedUMD.types | 6 +- .../importCallExpressionNestedUMD2.types | 6 +- ...tCallExpressionNoModuleKindSpecified.types | 30 +++++----- ...importCallExpressionWithTypeArgument.types | 8 +-- ...lWithDeclareModifierInAmbientContext.types | 2 +- ...rAndExportAssignmentInAmbientContext.types | 2 +- ...clWithExportModifierInAmbientContext.types | 2 +- ...rtShouldNotBeElidedInDeclarationEmit.types | 2 +- .../reference/importTsBeforeDTs.errors.txt | 4 +- .../reference/importTypeAmbient.types | 6 +- .../reference/importTypeAmbientMissing.types | 2 +- .../baselines/reference/importTypeLocal.types | 2 +- ...ferenecing-aliased-type-throug-array.types | 2 +- .../reference/importsInAmbientModules1.types | 2 +- .../reference/importsInAmbientModules2.types | 2 +- .../reference/importsInAmbientModules3.types | 2 +- .../reference/incompatibleExports1.types | 4 +- .../reference/incompatibleExports2.types | 2 +- ...sFileCompilationExternalPackageError.types | 2 +- .../reference/jsxImportInAttribute.types | 2 +- .../baselines/reference/jsxViaImport.2.types | 2 +- tests/baselines/reference/jsxViaImport.types | 2 +- ...NodeModuleJsDepthDefaultsToZero.errors.txt | 4 +- .../maxNodeModuleJsDepthDefaultsToZero.types | 2 +- .../reference/mergedDeclarations6.types | 2 +- .../missingFunctionImplementation2.types | 2 +- .../missingImportAfterModuleImport.types | 2 +- ...ntationCollidingNamesInAugmentation1.types | 4 +- .../moduleAugmentationDeclarationEmit1.types | 2 +- .../moduleAugmentationDeclarationEmit2.types | 2 +- ...duleAugmentationDisallowedExtensions.types | 4 +- ...duleAugmentationExtendAmbientModule1.types | 4 +- ...duleAugmentationExtendAmbientModule2.types | 4 +- .../moduleAugmentationExtendFileModule1.types | 2 +- .../moduleAugmentationExtendFileModule2.types | 2 +- .../reference/moduleAugmentationGlobal5.types | 4 +- ...moduleAugmentationImportsAndExports1.types | 2 +- ...moduleAugmentationImportsAndExports2.types | 2 +- ...moduleAugmentationImportsAndExports3.types | 2 +- ...moduleAugmentationImportsAndExports4.types | 2 +- ...moduleAugmentationImportsAndExports5.types | 2 +- ...moduleAugmentationImportsAndExports6.types | 2 +- .../moduleAugmentationInAmbientModule1.types | 8 +-- .../moduleAugmentationInAmbientModule2.types | 8 +-- .../moduleAugmentationInAmbientModule3.types | 12 ++-- .../moduleAugmentationInAmbientModule4.types | 12 ++-- .../moduleAugmentationInAmbientModule5.types | 4 +- .../moduleAugmentationNoNewNames.types | 2 +- .../moduleAugmentationsBundledOutput1.types | 8 +-- .../moduleAugmentationsImports1.types | 6 +- .../moduleAugmentationsImports2.types | 6 +- .../moduleAugmentationsImports3.types | 8 +-- .../moduleAugmentationsImports4.types | 10 ++-- .../moduleElementsInWrongContext2.types | 2 +- .../moduleElementsInWrongContext3.types | 2 +- .../reference/moduleExportAlias.types | 36 +++++------ .../reference/moduleMergeConstructor.types | 4 +- ...ionWithExtensions_withAmbientPresent.types | 2 +- ...Resolution_explicitNodeModulesImport.types | 2 +- .../module_augmentUninstantiatedModule.types | 4 +- tests/baselines/reference/moduledecl.types | 2 +- ...xportAssignmentsInAmbientDeclaration.types | 2 +- .../baselines/reference/nodeResolution5.types | 2 +- .../baselines/reference/nodeResolution7.types | 2 +- .../reference/paramTagOnCallExpression.types | 2 +- .../reference/parserExportAssignment6.types | 2 +- .../parserModuleDeclaration1.d.types | 2 +- .../reference/parserModuleDeclaration1.types | 2 +- .../reference/parserModuleDeclaration2.types | 2 +- .../privacyCannotNameAccessorDeclFile.types | 2 +- .../privacyCannotNameVarTypeDeclFile.types | 2 +- ...ctionCannotNameParameterTypeDeclFile.types | 2 +- ...FunctionCannotNameReturnTypeDeclFile.types | 2 +- .../reference/privacyGloImport.types | 6 +- .../privacyGloImportParseErrors.types | 14 ++--- .../reference/privacyImportParseErrors.types | 28 ++++----- .../reactNamespaceImportPresevation.types | 2 +- ...eExportAssignmentAndFindAliasedType1.types | 2 +- ...eExportAssignmentAndFindAliasedType2.types | 4 +- ...eExportAssignmentAndFindAliasedType3.types | 6 +- ...oduleNameWithSameLetDeclarationName2.types | 2 +- .../reference/shebangBeforeReferences.types | 2 +- .../reference/spellingSuggestionModule.types | 2 +- .../reference/systemExportAssignment3.types | 2 +- .../reference/topLevelAmbientModule.types | 2 +- ...opLevelModuleDeclarationAndFile.errors.txt | 4 +- .../topLevelModuleDeclarationAndFile.types | 2 +- .../transformNestedGeneratorsWithTry.types | 2 +- .../reference/tsxElementResolution19.types | 2 +- .../baselines/reference/typeAliasExport.types | 2 +- .../typeFromParamTagForFunction.types | 14 ++--- .../reference/typeReferenceDirectives12.types | 2 +- .../reference/typeReferenceDirectives9.types | 2 +- ...tsFromMultipleNodeModulesDirectories.types | 6 +- ...ootsFromNodeModulesInParentDirectory.types | 2 +- .../typeofAmbientExternalModules.errors.txt | 12 ++-- .../typeofExternalModules.errors.txt | 12 ++-- ...yExternalModuleStillHasInstance.errors.txt | 8 +-- .../reference/umd-augmentation-1.types | 2 +- .../reference/umd-augmentation-2.types | 2 +- tests/baselines/reference/umd-errors.types | 10 ++-- tests/baselines/reference/umd1.types | 2 +- tests/baselines/reference/umd3.types | 2 +- tests/baselines/reference/umd4.types | 2 +- tests/baselines/reference/umd5.types | 2 +- .../reference/umdGlobalConflict.types | 4 +- .../untypedModuleImport_allowJs.types | 2 +- .../untypedModuleImport_vsAmbient.types | 2 +- ...untypedModuleImport_withAugmentation.types | 2 +- ...ntypedModuleImport_withAugmentation2.types | 2 +- .../reference/varRequireFromJavascript.types | 6 +- .../reference/varRequireFromTypescript.types | 6 +- tests/cases/fourslash/jsRequireQuickInfo.ts | 2 +- 226 files changed, 982 insertions(+), 982 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0737f030b0d84..bae7befb6e112 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25107,7 +25107,7 @@ namespace ts { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } - if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + while (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } diff --git a/tests/baselines/reference/aliasAssignments.errors.txt b/tests/baselines/reference/aliasAssignments.errors.txt index 463f74e4c49f9..b93875bc6311a 100644 --- a/tests/baselines/reference/aliasAssignments.errors.txt +++ b/tests/baselines/reference/aliasAssignments.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type '1' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. -tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'. +tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type '1' is not assignable to type 'typeof import("tests/cases/compiler/aliasAssignments_moduleA")'. +tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof import("tests/cases/compiler/aliasAssignments_moduleA")' is not assignable to type 'number'. ==== tests/cases/compiler/aliasAssignments_1.ts (2 errors) ==== @@ -7,11 +7,11 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes var x = moduleA; x = 1; // Should be error ~ -!!! error TS2322: Type '1' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. +!!! error TS2322: Type '1' is not assignable to type 'typeof import("tests/cases/compiler/aliasAssignments_moduleA")'. var y = 1; y = moduleA; // should be error ~ -!!! error TS2322: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'. +!!! error TS2322: Type 'typeof import("tests/cases/compiler/aliasAssignments_moduleA")' is not assignable to type 'number'. ==== tests/cases/compiler/aliasAssignments_moduleA.ts (0 errors) ==== export class someClass { diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.types b/tests/baselines/reference/aliasOnMergedModuleInterface.types index fb9c197feecf2..3124e10b2f4e0 100644 --- a/tests/baselines/reference/aliasOnMergedModuleInterface.types +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.types @@ -26,7 +26,7 @@ var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be err === tests/cases/compiler/aliasOnMergedModuleInterface_0.ts === declare module "foo" ->"foo" : typeof "foo" +>"foo" : typeof import("foo") { module B { >B : any diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt b/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt index 981f89214e2ca..b03fd005547ec 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/a.ts(2,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. -tests/cases/compiler/a.ts(3,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. +tests/cases/compiler/a.ts(2,5): error TS2339: Property 'default' does not exist on type 'typeof import("tests/cases/compiler/b")'. +tests/cases/compiler/a.ts(3,5): error TS2339: Property 'default' does not exist on type 'typeof import("tests/cases/compiler/b")'. ==== tests/cases/compiler/a.ts (2 errors) ==== import Foo = require("./b"); Foo.default.bar(); ~~~~~~~ -!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. +!!! error TS2339: Property 'default' does not exist on type 'typeof import("tests/cases/compiler/b")'. Foo.default.default.foo(); ~~~~~~~ -!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. +!!! error TS2339: Property 'default' does not exist on type 'typeof import("tests/cases/compiler/b")'. ==== tests/cases/compiler/b.d.ts (0 errors) ==== export function foo(); diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.types b/tests/baselines/reference/ambientDeclarationsPatterns.types index 77cef7515b269..b3ea307d8c257 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.types +++ b/tests/baselines/reference/ambientDeclarationsPatterns.types @@ -28,7 +28,7 @@ foo(fileText); === tests/cases/conformance/ambient/declarations.d.ts === declare module "foo*baz" { ->"foo*baz" : typeof "foo*baz" +>"foo*baz" : typeof import("foo*baz") export function foo(s: string): void; >foo : (s: string) => void @@ -36,7 +36,7 @@ declare module "foo*baz" { } // Augmentations still work declare module "foo*baz" { ->"foo*baz" : typeof "foo*baz" +>"foo*baz" : typeof import("foo*baz") export const baz: string; >baz : string @@ -44,14 +44,14 @@ declare module "foo*baz" { // Longest prefix wins declare module "foos*" { ->"foos*" : typeof "foos*" +>"foos*" : typeof import("foos*") export const foos: string; >foos : string } declare module "*!text" { ->"*!text" : typeof "*!text" +>"*!text" : typeof import("*!text") const x: string; >x : string diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types index 93ea5f185d064..5d2e087ca2312 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types +++ b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types @@ -1,4 +1,4 @@ === tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts === declare module "too*many*asterisks" { } ->"too*many*asterisks" : typeof "too*many*asterisks" +>"too*many*asterisks" : typeof import("too*many*asterisks") diff --git a/tests/baselines/reference/ambientExportDefaultErrors.types b/tests/baselines/reference/ambientExportDefaultErrors.types index c9c2351d444d6..4da013dcf5833 100644 --- a/tests/baselines/reference/ambientExportDefaultErrors.types +++ b/tests/baselines/reference/ambientExportDefaultErrors.types @@ -12,7 +12,7 @@ export default 2 + 2; >2 : 2 export as namespace Foo; ->Foo : typeof "tests/cases/compiler/foo" +>Foo : typeof import("tests/cases/compiler/foo") === tests/cases/compiler/foo2.d.ts === export = 2 + 2; @@ -26,7 +26,7 @@ export as namespace Foo2; === tests/cases/compiler/indirection.d.ts === /// declare module "indirect" { ->"indirect" : typeof "indirect" +>"indirect" : typeof import("indirect") export default typeof Foo.default; >typeof Foo.default : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" @@ -38,7 +38,7 @@ declare module "indirect" { === tests/cases/compiler/indirection2.d.ts === /// declare module "indirect2" { ->"indirect2" : typeof "indirect2" +>"indirect2" : typeof import("indirect2") export = typeof Foo2; >typeof Foo2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types index f335f5255d24d..3e0374e01aa55 100644 --- a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types @@ -6,7 +6,7 @@ export = D; >D : D declare module "ext" { ->"ext" : typeof "ext" +>"ext" : typeof import("ext") export class C { } >C : C diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types index be88c42d3f98f..61d2b36e3ec04 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types @@ -3,5 +3,5 @@ module M { >M : any export declare module "M" { } ->"M" : typeof "M" +>"M" : typeof import("M") } diff --git a/tests/baselines/reference/ambientExternalModuleMerging.types b/tests/baselines/reference/ambientExternalModuleMerging.types index 8150f6c6dfc03..fc40d94c65437 100644 --- a/tests/baselines/reference/ambientExternalModuleMerging.types +++ b/tests/baselines/reference/ambientExternalModuleMerging.types @@ -17,7 +17,7 @@ var y = M.y; === tests/cases/conformance/ambient/ambientExternalModuleMerging_declare.ts === declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") export var x: string; >x : string @@ -25,7 +25,7 @@ declare module "M" { // Merge declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") export var y: string; >y : string diff --git a/tests/baselines/reference/ambientExternalModuleReopen.types b/tests/baselines/reference/ambientExternalModuleReopen.types index dffba752e0555..cbd1bda25b419 100644 --- a/tests/baselines/reference/ambientExternalModuleReopen.types +++ b/tests/baselines/reference/ambientExternalModuleReopen.types @@ -1,12 +1,12 @@ === tests/cases/compiler/ambientExternalModuleReopen.ts === declare module "fs" { ->"fs" : typeof "fs" +>"fs" : typeof import("fs") var x: string; >x : string } declare module 'fs' { ->'fs' : typeof "fs" +>'fs' : typeof import("fs") var y: number; >y : number diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types index 4072b2fcedd42..5995d11442ccc 100644 --- a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types @@ -1,6 +1,6 @@ === tests/cases/compiler/ambientExternalModuleWithRelativeExternalImportDeclaration.ts === declare module "OuterModule" { ->"OuterModule" : typeof "OuterModule" +>"OuterModule" : typeof import("OuterModule") import m2 = require("./SubModule"); >m2 : any diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types index d585e8ed6a130..f061663aac8ad 100644 --- a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types @@ -1,13 +1,13 @@ === tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts === declare module "./relativeModule" { ->"./relativeModule" : typeof "./relativeModule" +>"./relativeModule" : typeof import("./relativeModule") var x: string; >x : string } declare module ".\\relativeModule" { ->".\\relativeModule" : typeof ".\\relativeModule" +>".\\relativeModule" : typeof import(".\\\\relativeModule") var x: string; >x : string diff --git a/tests/baselines/reference/ambientRequireFunction.types b/tests/baselines/reference/ambientRequireFunction.types index ed34aa4309f77..d8d47964cfdfd 100644 --- a/tests/baselines/reference/ambientRequireFunction.types +++ b/tests/baselines/reference/ambientRequireFunction.types @@ -2,8 +2,8 @@ /// const fs = require("fs"); ->fs : typeof "fs" ->require("fs") : typeof "fs" +>fs : typeof import("fs") +>require("fs") : typeof import("fs") >require : (moduleName: string) => any >"fs" : "fs" @@ -11,7 +11,7 @@ const text = fs.readFileSync("/a/b/c"); >text : string >fs.readFileSync("/a/b/c") : string >fs.readFileSync : (s: string) => string ->fs : typeof "fs" +>fs : typeof import("fs") >readFileSync : (s: string) => string >"/a/b/c" : "/a/b/c" @@ -21,7 +21,7 @@ declare function require(moduleName: string): any; >moduleName : string declare module "fs" { ->"fs" : typeof "fs" +>"fs" : typeof import("fs") export function readFileSync(s: string): string; >readFileSync : (s: string) => string diff --git a/tests/baselines/reference/augmentExportEquals1_1.types b/tests/baselines/reference/augmentExportEquals1_1.types index 9077a27d32737..7c0a355d08caf 100644 --- a/tests/baselines/reference/augmentExportEquals1_1.types +++ b/tests/baselines/reference/augmentExportEquals1_1.types @@ -10,7 +10,7 @@ let a: x.A; // should not work === tests/cases/compiler/file1.d.ts === declare module "file1" { ->"file1" : typeof "file1" +>"file1" : typeof import("file1") var x: number; >x : number diff --git a/tests/baselines/reference/augmentExportEquals2_1.types b/tests/baselines/reference/augmentExportEquals2_1.types index 9a619638a011e..a684b76dd51c3 100644 --- a/tests/baselines/reference/augmentExportEquals2_1.types +++ b/tests/baselines/reference/augmentExportEquals2_1.types @@ -10,7 +10,7 @@ let a: x.A; // should not work === tests/cases/compiler/file1.d.ts === declare module "file1" { ->"file1" : typeof "file1" +>"file1" : typeof import("file1") function foo(): void; >foo : () => void diff --git a/tests/baselines/reference/augmentExportEquals3_1.types b/tests/baselines/reference/augmentExportEquals3_1.types index f841fb315352e..b0c0e806f57b5 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.types +++ b/tests/baselines/reference/augmentExportEquals3_1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { ->"file1" : typeof "file1" +>"file1" : typeof import("file1") function foo(): void; >foo : typeof foo diff --git a/tests/baselines/reference/augmentExportEquals4_1.types b/tests/baselines/reference/augmentExportEquals4_1.types index 9daf444e41937..dbb36c39e4217 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.types +++ b/tests/baselines/reference/augmentExportEquals4_1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { ->"file1" : typeof "file1" +>"file1" : typeof import("file1") class foo {} >foo : foo diff --git a/tests/baselines/reference/augmentExportEquals5.types b/tests/baselines/reference/augmentExportEquals5.types index eaa956e1d4e9c..c071a195f0e1f 100644 --- a/tests/baselines/reference/augmentExportEquals5.types +++ b/tests/baselines/reference/augmentExportEquals5.types @@ -13,7 +13,7 @@ declare module Express { } declare module "express" { ->"express" : typeof "express" +>"express" : typeof import("express") function e(): e.Express; >e : typeof e diff --git a/tests/baselines/reference/augmentExportEquals6_1.types b/tests/baselines/reference/augmentExportEquals6_1.types index 6929d99ad51c7..3e7c2596df48e 100644 --- a/tests/baselines/reference/augmentExportEquals6_1.types +++ b/tests/baselines/reference/augmentExportEquals6_1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { ->"file1" : typeof "file1" +>"file1" : typeof import("file1") class foo {} >foo : foo diff --git a/tests/baselines/reference/augmentExportEquals7.types b/tests/baselines/reference/augmentExportEquals7.types index 4311a3c112e2b..b1626ff89252c 100644 --- a/tests/baselines/reference/augmentExportEquals7.types +++ b/tests/baselines/reference/augmentExportEquals7.types @@ -13,7 +13,7 @@ import * as lib from "lib"; >lib : () => void declare module "lib" { ->"lib" : typeof "lib" +>"lib" : typeof import("lib") export function fn(): void; >fn : () => void diff --git a/tests/baselines/reference/bangInModuleName.types b/tests/baselines/reference/bangInModuleName.types index 691ac6add0087..cb1a66f986d4e 100644 --- a/tests/baselines/reference/bangInModuleName.types +++ b/tests/baselines/reference/bangInModuleName.types @@ -6,7 +6,7 @@ import * as http from 'intern/dojo/node!http'; === tests/cases/compiler/a.d.ts === declare module "http" { ->"http" : typeof "http" +>"http" : typeof import("http") } declare module 'intern/dojo/node!http' { diff --git a/tests/baselines/reference/commonJsUnusedLocals.types b/tests/baselines/reference/commonJsUnusedLocals.types index e792ad8e78282..55c07a7d23046 100644 --- a/tests/baselines/reference/commonJsUnusedLocals.types +++ b/tests/baselines/reference/commonJsUnusedLocals.types @@ -6,7 +6,7 @@ const x = 0; exports.y = 1; >exports.y = 1 : 1 >exports.y : number ->exports : typeof "/a" +>exports : typeof import("/a") >y : number >1 : 1 diff --git a/tests/baselines/reference/commonSourceDirectory.types b/tests/baselines/reference/commonSourceDirectory.types index ea16e24b8513f..79f5d8aacd893 100644 --- a/tests/baselines/reference/commonSourceDirectory.types +++ b/tests/baselines/reference/commonSourceDirectory.types @@ -20,7 +20,7 @@ export const x = 0; === /types/bar.d.ts === declare module "bar" { ->"bar" : typeof "bar" +>"bar" : typeof import("bar") export const y = 0; >y : 0 diff --git a/tests/baselines/reference/commonjsAccessExports.types b/tests/baselines/reference/commonjsAccessExports.types index 61d57d4b2cc05..639245e6cf92d 100644 --- a/tests/baselines/reference/commonjsAccessExports.types +++ b/tests/baselines/reference/commonjsAccessExports.types @@ -2,13 +2,13 @@ exports.x = 0; >exports.x = 0 : 0 >exports.x : number ->exports : typeof "/a" +>exports : typeof import("/a") >x : number >0 : 0 exports.x; >exports.x : number ->exports : typeof "/a" +>exports : typeof import("/a") >x : number // Works nested @@ -17,7 +17,7 @@ exports.x; exports.Cls = function() { >exports.Cls = function() { this.x = 0; } : () => void >exports.Cls : () => void ->exports : typeof "/a" +>exports : typeof import("/a") >Cls : () => void >function() { this.x = 0; } : () => void @@ -34,6 +34,6 @@ const instance = new exports.Cls(); >instance : { x: number; } >new exports.Cls() : { x: number; } >exports.Cls : () => void ->exports : typeof "/a" +>exports : typeof import("/a") >Cls : () => void diff --git a/tests/baselines/reference/complexRecursiveCollections.types b/tests/baselines/reference/complexRecursiveCollections.types index 80d007f788419..d29a9956e194d 100644 --- a/tests/baselines/reference/complexRecursiveCollections.types +++ b/tests/baselines/reference/complexRecursiveCollections.types @@ -3804,7 +3804,7 @@ declare module Immutable { } } declare module "immutable" { ->"immutable" : typeof "immutable" +>"immutable" : typeof import("immutable") export = Immutable >Immutable : typeof Immutable diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types index f0044067db8be..df80419ca16b9 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types @@ -1,6 +1,6 @@ === tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts === declare module "fs" { ->"fs" : typeof "fs" +>"fs" : typeof import("fs") export class File { >File : File diff --git a/tests/baselines/reference/cyclicModuleImport.types b/tests/baselines/reference/cyclicModuleImport.types index 6d4d08084a3b5..5a70b358871cf 100644 --- a/tests/baselines/reference/cyclicModuleImport.types +++ b/tests/baselines/reference/cyclicModuleImport.types @@ -1,6 +1,6 @@ === tests/cases/compiler/cyclicModuleImport.ts === declare module "SubModule" { ->"SubModule" : typeof "SubModule" +>"SubModule" : typeof import("SubModule") import MainModule = require('MainModule'); >MainModule : typeof MainModule @@ -24,7 +24,7 @@ declare module "SubModule" { >SubModule : SubModule } declare module "MainModule" { ->"MainModule" : typeof "MainModule" +>"MainModule" : typeof import("MainModule") import SubModule = require('SubModule'); >SubModule : typeof SubModule diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration2.types b/tests/baselines/reference/declFileAliasUseBeforeDeclaration2.types index 0666cf3012406..8ac39078fa550 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration2.types +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration2.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileAliasUseBeforeDeclaration2.ts === declare module "test" { ->"test" : typeof "test" +>"test" : typeof import("test") module A { >A : typeof A diff --git a/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.types b/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.types index d60bed7c414bc..2a4246d022cd2 100644 --- a/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.types +++ b/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.types @@ -13,7 +13,7 @@ export var x: SubModule.m.m3.c; === tests/cases/compiler/declFileAmbientExternalModuleWithSingleExportedModule_0.ts === declare module "SubModule" { ->"SubModule" : typeof "SubModule" +>"SubModule" : typeof import("SubModule") export module m { >m : any diff --git a/tests/baselines/reference/declarationEmitRelativeModuleError.types b/tests/baselines/reference/declarationEmitRelativeModuleError.types index 56cb018c9b9e6..a134269d68b4b 100644 --- a/tests/baselines/reference/declarationEmitRelativeModuleError.types +++ b/tests/baselines/reference/declarationEmitRelativeModuleError.types @@ -1,10 +1,10 @@ === tests/cases/compiler/declarationEmitRelativeModuleError.ts === declare module "b:block" { // <-- no error anymore ->"b:block" : typeof "b:block" +>"b:block" : typeof import("b:block") } declare module "b:/block" { // <-- still an error ->"b:/block" : typeof "b:/block" +>"b:/block" : typeof import("b:/block") } diff --git a/tests/baselines/reference/declarationMerging2.types b/tests/baselines/reference/declarationMerging2.types index 890b1e3faa7b3..b36fc1110a982 100644 --- a/tests/baselines/reference/declarationMerging2.types +++ b/tests/baselines/reference/declarationMerging2.types @@ -15,7 +15,7 @@ export class A { === tests/cases/compiler/b.ts === export {} declare module "./a" { ->"./a" : typeof "tests/cases/compiler/a" +>"./a" : typeof import("tests/cases/compiler/a") interface A { >A : A diff --git a/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types b/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types index e0936614fb24a..c399e959850d0 100644 --- a/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types +++ b/tests/baselines/reference/declareExternalModuleWithExportAssignedFundule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declareExternalModuleWithExportAssignedFundule.ts === declare module "express" { ->"express" : typeof "express" +>"express" : typeof import("express") export = express; >express : typeof express diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration4.types b/tests/baselines/reference/es5ExportDefaultClassDeclaration4.types index 3ff3bbfe502c3..faeb1d3425547 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration4.types +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration4.types @@ -1,6 +1,6 @@ === tests/cases/compiler/es5ExportDefaultClassDeclaration4.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export var before: C; >before : C diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types index 88240e7861e96..fd44fcdfb4fb1 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types @@ -1,6 +1,6 @@ === tests/cases/compiler/es5ExportDefaultFunctionDeclaration4.ts === declare module "bar" { ->"bar" : typeof "bar" +>"bar" : typeof import("bar") var before: typeof func; >before : () => typeof func diff --git a/tests/baselines/reference/es6ExportAssignment4.types b/tests/baselines/reference/es6ExportAssignment4.types index 7265f066c8d00..e550a7de47dc6 100644 --- a/tests/baselines/reference/es6ExportAssignment4.types +++ b/tests/baselines/reference/es6ExportAssignment4.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modules.d.ts === declare module "a" { ->"a" : typeof "a" +>"a" : typeof import("a") var a: number; >a : number diff --git a/tests/baselines/reference/es6ExportEqualsInterop.types b/tests/baselines/reference/es6ExportEqualsInterop.types index 112d317c228e2..a3d2400787b1b 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.types +++ b/tests/baselines/reference/es6ExportEqualsInterop.types @@ -320,7 +320,7 @@ export * from "class-module"; === tests/cases/compiler/modules.d.ts === declare module "interface" { ->"interface" : typeof "interface" +>"interface" : typeof import("interface") interface Foo { >Foo : Foo @@ -336,7 +336,7 @@ declare module "interface" { } declare module "variable" { ->"variable" : typeof "variable" +>"variable" : typeof import("variable") var Foo: { >Foo : { a: number; b: number; } @@ -352,7 +352,7 @@ declare module "variable" { } declare module "interface-variable" { ->"interface-variable" : typeof "interface-variable" +>"interface-variable" : typeof import("interface-variable") interface Foo { >Foo : Foo @@ -377,7 +377,7 @@ declare module "interface-variable" { } declare module "module" { ->"module" : typeof "module" +>"module" : typeof import("module") module Foo { >Foo : typeof Foo @@ -393,7 +393,7 @@ declare module "module" { } declare module "interface-module" { ->"interface-module" : typeof "interface-module" +>"interface-module" : typeof import("interface-module") interface Foo { >Foo : Foo @@ -418,7 +418,7 @@ declare module "interface-module" { } declare module "variable-module" { ->"variable-module" : typeof "variable-module" +>"variable-module" : typeof import("variable-module") module Foo { >Foo : { a: number; b: number; } @@ -447,7 +447,7 @@ declare module "variable-module" { } declare module "function" { ->"function" : typeof "function" +>"function" : typeof import("function") function foo(); >foo : () => any @@ -457,7 +457,7 @@ declare module "function" { } declare module "function-module" { ->"function-module" : typeof "function-module" +>"function-module" : typeof import("function-module") function foo(); >foo : typeof foo @@ -476,7 +476,7 @@ declare module "function-module" { } declare module "class" { ->"class" : typeof "class" +>"class" : typeof import("class") class Foo { >Foo : Foo @@ -492,7 +492,7 @@ declare module "class" { } declare module "class-module" { ->"class-module" : typeof "class-module" +>"class-module" : typeof import("class-module") class Foo { >Foo : Foo diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration2.types b/tests/baselines/reference/es6ImportEqualsDeclaration2.types index a3af23e6c1d01..c531f38deb874 100644 --- a/tests/baselines/reference/es6ImportEqualsDeclaration2.types +++ b/tests/baselines/reference/es6ImportEqualsDeclaration2.types @@ -1,13 +1,13 @@ === tests/cases/compiler/server.d.ts === declare module "other" { ->"other" : typeof "other" +>"other" : typeof import("other") export class C { } >C : C } declare module "server" { ->"server" : typeof "server" +>"server" : typeof import("server") import events = require("other"); // Ambient declaration, no error expected. >events : typeof events diff --git a/tests/baselines/reference/exportAsNamespace.d.types b/tests/baselines/reference/exportAsNamespace.d.types index 4952cb8863bc7..59988676ba2d3 100644 --- a/tests/baselines/reference/exportAsNamespace.d.types +++ b/tests/baselines/reference/exportAsNamespace.d.types @@ -5,5 +5,5 @@ export var X; >X : any export as namespace N ->N : typeof "tests/cases/compiler/exportAsNamespace" +>N : typeof import("tests/cases/compiler/exportAsNamespace") diff --git a/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.types b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.types index c0e629f7d35b2..e53e34a21d16e 100644 --- a/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.types +++ b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportDeclarationsInAmbientNamespaces2.ts === declare module "mod" { ->"mod" : typeof "mod" +>"mod" : typeof import("mod") export var x: number; >x : number diff --git a/tests/baselines/reference/exportDefaultProperty.types b/tests/baselines/reference/exportDefaultProperty.types index 55801a1d92d9c..fc19dcf3ad6e9 100644 --- a/tests/baselines/reference/exportDefaultProperty.types +++ b/tests/baselines/reference/exportDefaultProperty.types @@ -56,7 +56,7 @@ declare namespace foo.bar { } declare module "foobar" { ->"foobar" : typeof "foobar" +>"foobar" : typeof import("foobar") export default foo.bar; >foo.bar : typeof foo.bar @@ -65,7 +65,7 @@ declare module "foobar" { } declare module "foobarx" { ->"foobarx" : typeof "foobarx" +>"foobarx" : typeof import("foobarx") export default foo.bar.X; >foo.bar.X : number diff --git a/tests/baselines/reference/exportEqualsProperty.types b/tests/baselines/reference/exportEqualsProperty.types index cb89e4c1df090..dbe19fa7d5aa0 100644 --- a/tests/baselines/reference/exportEqualsProperty.types +++ b/tests/baselines/reference/exportEqualsProperty.types @@ -51,7 +51,7 @@ declare namespace foo.bar { } declare module "foobar" { ->"foobar" : typeof "foobar" +>"foobar" : typeof import("foobar") export = foo.bar; >foo.bar : typeof foo.bar @@ -60,7 +60,7 @@ declare module "foobar" { } declare module "foobarx" { ->"foobarx" : typeof "foobarx" +>"foobarx" : typeof import("foobarx") export = foo.bar.X; >foo.bar.X : number diff --git a/tests/baselines/reference/exportNestedNamespaces.types b/tests/baselines/reference/exportNestedNamespaces.types index 893ed56ef7089..9b8e84332e876 100644 --- a/tests/baselines/reference/exportNestedNamespaces.types +++ b/tests/baselines/reference/exportNestedNamespaces.types @@ -2,7 +2,7 @@ exports.n = {}; >exports.n = {} : typeof __object >exports.n : typeof __object ->exports : typeof "tests/cases/conformance/salsa/mod" +>exports : typeof import("tests/cases/conformance/salsa/mod") >n : typeof __object >{} : typeof __object @@ -10,7 +10,7 @@ exports.n.K = function () { >exports.n.K = function () { this.x = 10;} : () => void >exports.n.K : () => void >exports.n : typeof __object ->exports : typeof "tests/cases/conformance/salsa/mod" +>exports : typeof import("tests/cases/conformance/salsa/mod") >n : typeof __object >K : () => void >function () { this.x = 10;} : () => void @@ -25,7 +25,7 @@ exports.n.K = function () { exports.Classic = class { >exports.Classic = class { constructor() { this.p = 1 }} : typeof (Anonymous class) >exports.Classic : typeof (Anonymous class) ->exports : typeof "tests/cases/conformance/salsa/mod" +>exports : typeof import("tests/cases/conformance/salsa/mod") >Classic : typeof (Anonymous class) >class { constructor() { this.p = 1 }} : typeof (Anonymous class) diff --git a/tests/baselines/reference/exportNestedNamespaces2.errors.txt b/tests/baselines/reference/exportNestedNamespaces2.errors.txt index f8378e27776a7..7b4b3284f7223 100644 --- a/tests/baselines/reference/exportNestedNamespaces2.errors.txt +++ b/tests/baselines/reference/exportNestedNamespaces2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/salsa/first.js(1,1): error TS2539: Cannot assign to '"tests/cases/conformance/salsa/first"' because it is not a variable. tests/cases/conformance/salsa/first.js(1,11): error TS2304: Cannot find name 'require'. -tests/cases/conformance/salsa/first.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof "tests/cases/conformance/salsa/first"'. +tests/cases/conformance/salsa/first.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof import("tests/cases/conformance/salsa/first")'. tests/cases/conformance/salsa/second.js(1,1): error TS2539: Cannot assign to '"tests/cases/conformance/salsa/second"' because it is not a variable. tests/cases/conformance/salsa/second.js(1,11): error TS2304: Cannot find name 'require'. -tests/cases/conformance/salsa/second.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof "tests/cases/conformance/salsa/second"'. +tests/cases/conformance/salsa/second.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof import("tests/cases/conformance/salsa/second")'. ==== tests/cases/conformance/salsa/mod.js (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/conformance/salsa/second.js(2,9): error TS2339: Property 'formatters !!! error TS2304: Cannot find name 'require'. exports.formatters.j = function (v) { ~~~~~~~~~~ -!!! error TS2339: Property 'formatters' does not exist on type 'typeof "tests/cases/conformance/salsa/first"'. +!!! error TS2339: Property 'formatters' does not exist on type 'typeof import("tests/cases/conformance/salsa/first")'. return v } ==== tests/cases/conformance/salsa/second.js (3 errors) ==== @@ -28,7 +28,7 @@ tests/cases/conformance/salsa/second.js(2,9): error TS2339: Property 'formatters !!! error TS2304: Cannot find name 'require'. exports.formatters.o = function (v) { ~~~~~~~~~~ -!!! error TS2339: Property 'formatters' does not exist on type 'typeof "tests/cases/conformance/salsa/second"'. +!!! error TS2339: Property 'formatters' does not exist on type 'typeof import("tests/cases/conformance/salsa/second")'. return v } diff --git a/tests/baselines/reference/exportNestedNamespaces2.types b/tests/baselines/reference/exportNestedNamespaces2.types index 761c9bc604ec0..e15395866506b 100644 --- a/tests/baselines/reference/exportNestedNamespaces2.types +++ b/tests/baselines/reference/exportNestedNamespaces2.types @@ -3,15 +3,15 @@ exports.formatters = {} >exports.formatters = {} : { [x: string]: any; } >exports.formatters : { [x: string]: any; } ->exports : typeof "tests/cases/conformance/salsa/mod" +>exports : typeof import("tests/cases/conformance/salsa/mod") >formatters : { [x: string]: any; } >{} : { [x: string]: any; } === tests/cases/conformance/salsa/first.js === exports = require('./mod') ->exports = require('./mod') : typeof "tests/cases/conformance/salsa/mod" +>exports = require('./mod') : typeof import("tests/cases/conformance/salsa/mod") >exports : any ->require('./mod') : typeof "tests/cases/conformance/salsa/mod" +>require('./mod') : typeof import("tests/cases/conformance/salsa/mod") >require : any >'./mod' : "./mod" @@ -19,7 +19,7 @@ exports.formatters.j = function (v) { >exports.formatters.j = function (v) { return v} : (v: any) => any >exports.formatters.j : any >exports.formatters : any ->exports : typeof "tests/cases/conformance/salsa/first" +>exports : typeof import("tests/cases/conformance/salsa/first") >formatters : any >j : any >function (v) { return v} : (v: any) => any @@ -30,9 +30,9 @@ exports.formatters.j = function (v) { } === tests/cases/conformance/salsa/second.js === exports = require('./mod') ->exports = require('./mod') : typeof "tests/cases/conformance/salsa/mod" +>exports = require('./mod') : typeof import("tests/cases/conformance/salsa/mod") >exports : any ->require('./mod') : typeof "tests/cases/conformance/salsa/mod" +>require('./mod') : typeof import("tests/cases/conformance/salsa/mod") >require : any >'./mod' : "./mod" @@ -40,7 +40,7 @@ exports.formatters.o = function (v) { >exports.formatters.o = function (v) { return v} : (v: any) => any >exports.formatters.o : any >exports.formatters : any ->exports : typeof "tests/cases/conformance/salsa/second" +>exports : typeof import("tests/cases/conformance/salsa/second") >formatters : any >o : any >function (v) { return v} : (v: any) => any diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types index a7c05f2c722b8..fdb1c5d8121a5 100644 --- a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts === declare module "m2" { ->"m2" : typeof "m2" +>"m2" : typeof import("m2") export module X { >X : () => any @@ -22,7 +22,7 @@ declare module "m2" { } declare module "m2" { ->"m2" : typeof "m2" +>"m2" : typeof import("m2") function Z2(): X.I; >Z2 : () => X.I diff --git a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.types b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.types index 70fd8921c0a57..911ceaf0270f8 100644 --- a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.types +++ b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts === declare module "m2" { ->"m2" : typeof "m2" +>"m2" : typeof import("m2") module X { >X : any @@ -22,7 +22,7 @@ declare module "m2" { } declare module "m2" { ->"m2" : typeof "m2" +>"m2" : typeof import("m2") function Z2(): X.I; >Z2 : () => any diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types index 067667b0218e4..caf7243c164fc 100644 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types @@ -4,7 +4,7 @@ declare module X { export interface bar { } } >bar : bar declare module "m" { ->"m" : typeof "m" +>"m" : typeof import("m") export { X }; >X : any diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.types index 3d2cf9d96d3f6..f9c66c6a9a2aa 100644 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.types +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.types @@ -4,7 +4,7 @@ declare module X { export interface bar { } } >bar : bar declare module "m" { ->"m" : typeof "m" +>"m" : typeof import("m") module X { export interface foo { } } >X : any diff --git a/tests/baselines/reference/exportsInAmbientModules1.types b/tests/baselines/reference/exportsInAmbientModules1.types index 468ffb682fc69..4dddfe9c6bbea 100644 --- a/tests/baselines/reference/exportsInAmbientModules1.types +++ b/tests/baselines/reference/exportsInAmbientModules1.types @@ -4,7 +4,7 @@ export var x: number === tests/cases/compiler/main.ts === declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") export {x} from "external" >x : number diff --git a/tests/baselines/reference/exportsInAmbientModules2.types b/tests/baselines/reference/exportsInAmbientModules2.types index bd764d02ce0f9..345ee5a2f11d2 100644 --- a/tests/baselines/reference/exportsInAmbientModules2.types +++ b/tests/baselines/reference/exportsInAmbientModules2.types @@ -4,7 +4,7 @@ export default class C {} === tests/cases/compiler/main.ts === declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") export * from "external" } diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types index 1fd11b0513bc5..6142c1066facc 100644 --- a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types @@ -1,9 +1,9 @@ === tests/cases/compiler/bar.ts === export async function foo({ foo = await import("./bar") }) { ->foo : ({ foo }: { foo?: typeof "tests/cases/compiler/bar"; }) => Promise ->foo : typeof "tests/cases/compiler/bar" ->await import("./bar") : typeof "tests/cases/compiler/bar" ->import("./bar") : Promise +>foo : ({ foo }: { foo?: typeof import("tests/cases/compiler/bar"); }) => Promise +>foo : typeof import("tests/cases/compiler/bar") +>await import("./bar") : typeof import("tests/cases/compiler/bar") +>import("./bar") : Promise >"./bar" : "./bar" } diff --git a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt index 58e411e1035c5..d6a2be707e0b4 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt +++ b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt @@ -1,25 +1,25 @@ tests/cases/compiler/f2.ts(6,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(7,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(8,7): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(8,7): error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. tests/cases/compiler/f2.ts(11,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(12,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(16,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(17,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(18,8): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(18,8): error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. tests/cases/compiler/f2.ts(21,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(22,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(26,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(27,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(28,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(29,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(30,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. -tests/cases/compiler/f2.ts(31,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(30,12): error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. +tests/cases/compiler/f2.ts(31,12): error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. tests/cases/compiler/f2.ts(35,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(36,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(37,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. tests/cases/compiler/f2.ts(38,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. -tests/cases/compiler/f2.ts(39,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. -tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +tests/cases/compiler/f2.ts(39,13): error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. +tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. ==== tests/cases/compiler/f1.ts (0 errors) ==== @@ -39,7 +39,7 @@ tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. stuff.blah = 2; ~~~~ -!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +!!! error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. stuff[n] = 3; stuff.x++; @@ -59,7 +59,7 @@ tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. (stuff.blah) = 2; ~~~~ -!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +!!! error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. (stuff[n]) = 3; (stuff.x)++; @@ -85,10 +85,10 @@ tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for (stuff.blah in []) {} ~~~~ -!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +!!! error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. for (stuff.blah of []) {} ~~~~ -!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +!!! error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. for (stuff[n] in []) {} for (stuff[n] of []) {} @@ -106,10 +106,10 @@ tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist !!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. for ((stuff.blah) in []) {} ~~~~ -!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +!!! error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. for ((stuff.blah) of []) {} ~~~~ -!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'. +!!! error TS2339: Property 'blah' does not exist on type 'typeof import("tests/cases/compiler/f1")'. for ((stuff[n]) in []) {} for ((stuff[n]) of []) {} diff --git a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt index a0b34ecbee1a3..74ad59b4bb769 100644 --- a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt +++ b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts(4,7): error TS2339: Property 'bar' does not exist on type 'typeof "tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. +tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts(4,7): error TS2339: Property 'bar' does not exist on type 'typeof import("tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1")'. ==== tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_fi file1.foo(); file1.bar(); ~~~ -!!! error TS2339: Property 'bar' does not exist on type 'typeof "tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. +!!! error TS2339: Property 'bar' does not exist on type 'typeof import("tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1")'. ==== tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1.ts (0 errors) ==== diff --git a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.types b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.types index 9095955caac42..f75bfd713c15e 100644 --- a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.types +++ b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.types @@ -22,7 +22,7 @@ export function foo() { }; === tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file2.ts === declare module "externalModuleRefernceResolutionOrderInImportDeclaration_file1" { ->"externalModuleRefernceResolutionOrderInImportDeclaration_file1" : typeof "externalModuleRefernceResolutionOrderInImportDeclaration_file1" +>"externalModuleRefernceResolutionOrderInImportDeclaration_file1" : typeof import("externalModuleRefernceResolutionOrderInImportDeclaration_file1") export function bar(); >bar : () => any diff --git a/tests/baselines/reference/importAsBaseClass.errors.txt b/tests/baselines/reference/importAsBaseClass.errors.txt index 8f23baad5439c..737556c7d5103 100644 --- a/tests/baselines/reference/importAsBaseClass.errors.txt +++ b/tests/baselines/reference/importAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2507: Type 'typeof "tests/cases/compiler/importAsBaseClass_0"' is not a constructor function type. +tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2507: Type 'typeof import("tests/cases/compiler/importAsBaseClass_0")' is not a constructor function type. ==== tests/cases/compiler/importAsBaseClass_1.ts (1 errors) ==== import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { } ~~~~~~~ -!!! error TS2507: Type 'typeof "tests/cases/compiler/importAsBaseClass_0"' is not a constructor function type. +!!! error TS2507: Type 'typeof import("tests/cases/compiler/importAsBaseClass_0")' is not a constructor function type. ==== tests/cases/compiler/importAsBaseClass_0.ts (0 errors) ==== export class Greeter { diff --git a/tests/baselines/reference/importCallExpression1ESNext.types b/tests/baselines/reference/importCallExpression1ESNext.types index 29e2c3d261bc9..30fe9acd605ea 100644 --- a/tests/baselines/reference/importCallExpression1ESNext.types +++ b/tests/baselines/reference/importCallExpression1ESNext.types @@ -5,40 +5,40 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }) export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } diff --git a/tests/baselines/reference/importCallExpression2ESNext.types b/tests/baselines/reference/importCallExpression2ESNext.types index 084eb33dde95d..3527b92d4c46d 100644 --- a/tests/baselines/reference/importCallExpression2ESNext.types +++ b/tests/baselines/reference/importCallExpression2ESNext.types @@ -40,6 +40,6 @@ function foo(x: Promise) { foo(import("./0")); >foo(import("./0")) : void >foo : (x: Promise) => void ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpression3ESNext.types b/tests/baselines/reference/importCallExpression3ESNext.types index e517be6e722f4..4d81b4ec33115 100644 --- a/tests/baselines/reference/importCallExpression3ESNext.types +++ b/tests/baselines/reference/importCallExpression3ESNext.types @@ -14,9 +14,9 @@ async function foo() { class C extends (await import("./0")).B {} >C : C >(await import("./0")).B : B ->(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" ->await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" ->import("./0") : Promise +>(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") +>await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") +>import("./0") : Promise >"./0" : "./0" >B : typeof B diff --git a/tests/baselines/reference/importCallExpression4ESNext.types b/tests/baselines/reference/importCallExpression4ESNext.types index 74cc6ff8b28fa..82ddbf1db6571 100644 --- a/tests/baselines/reference/importCallExpression4ESNext.types +++ b/tests/baselines/reference/importCallExpression4ESNext.types @@ -24,27 +24,27 @@ class C { >C : C private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -53,7 +53,7 @@ class C { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -68,9 +68,9 @@ class C { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -80,7 +80,7 @@ class C { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); diff --git a/tests/baselines/reference/importCallExpressionAsyncES3AMD.types b/tests/baselines/reference/importCallExpressionAsyncES3AMD.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3AMD.types +++ b/tests/baselines/reference/importCallExpressionAsyncES3AMD.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES3CJS.types b/tests/baselines/reference/importCallExpressionAsyncES3CJS.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3CJS.types +++ b/tests/baselines/reference/importCallExpressionAsyncES3CJS.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES3System.types b/tests/baselines/reference/importCallExpressionAsyncES3System.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3System.types +++ b/tests/baselines/reference/importCallExpressionAsyncES3System.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES3UMD.types b/tests/baselines/reference/importCallExpressionAsyncES3UMD.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3UMD.types +++ b/tests/baselines/reference/importCallExpressionAsyncES3UMD.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES5AMD.types b/tests/baselines/reference/importCallExpressionAsyncES5AMD.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5AMD.types +++ b/tests/baselines/reference/importCallExpressionAsyncES5AMD.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES5CJS.types b/tests/baselines/reference/importCallExpressionAsyncES5CJS.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5CJS.types +++ b/tests/baselines/reference/importCallExpressionAsyncES5CJS.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES5System.types b/tests/baselines/reference/importCallExpressionAsyncES5System.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5System.types +++ b/tests/baselines/reference/importCallExpressionAsyncES5System.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES5UMD.types b/tests/baselines/reference/importCallExpressionAsyncES5UMD.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5UMD.types +++ b/tests/baselines/reference/importCallExpressionAsyncES5UMD.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES6AMD.types b/tests/baselines/reference/importCallExpressionAsyncES6AMD.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6AMD.types +++ b/tests/baselines/reference/importCallExpressionAsyncES6AMD.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES6CJS.types b/tests/baselines/reference/importCallExpressionAsyncES6CJS.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6CJS.types +++ b/tests/baselines/reference/importCallExpressionAsyncES6CJS.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES6System.types b/tests/baselines/reference/importCallExpressionAsyncES6System.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6System.types +++ b/tests/baselines/reference/importCallExpressionAsyncES6System.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES6UMD.types b/tests/baselines/reference/importCallExpressionAsyncES6UMD.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6UMD.types +++ b/tests/baselines/reference/importCallExpressionAsyncES6UMD.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncESNext.types b/tests/baselines/reference/importCallExpressionAsyncESNext.types index 4f6a2bb31bea1..1de333feaea79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncESNext.types +++ b/tests/baselines/reference/importCallExpressionAsyncESNext.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" ->import('./test') : Promise +>req : typeof import("tests/cases/conformance/dynamicImport/test") +>await import('./test') : typeof import("tests/cases/conformance/dynamicImport/test") +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt b/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt index 39622f39b3f26..c62c7868e10be 100644 --- a/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt +++ b/tests/baselines/reference/importCallExpressionCheckReturntype1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/dynamicImport/1.ts(4,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not assignable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'. - Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'. -tests/cases/conformance/dynamicImport/1.ts(5,10): error TS2352: Type 'Promise' cannot be converted to type 'Promise'. - Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not comparable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'. - Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'. +tests/cases/conformance/dynamicImport/1.ts(4,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. + Type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")' is not assignable to type 'typeof import("tests/cases/conformance/dynamicImport/anotherModule")'. + Property 'D' is missing in type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")'. +tests/cases/conformance/dynamicImport/1.ts(5,10): error TS2352: Type 'Promise' cannot be converted to type 'Promise'. + Type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")' is not comparable to type 'typeof import("tests/cases/conformance/dynamicImport/anotherModule")'. + Property 'D' is missing in type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")'. ==== tests/cases/conformance/dynamicImport/anotherModule.ts (0 errors) ==== @@ -18,13 +18,13 @@ tests/cases/conformance/dynamicImport/1.ts(5,10): error TS2352: Type 'Promise = import("./defaultPath"); ~~ -!!! error TS2322: Type 'Promise' is not assignable to type 'Promise'. -!!! error TS2322: Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not assignable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'. -!!! error TS2322: Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'. +!!! error TS2322: Type 'Promise' is not assignable to type 'Promise'. +!!! error TS2322: Type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")' is not assignable to type 'typeof import("tests/cases/conformance/dynamicImport/anotherModule")'. +!!! error TS2322: Property 'D' is missing in type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")'. let p2 = import("./defaultPath") as Promise; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type 'Promise' cannot be converted to type 'Promise'. -!!! error TS2352: Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not comparable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'. -!!! error TS2352: Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'. +!!! error TS2352: Type 'Promise' cannot be converted to type 'Promise'. +!!! error TS2352: Type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")' is not comparable to type 'typeof import("tests/cases/conformance/dynamicImport/anotherModule")'. +!!! error TS2352: Property 'D' is missing in type 'typeof import("tests/cases/conformance/dynamicImport/defaultPath")'. let p3: Promise = import("./defaultPath"); \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit2.types b/tests/baselines/reference/importCallExpressionDeclarationEmit2.types index 5b8334775f100..802c00f35b4be 100644 --- a/tests/baselines/reference/importCallExpressionDeclarationEmit2.types +++ b/tests/baselines/reference/importCallExpressionDeclarationEmit2.types @@ -5,7 +5,7 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpressionES5AMD.types b/tests/baselines/reference/importCallExpressionES5AMD.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES5AMD.types +++ b/tests/baselines/reference/importCallExpressionES5AMD.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES5CJS.types b/tests/baselines/reference/importCallExpressionES5CJS.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES5CJS.types +++ b/tests/baselines/reference/importCallExpressionES5CJS.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES5System.types b/tests/baselines/reference/importCallExpressionES5System.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES5System.types +++ b/tests/baselines/reference/importCallExpressionES5System.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES5UMD.types b/tests/baselines/reference/importCallExpressionES5UMD.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES5UMD.types +++ b/tests/baselines/reference/importCallExpressionES5UMD.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES6AMD.types b/tests/baselines/reference/importCallExpressionES6AMD.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES6AMD.types +++ b/tests/baselines/reference/importCallExpressionES6AMD.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES6CJS.types b/tests/baselines/reference/importCallExpressionES6CJS.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES6CJS.types +++ b/tests/baselines/reference/importCallExpressionES6CJS.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES6System.types b/tests/baselines/reference/importCallExpressionES6System.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES6System.types +++ b/tests/baselines/reference/importCallExpressionES6System.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES6UMD.types b/tests/baselines/reference/importCallExpressionES6UMD.types index e97f722b14ff5..ceb6a6fe29962 100644 --- a/tests/baselines/reference/importCallExpressionES6UMD.types +++ b/tests/baselines/reference/importCallExpressionES6UMD.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionErrorInES2015.types b/tests/baselines/reference/importCallExpressionErrorInES2015.types index 53a1b3d08fa22..f0a055e7a0626 100644 --- a/tests/baselines/reference/importCallExpressionErrorInES2015.types +++ b/tests/baselines/reference/importCallExpressionErrorInES2015.types @@ -5,26 +5,26 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }) @@ -33,7 +33,7 @@ function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } diff --git a/tests/baselines/reference/importCallExpressionInAMD1.types b/tests/baselines/reference/importCallExpressionInAMD1.types index 661d27d14692e..6d270e686edf2 100644 --- a/tests/baselines/reference/importCallExpressionInAMD1.types +++ b/tests/baselines/reference/importCallExpressionInAMD1.types @@ -5,40 +5,40 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } diff --git a/tests/baselines/reference/importCallExpressionInAMD2.types b/tests/baselines/reference/importCallExpressionInAMD2.types index 44b17eb51fd5c..8e33f8258d479 100644 --- a/tests/baselines/reference/importCallExpressionInAMD2.types +++ b/tests/baselines/reference/importCallExpressionInAMD2.types @@ -41,6 +41,6 @@ function foo(x: Promise) { foo(import("./0")); >foo(import("./0")) : void >foo : (x: Promise) => void ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpressionInAMD3.types b/tests/baselines/reference/importCallExpressionInAMD3.types index e517be6e722f4..4d81b4ec33115 100644 --- a/tests/baselines/reference/importCallExpressionInAMD3.types +++ b/tests/baselines/reference/importCallExpressionInAMD3.types @@ -14,9 +14,9 @@ async function foo() { class C extends (await import("./0")).B {} >C : C >(await import("./0")).B : B ->(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" ->await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" ->import("./0") : Promise +>(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") +>await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") +>import("./0") : Promise >"./0" : "./0" >B : typeof B diff --git a/tests/baselines/reference/importCallExpressionInAMD4.types b/tests/baselines/reference/importCallExpressionInAMD4.types index 156247851c914..afedd6f4b815f 100644 --- a/tests/baselines/reference/importCallExpressionInAMD4.types +++ b/tests/baselines/reference/importCallExpressionInAMD4.types @@ -24,27 +24,27 @@ class C { >C : C private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -53,7 +53,7 @@ class C { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -68,9 +68,9 @@ class C { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -80,7 +80,7 @@ class C { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); @@ -91,27 +91,27 @@ export class D { >D : D private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -120,7 +120,7 @@ export class D { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -135,9 +135,9 @@ export class D { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -147,7 +147,7 @@ export class D { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); diff --git a/tests/baselines/reference/importCallExpressionInCJS1.types b/tests/baselines/reference/importCallExpressionInCJS1.types index 661d27d14692e..6d270e686edf2 100644 --- a/tests/baselines/reference/importCallExpressionInCJS1.types +++ b/tests/baselines/reference/importCallExpressionInCJS1.types @@ -5,40 +5,40 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } diff --git a/tests/baselines/reference/importCallExpressionInCJS2.types b/tests/baselines/reference/importCallExpressionInCJS2.types index 063a52245395d..d8d7e07df3a77 100644 --- a/tests/baselines/reference/importCallExpressionInCJS2.types +++ b/tests/baselines/reference/importCallExpressionInCJS2.types @@ -24,10 +24,10 @@ async function compute(promise: Promise) { >j : any j = await import("./1"); ->j = await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" +>j = await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") >j : any ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" return j.backup(); @@ -46,6 +46,6 @@ async function compute(promise: Promise) { compute(import("./0")); >compute(import("./0")) : Promise >compute : (promise: Promise) => Promise ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpressionInCJS3.types b/tests/baselines/reference/importCallExpressionInCJS3.types index 44b17eb51fd5c..8e33f8258d479 100644 --- a/tests/baselines/reference/importCallExpressionInCJS3.types +++ b/tests/baselines/reference/importCallExpressionInCJS3.types @@ -41,6 +41,6 @@ function foo(x: Promise) { foo(import("./0")); >foo(import("./0")) : void >foo : (x: Promise) => void ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpressionInCJS4.types b/tests/baselines/reference/importCallExpressionInCJS4.types index e517be6e722f4..4d81b4ec33115 100644 --- a/tests/baselines/reference/importCallExpressionInCJS4.types +++ b/tests/baselines/reference/importCallExpressionInCJS4.types @@ -14,9 +14,9 @@ async function foo() { class C extends (await import("./0")).B {} >C : C >(await import("./0")).B : B ->(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" ->await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" ->import("./0") : Promise +>(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") +>await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") +>import("./0") : Promise >"./0" : "./0" >B : typeof B diff --git a/tests/baselines/reference/importCallExpressionInCJS5.types b/tests/baselines/reference/importCallExpressionInCJS5.types index 7d0c6f01cacd3..aea65c1407070 100644 --- a/tests/baselines/reference/importCallExpressionInCJS5.types +++ b/tests/baselines/reference/importCallExpressionInCJS5.types @@ -24,27 +24,27 @@ class C { >C : C private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -53,7 +53,7 @@ class C { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -68,9 +68,9 @@ class C { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -80,7 +80,7 @@ class C { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); @@ -91,27 +91,27 @@ export class D { >D : D private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -120,7 +120,7 @@ export class D { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -135,9 +135,9 @@ export class D { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -147,7 +147,7 @@ export class D { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); diff --git a/tests/baselines/reference/importCallExpressionInScriptContext1.types b/tests/baselines/reference/importCallExpressionInScriptContext1.types index c318667c7d86a..76955c4daa425 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext1.types +++ b/tests/baselines/reference/importCallExpressionInScriptContext1.types @@ -5,8 +5,8 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" function arguments() { } // this is allow as the file doesn't have implicit "use strict" diff --git a/tests/baselines/reference/importCallExpressionInScriptContext2.types b/tests/baselines/reference/importCallExpressionInScriptContext2.types index 4e9feaef9b0af..be0b66226d916 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext2.types +++ b/tests/baselines/reference/importCallExpressionInScriptContext2.types @@ -8,8 +8,8 @@ export function foo() { return "foo"; } >"use strict" : "use strict" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" function arguments() { } diff --git a/tests/baselines/reference/importCallExpressionInSystem1.types b/tests/baselines/reference/importCallExpressionInSystem1.types index 661d27d14692e..6d270e686edf2 100644 --- a/tests/baselines/reference/importCallExpressionInSystem1.types +++ b/tests/baselines/reference/importCallExpressionInSystem1.types @@ -5,40 +5,40 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } diff --git a/tests/baselines/reference/importCallExpressionInSystem2.types b/tests/baselines/reference/importCallExpressionInSystem2.types index 44b17eb51fd5c..8e33f8258d479 100644 --- a/tests/baselines/reference/importCallExpressionInSystem2.types +++ b/tests/baselines/reference/importCallExpressionInSystem2.types @@ -41,6 +41,6 @@ function foo(x: Promise) { foo(import("./0")); >foo(import("./0")) : void >foo : (x: Promise) => void ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpressionInSystem3.types b/tests/baselines/reference/importCallExpressionInSystem3.types index e517be6e722f4..4d81b4ec33115 100644 --- a/tests/baselines/reference/importCallExpressionInSystem3.types +++ b/tests/baselines/reference/importCallExpressionInSystem3.types @@ -14,9 +14,9 @@ async function foo() { class C extends (await import("./0")).B {} >C : C >(await import("./0")).B : B ->(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" ->await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" ->import("./0") : Promise +>(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") +>await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") +>import("./0") : Promise >"./0" : "./0" >B : typeof B diff --git a/tests/baselines/reference/importCallExpressionInSystem4.types b/tests/baselines/reference/importCallExpressionInSystem4.types index 156247851c914..afedd6f4b815f 100644 --- a/tests/baselines/reference/importCallExpressionInSystem4.types +++ b/tests/baselines/reference/importCallExpressionInSystem4.types @@ -24,27 +24,27 @@ class C { >C : C private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -53,7 +53,7 @@ class C { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -68,9 +68,9 @@ class C { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -80,7 +80,7 @@ class C { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); @@ -91,27 +91,27 @@ export class D { >D : D private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -120,7 +120,7 @@ export class D { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -135,9 +135,9 @@ export class D { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -147,7 +147,7 @@ export class D { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); diff --git a/tests/baselines/reference/importCallExpressionInUMD1.types b/tests/baselines/reference/importCallExpressionInUMD1.types index 661d27d14692e..6d270e686edf2 100644 --- a/tests/baselines/reference/importCallExpressionInUMD1.types +++ b/tests/baselines/reference/importCallExpressionInUMD1.types @@ -5,40 +5,40 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>p1.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof import("tests/cases/conformance/dynamicImport/0")) => string +>zero : typeof import("tests/cases/conformance/dynamicImport/0") return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" +>zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } diff --git a/tests/baselines/reference/importCallExpressionInUMD2.types b/tests/baselines/reference/importCallExpressionInUMD2.types index 44b17eb51fd5c..8e33f8258d479 100644 --- a/tests/baselines/reference/importCallExpressionInUMD2.types +++ b/tests/baselines/reference/importCallExpressionInUMD2.types @@ -41,6 +41,6 @@ function foo(x: Promise) { foo(import("./0")); >foo(import("./0")) : void >foo : (x: Promise) => void ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpressionInUMD3.types b/tests/baselines/reference/importCallExpressionInUMD3.types index e517be6e722f4..4d81b4ec33115 100644 --- a/tests/baselines/reference/importCallExpressionInUMD3.types +++ b/tests/baselines/reference/importCallExpressionInUMD3.types @@ -14,9 +14,9 @@ async function foo() { class C extends (await import("./0")).B {} >C : C >(await import("./0")).B : B ->(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" ->await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" ->import("./0") : Promise +>(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") +>await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") +>import("./0") : Promise >"./0" : "./0" >B : typeof B diff --git a/tests/baselines/reference/importCallExpressionInUMD4.types b/tests/baselines/reference/importCallExpressionInUMD4.types index 156247851c914..afedd6f4b815f 100644 --- a/tests/baselines/reference/importCallExpressionInUMD4.types +++ b/tests/baselines/reference/importCallExpressionInUMD4.types @@ -24,27 +24,27 @@ class C { >C : C private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -53,7 +53,7 @@ class C { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -68,9 +68,9 @@ class C { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -80,7 +80,7 @@ class C { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); @@ -91,27 +91,27 @@ export class D { >D : D private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -120,7 +120,7 @@ export class D { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -135,9 +135,9 @@ export class D { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -147,7 +147,7 @@ export class D { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); diff --git a/tests/baselines/reference/importCallExpressionNestedAMD.types b/tests/baselines/reference/importCallExpressionNestedAMD.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedAMD.types +++ b/tests/baselines/reference/importCallExpressionNestedAMD.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedAMD2.types b/tests/baselines/reference/importCallExpressionNestedAMD2.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedAMD2.types +++ b/tests/baselines/reference/importCallExpressionNestedAMD2.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedCJS.types b/tests/baselines/reference/importCallExpressionNestedCJS.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS.types +++ b/tests/baselines/reference/importCallExpressionNestedCJS.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedCJS2.types b/tests/baselines/reference/importCallExpressionNestedCJS2.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS2.types +++ b/tests/baselines/reference/importCallExpressionNestedCJS2.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedES2015.types b/tests/baselines/reference/importCallExpressionNestedES2015.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedES2015.types +++ b/tests/baselines/reference/importCallExpressionNestedES2015.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedES20152.types b/tests/baselines/reference/importCallExpressionNestedES20152.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedES20152.types +++ b/tests/baselines/reference/importCallExpressionNestedES20152.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedESNext.types b/tests/baselines/reference/importCallExpressionNestedESNext.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedESNext.types +++ b/tests/baselines/reference/importCallExpressionNestedESNext.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedESNext2.types b/tests/baselines/reference/importCallExpressionNestedESNext2.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedESNext2.types +++ b/tests/baselines/reference/importCallExpressionNestedESNext2.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedSystem.types b/tests/baselines/reference/importCallExpressionNestedSystem.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedSystem.types +++ b/tests/baselines/reference/importCallExpressionNestedSystem.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedSystem2.types b/tests/baselines/reference/importCallExpressionNestedSystem2.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedSystem2.types +++ b/tests/baselines/reference/importCallExpressionNestedSystem2.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedUMD.types b/tests/baselines/reference/importCallExpressionNestedUMD.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD.types +++ b/tests/baselines/reference/importCallExpressionNestedUMD.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNestedUMD2.types b/tests/baselines/reference/importCallExpressionNestedUMD2.types index 2f74d78b6c845..1e23832e30522 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD2.types +++ b/tests/baselines/reference/importCallExpressionNestedUMD2.types @@ -9,9 +9,9 @@ async function foo() { >await import((await import("./foo")).default) : any >import((await import("./foo")).default) : Promise >(await import("./foo")).default : "./foo" ->(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo" ->await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo" ->import("./foo") : Promise +>(await import("./foo")) : typeof import("tests/cases/conformance/dynamicImport/foo") +>await import("./foo") : typeof import("tests/cases/conformance/dynamicImport/foo") +>import("./foo") : Promise >"./foo" : "./foo" >default : "./foo" } diff --git a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.types b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.types index 552e3cf9206ca..ef8cdaec2fa72 100644 --- a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.types +++ b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.types @@ -24,27 +24,27 @@ class C { >C : C private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>myModule : Promise +>then : (onfulfilled?: (value: typeof import("tests/cases/conformance/dynamicImport/0")) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof import("tests/cases/conformance/dynamicImport/0")) => void +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -53,7 +53,7 @@ class C { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" +>Zero : typeof import("tests/cases/conformance/dynamicImport/0") >foo : () => string }, async err => { @@ -68,9 +68,9 @@ class C { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" ->import("./1") : Promise +>one : typeof import("tests/cases/conformance/dynamicImport/1") +>await import("./1") : typeof import("tests/cases/conformance/dynamicImport/1") +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -80,7 +80,7 @@ class C { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" +>one : typeof import("tests/cases/conformance/dynamicImport/1") >backup : () => string }); diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.types b/tests/baselines/reference/importCallExpressionWithTypeArgument.types index d228ae7c95ddc..123215a865608 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.types +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.types @@ -8,13 +8,13 @@ export function foo() { return "foo"; } >"use strict" : "use strict" var p1 = import>("./0"); // error ->p1 : Promise ->import>("./0") : Promise +>p1 : Promise +>import>("./0") : Promise >Promise : Promise >"./0" : "./0" var p2 = import<>("./0"); // error ->p2 : Promise ->import<>("./0") : Promise +>p2 : Promise +>import<>("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importDeclWithDeclareModifierInAmbientContext.types b/tests/baselines/reference/importDeclWithDeclareModifierInAmbientContext.types index 1721f8cdfe300..21f7d4f05b411 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifierInAmbientContext.types +++ b/tests/baselines/reference/importDeclWithDeclareModifierInAmbientContext.types @@ -1,6 +1,6 @@ === tests/cases/compiler/importDeclWithDeclareModifierInAmbientContext.ts === declare module "m" { ->"m" : typeof "m" +>"m" : typeof import("m") module x { >x : any diff --git a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignmentInAmbientContext.types b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignmentInAmbientContext.types index 7ba42021954fa..80f9ba8530343 100644 --- a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignmentInAmbientContext.types +++ b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignmentInAmbientContext.types @@ -1,6 +1,6 @@ === tests/cases/compiler/importDeclWithExportModifierAndExportAssignmentInAmbientContext.ts === declare module "m" { ->"m" : typeof "m" +>"m" : typeof import("m") module x { >x : any diff --git a/tests/baselines/reference/importDeclWithExportModifierInAmbientContext.types b/tests/baselines/reference/importDeclWithExportModifierInAmbientContext.types index 4818b04acb4a3..82244ad18b099 100644 --- a/tests/baselines/reference/importDeclWithExportModifierInAmbientContext.types +++ b/tests/baselines/reference/importDeclWithExportModifierInAmbientContext.types @@ -1,6 +1,6 @@ === tests/cases/compiler/importDeclWithExportModifierInAmbientContext.ts === declare module "m" { ->"m" : typeof "m" +>"m" : typeof import("m") module x { >x : any diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types index 2531654f80b92..c12cd511cb9d9 100644 --- a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types @@ -1,6 +1,6 @@ === tests/cases/compiler/node_modules/umd.d.ts === export as namespace UMD; ->UMD : typeof "tests/cases/compiler/node_modules/umd" +>UMD : typeof import("tests/cases/compiler/node_modules/umd") export type Thing = { >Thing : Thing diff --git a/tests/baselines/reference/importTsBeforeDTs.errors.txt b/tests/baselines/reference/importTsBeforeDTs.errors.txt index aaee4e3d07085..373b191f5962e 100644 --- a/tests/baselines/reference/importTsBeforeDTs.errors.txt +++ b/tests/baselines/reference/importTsBeforeDTs.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/externalModules/foo_1.ts(2,14): error TS2339: Property 'x' does not exist on type 'typeof "tests/cases/conformance/externalModules/foo_0"'. +tests/cases/conformance/externalModules/foo_1.ts(2,14): error TS2339: Property 'x' does not exist on type 'typeof import("tests/cases/conformance/externalModules/foo_0")'. ==== tests/cases/conformance/externalModules/foo_1.ts (1 errors) ==== import foo = require("./foo_0"); var z1 = foo.x + 10; // Should error, as .ts preferred over .d.ts ~ -!!! error TS2339: Property 'x' does not exist on type 'typeof "tests/cases/conformance/externalModules/foo_0"'. +!!! error TS2339: Property 'x' does not exist on type 'typeof import("tests/cases/conformance/externalModules/foo_0")'. var z2 = foo.y + 10; // Should resolve ==== tests/cases/conformance/externalModules/foo_0.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/importTypeAmbient.types b/tests/baselines/reference/importTypeAmbient.types index d7b7399d28d7b..bfa3c1b4ef4c7 100644 --- a/tests/baselines/reference/importTypeAmbient.types +++ b/tests/baselines/reference/importTypeAmbient.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/import/importTypeAmbient.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") interface Point { >Point : Point @@ -23,7 +23,7 @@ const x: import("foo") = { x: 0, y: 0 }; >0 : 0 declare module "foo2" { ->"foo2" : typeof "foo2" +>"foo2" : typeof import("foo2") namespace Bar { >Bar : typeof Bar @@ -92,7 +92,7 @@ class Bar2 { } let shim: typeof import("foo2") = { ->shim : typeof "foo2" +>shim : typeof import("foo2") >{ Bar: Bar2} : { Bar: typeof Bar2; } Bar: Bar2 diff --git a/tests/baselines/reference/importTypeAmbientMissing.types b/tests/baselines/reference/importTypeAmbientMissing.types index 975f0f83a7b63..b9da468146e23 100644 --- a/tests/baselines/reference/importTypeAmbientMissing.types +++ b/tests/baselines/reference/importTypeAmbientMissing.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/import/importTypeAmbientMissing.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") interface Point { >Point : Point diff --git a/tests/baselines/reference/importTypeLocal.types b/tests/baselines/reference/importTypeLocal.types index 8969260819d71..955a3a6bf46bc 100644 --- a/tests/baselines/reference/importTypeLocal.types +++ b/tests/baselines/reference/importTypeLocal.types @@ -89,7 +89,7 @@ export class Bar2 { } export let shim: typeof import("./foo2") = { ->shim : typeof "tests/cases/conformance/types/import/foo2" +>shim : typeof import("tests/cases/conformance/types/import/foo2") >{ Bar: Bar2} : { Bar: typeof Bar2; } Bar: Bar2 diff --git a/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types b/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types index 986c65ca0fe2c..cd36e8deed34a 100644 --- a/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types +++ b/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types @@ -17,7 +17,7 @@ var p = testData[0].name; === tests/cases/compiler/b.ts === declare module "ITest" { ->"ITest" : typeof "ITest" +>"ITest" : typeof import("ITest") interface Name { >Name : Name diff --git a/tests/baselines/reference/importsInAmbientModules1.types b/tests/baselines/reference/importsInAmbientModules1.types index e0775f26ca5c0..b6279a69d563e 100644 --- a/tests/baselines/reference/importsInAmbientModules1.types +++ b/tests/baselines/reference/importsInAmbientModules1.types @@ -4,7 +4,7 @@ export var x: number === tests/cases/compiler/main.ts === declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") import {x} from "external" >x : number diff --git a/tests/baselines/reference/importsInAmbientModules2.types b/tests/baselines/reference/importsInAmbientModules2.types index 344c7ed87f030..275debe07aa71 100644 --- a/tests/baselines/reference/importsInAmbientModules2.types +++ b/tests/baselines/reference/importsInAmbientModules2.types @@ -4,7 +4,7 @@ export default class C {} === tests/cases/compiler/main.ts === declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") import C from "external" >C : typeof C diff --git a/tests/baselines/reference/importsInAmbientModules3.types b/tests/baselines/reference/importsInAmbientModules3.types index cecc08cf09b9b..e02f7431d7888 100644 --- a/tests/baselines/reference/importsInAmbientModules3.types +++ b/tests/baselines/reference/importsInAmbientModules3.types @@ -1,6 +1,6 @@ === tests/cases/compiler/main.ts === declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") import C = require("external"); >C : typeof C diff --git a/tests/baselines/reference/incompatibleExports1.types b/tests/baselines/reference/incompatibleExports1.types index 3d3acd936d64d..1d49dcfbd9b63 100644 --- a/tests/baselines/reference/incompatibleExports1.types +++ b/tests/baselines/reference/incompatibleExports1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/incompatibleExports1.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export interface x { a: string } >x : x @@ -16,7 +16,7 @@ declare module "foo" { } declare module "baz" { ->"baz" : typeof "baz" +>"baz" : typeof import("baz") export module a { >a : typeof a diff --git a/tests/baselines/reference/incompatibleExports2.types b/tests/baselines/reference/incompatibleExports2.types index 554f6ce2583e1..419bf552f32aa 100644 --- a/tests/baselines/reference/incompatibleExports2.types +++ b/tests/baselines/reference/incompatibleExports2.types @@ -1,6 +1,6 @@ === tests/cases/compiler/incompatibleExports2.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export interface x { a: string } >x : x diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.types b/tests/baselines/reference/jsFileCompilationExternalPackageError.types index 82418aeeb2801..269d8f5cf9d1e 100644 --- a/tests/baselines/reference/jsFileCompilationExternalPackageError.types +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.types @@ -22,7 +22,7 @@ var a = 10; exports.a = 10; >exports.a = 10 : 10 >exports.a : number ->exports : typeof "tests/cases/compiler/node_modules/c" +>exports : typeof import("tests/cases/compiler/node_modules/c") >a : number >10 : 10 diff --git a/tests/baselines/reference/jsxImportInAttribute.types b/tests/baselines/reference/jsxImportInAttribute.types index 1b774110e6d8a..92997d99399af 100644 --- a/tests/baselines/reference/jsxImportInAttribute.types +++ b/tests/baselines/reference/jsxImportInAttribute.types @@ -15,7 +15,7 @@ let x = Test; // emit test_1.default === tests/cases/compiler/component.d.ts === declare module "Test" { ->"Test" : typeof "Test" +>"Test" : typeof import("Test") export default class Text { } >Text : Text diff --git a/tests/baselines/reference/jsxViaImport.2.types b/tests/baselines/reference/jsxViaImport.2.types index 2d2e3bb32bce3..6bfbd8ca31a4c 100644 --- a/tests/baselines/reference/jsxViaImport.2.types +++ b/tests/baselines/reference/jsxViaImport.2.types @@ -35,7 +35,7 @@ declare module React { >U : U } declare module "BaseComponent" { ->"BaseComponent" : typeof "BaseComponent" +>"BaseComponent" : typeof import("BaseComponent") export default class extends React.Component { >React.Component : React.Component diff --git a/tests/baselines/reference/jsxViaImport.types b/tests/baselines/reference/jsxViaImport.types index 17f594536c0a9..b9061e0b7c26f 100644 --- a/tests/baselines/reference/jsxViaImport.types +++ b/tests/baselines/reference/jsxViaImport.types @@ -35,7 +35,7 @@ declare module React { >U : U } declare module "BaseComponent" { ->"BaseComponent" : typeof "BaseComponent" +>"BaseComponent" : typeof import("BaseComponent") var base: React.Component; >base : React.Component diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt index e9455a4efbd2f..edb5e32151f1f 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt @@ -1,4 +1,4 @@ -/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. +/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof import("shortid")'. ==== /tsconfig.json (0 errors) ==== @@ -17,7 +17,7 @@ foo.x // found in index.d.ts foo.y // ignored from shortid/index.js ~ -!!! error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. +!!! error TS2339: Property 'y' does not exist on type 'typeof import("shortid")'. ==== /node_modules/shortid/node_modules/z/index.js (0 errors) ==== diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.types b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.types index 0dfbbb9877f8d..30815e07f5e89 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.types +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.types @@ -16,7 +16,7 @@ foo.y // ignored from shortid/index.js === /typings/index.d.ts === declare module "shortid" { ->"shortid" : typeof "shortid" +>"shortid" : typeof import("shortid") export var x: number; >x : number diff --git a/tests/baselines/reference/mergedDeclarations6.types b/tests/baselines/reference/mergedDeclarations6.types index 89c0d0f4997ae..3b2b5a8d512c2 100644 --- a/tests/baselines/reference/mergedDeclarations6.types +++ b/tests/baselines/reference/mergedDeclarations6.types @@ -23,7 +23,7 @@ import {A} from './a'; >A : typeof A declare module "./a" { ->"./a" : typeof "tests/cases/compiler/a" +>"./a" : typeof import("tests/cases/compiler/a") interface A { } >A : A diff --git a/tests/baselines/reference/missingFunctionImplementation2.types b/tests/baselines/reference/missingFunctionImplementation2.types index 2eae6187560f0..640a7aaecb0a7 100644 --- a/tests/baselines/reference/missingFunctionImplementation2.types +++ b/tests/baselines/reference/missingFunctionImplementation2.types @@ -1,7 +1,7 @@ === tests/cases/compiler/missingFunctionImplementation2_a.ts === export {}; declare module "./missingFunctionImplementation2_b" { ->"./missingFunctionImplementation2_b" : typeof "tests/cases/compiler/missingFunctionImplementation2_b" +>"./missingFunctionImplementation2_b" : typeof import("tests/cases/compiler/missingFunctionImplementation2_b") export function f(a, b): void; >f : { (a?: any, b?: any): any; (a: any, b: any): void; } diff --git a/tests/baselines/reference/missingImportAfterModuleImport.types b/tests/baselines/reference/missingImportAfterModuleImport.types index 3af7f2b179506..c6c1fb265e069 100644 --- a/tests/baselines/reference/missingImportAfterModuleImport.types +++ b/tests/baselines/reference/missingImportAfterModuleImport.types @@ -19,7 +19,7 @@ export = MainModule; === tests/cases/compiler/missingImportAfterModuleImport_0.ts === declare module "SubModule" { ->"SubModule" : typeof "SubModule" +>"SubModule" : typeof import("SubModule") class SubModule { >SubModule : SubModule diff --git a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.types b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.types index 14a155b2035cb..5729746cbb17a 100644 --- a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.types +++ b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.types @@ -14,7 +14,7 @@ import { Observable } from "./observable" >function() { } : () => void declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") interface I {x0} >I : I @@ -37,7 +37,7 @@ import { Observable } from "./observable" >function() { } : () => void declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") interface I {x1} >I : I diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types index 4818543dc857b..e16188eaf6b36 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types @@ -14,7 +14,7 @@ import { Observable } from "./observable" >function() { } : () => void declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types index fc0cbc5c8df05..ea8d2c69c9b9a 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types @@ -14,7 +14,7 @@ import { Observable } from "./observable" >function() { } : () => void declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types index a179b0e06565b..0674941e2577a 100644 --- a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types @@ -13,7 +13,7 @@ namespace N1 { } declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") var x: number; >x : number @@ -72,7 +72,7 @@ declare module "./observable" { } declare module "./test" { ->"./test" : typeof "tests/cases/compiler/test" +>"./test" : typeof import("tests/cases/compiler/test") export = N1; >N1 : typeof N1 diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types index 408429076c4a3..b2586292b1214 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types @@ -37,7 +37,7 @@ import { Observable } from "observable" >function() { } : () => void declare module "observable" { ->"observable" : typeof "observable" +>"observable" : typeof import("observable") interface Observable { >Observable : Observable @@ -63,7 +63,7 @@ declare module "observable" { === tests/cases/compiler/observable.d.ts === declare module "observable" { ->"observable" : typeof "observable" +>"observable" : typeof import("observable") class Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types index b81ac9dba6966..f40b395bb06ac 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types @@ -55,7 +55,7 @@ import { Observable } from "observable" >function() { } : () => void declare module "observable" { ->"observable" : typeof "observable" +>"observable" : typeof import("observable") interface Observable { >Observable : Observable @@ -81,7 +81,7 @@ declare module "observable" { === tests/cases/compiler/observable.d.ts === declare module "observable" { ->"observable" : typeof "observable" +>"observable" : typeof import("observable") class Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule1.types b/tests/baselines/reference/moduleAugmentationExtendFileModule1.types index 4818543dc857b..e16188eaf6b36 100644 --- a/tests/baselines/reference/moduleAugmentationExtendFileModule1.types +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule1.types @@ -14,7 +14,7 @@ import { Observable } from "./observable" >function() { } : () => void declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule2.types b/tests/baselines/reference/moduleAugmentationExtendFileModule2.types index fc0cbc5c8df05..ea8d2c69c9b9a 100644 --- a/tests/baselines/reference/moduleAugmentationExtendFileModule2.types +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule2.types @@ -14,7 +14,7 @@ import { Observable } from "./observable" >function() { } : () => void declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationGlobal5.types b/tests/baselines/reference/moduleAugmentationGlobal5.types index a7a24f1dbceaa..c43a6b454ac7a 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal5.types +++ b/tests/baselines/reference/moduleAugmentationGlobal5.types @@ -7,7 +7,7 @@ No type information for this code. No type information for this code. No type information for this code.=== tests/cases/compiler/f1.d.ts === declare module "A" { ->"A" : typeof "A" +>"A" : typeof import("A") global { >global : any @@ -19,7 +19,7 @@ declare module "A" { } === tests/cases/compiler/f2.d.ts === declare module "B" { ->"B" : typeof "B" +>"B" : typeof import("B") global { >global : any diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.types b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types index f210ce5cdc533..8315676d230b1 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types @@ -28,7 +28,7 @@ A.prototype.foo = function () { return undefined; } >undefined : undefined declare module "./f1" { ->"./f1" : typeof "tests/cases/compiler/f1" +>"./f1" : typeof import("tests/cases/compiler/f1") interface A { >A : A diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.types b/tests/baselines/reference/moduleAugmentationImportsAndExports2.types index 22ae1b1e79fa9..a2340092e5275 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.types @@ -37,7 +37,7 @@ namespace N { } declare module "./f1" { ->"./f1" : typeof "tests/cases/compiler/f1" +>"./f1" : typeof import("tests/cases/compiler/f1") import {B} from "./f2"; >B : typeof B diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types index de54c32c22be1..088ffc66c58fc 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types @@ -37,7 +37,7 @@ namespace N { } declare module "./f1" { ->"./f1" : typeof "tests/cases/compiler/f1" +>"./f1" : typeof import("tests/cases/compiler/f1") import {B} from "./f2"; >B : typeof B diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.types b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types index fdda015987adf..771731ecdb38c 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports4.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types @@ -49,7 +49,7 @@ import C = N.Cls; >Cls : C declare module "./f1" { ->"./f1" : typeof "tests/cases/compiler/f1" +>"./f1" : typeof import("tests/cases/compiler/f1") interface A { >A : A diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.types b/tests/baselines/reference/moduleAugmentationImportsAndExports5.types index fdda015987adf..771731ecdb38c 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.types @@ -49,7 +49,7 @@ import C = N.Cls; >Cls : C declare module "./f1" { ->"./f1" : typeof "tests/cases/compiler/f1" +>"./f1" : typeof import("tests/cases/compiler/f1") interface A { >A : A diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.types b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types index 5631272a77610..4457aefb78dc2 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types @@ -49,7 +49,7 @@ import C = N.Cls; >Cls : C declare module "./f1" { ->"./f1" : typeof "tests/cases/compiler/f1" +>"./f1" : typeof import("tests/cases/compiler/f1") interface A { >A : A diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule1.types b/tests/baselines/reference/moduleAugmentationInAmbientModule1.types index a5de2d5e0c971..428df933b131d 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule1.types +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule1.types @@ -18,14 +18,14 @@ x.foo().x; === tests/cases/compiler/O.d.ts === declare module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") class Observable {} >Observable : Observable } declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") class Cls { x: number } >Cls : Cls @@ -33,13 +33,13 @@ declare module "M" { } declare module "Map" { ->"Map" : typeof "Map" +>"Map" : typeof import("Map") import { Cls } from "M"; >Cls : typeof Cls module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule2.types b/tests/baselines/reference/moduleAugmentationInAmbientModule2.types index bc43861af8934..190a8d568b3c6 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule2.types +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule2.types @@ -19,14 +19,14 @@ x.foo().x; === tests/cases/compiler/O.d.ts === declare module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") class Observable {} >Observable : Observable } declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") class Cls { x: number } >Cls : Cls @@ -34,13 +34,13 @@ declare module "M" { } declare module "Map" { ->"Map" : typeof "Map" +>"Map" : typeof import("Map") import { Cls } from "M"; >Cls : typeof Cls module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule3.types b/tests/baselines/reference/moduleAugmentationInAmbientModule3.types index e2f336101cb49..06efc3c4e869a 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule3.types +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule3.types @@ -27,14 +27,14 @@ x.foo2().x2; === tests/cases/compiler/O.d.ts === declare module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") class Observable {} >Observable : Observable } declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") class Cls { x: number } >Cls : Cls @@ -42,13 +42,13 @@ declare module "M" { } declare module "Map" { ->"Map" : typeof "Map" +>"Map" : typeof import("Map") import { Cls } from "M"; >Cls : typeof Cls module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") interface Observable { >Observable : Observable @@ -61,14 +61,14 @@ declare module "Map" { } declare module "Map" { ->"Map" : typeof "Map" +>"Map" : typeof import("Map") class Cls2 { x2: number } >Cls2 : Cls2 >x2 : number module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule4.types b/tests/baselines/reference/moduleAugmentationInAmbientModule4.types index e6b6b522784ef..bdb2501ac8c0a 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule4.types +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule4.types @@ -28,14 +28,14 @@ x.foo2().x2; === tests/cases/compiler/O.d.ts === declare module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") class Observable {} >Observable : Observable } declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") class Cls { x: number } >Cls : Cls @@ -43,13 +43,13 @@ declare module "M" { } declare module "Map" { ->"Map" : typeof "Map" +>"Map" : typeof import("Map") import { Cls } from "M"; >Cls : typeof Cls module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") interface Observable { >Observable : Observable @@ -63,14 +63,14 @@ declare module "Map" { === tests/cases/compiler/O2.d.ts === declare module "Map" { ->"Map" : typeof "Map" +>"Map" : typeof import("Map") class Cls2 { x2: number } >Cls2 : Cls2 >x2 : number module "Observable" { ->"Observable" : typeof "Observable" +>"Observable" : typeof import("Observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.types b/tests/baselines/reference/moduleAugmentationInAmbientModule5.types index a0ccf73fbc41b..82649bd9a6b7c 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule5.types +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.types @@ -18,7 +18,7 @@ let y = x.getA().x; === tests/cases/compiler/array.d.ts === declare module "A" { ->"A" : typeof "A" +>"A" : typeof import("A") class A { x: number; } >A : A @@ -26,7 +26,7 @@ declare module "A" { } declare module "array" { ->"array" : typeof "array" +>"array" : typeof import("array") import {A} from "A"; >A : typeof A diff --git a/tests/baselines/reference/moduleAugmentationNoNewNames.types b/tests/baselines/reference/moduleAugmentationNoNewNames.types index 5fb6b32ce405a..08bef8ee6e5b5 100644 --- a/tests/baselines/reference/moduleAugmentationNoNewNames.types +++ b/tests/baselines/reference/moduleAugmentationNoNewNames.types @@ -14,7 +14,7 @@ import { Observable } from "./observable" >function() { } : () => void declare module "./observable" { ->"./observable" : typeof "tests/cases/compiler/observable" +>"./observable" : typeof import("tests/cases/compiler/observable") interface Observable { >Observable : Observable diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.types b/tests/baselines/reference/moduleAugmentationsBundledOutput1.types index 7199fd26c0845..6c5ebdccdc34b 100644 --- a/tests/baselines/reference/moduleAugmentationsBundledOutput1.types +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.types @@ -32,7 +32,7 @@ import {Cls} from "./m1"; >"1" : "1" declare module "./m1" { ->"./m1" : typeof "tests/cases/compiler/m1" +>"./m1" : typeof import("tests/cases/compiler/m1") interface Cls { >Cls : Cls @@ -43,7 +43,7 @@ declare module "./m1" { } declare module "./m1" { ->"./m1" : typeof "tests/cases/compiler/m1" +>"./m1" : typeof import("tests/cases/compiler/m1") interface Cls { >Cls : Cls @@ -95,7 +95,7 @@ import {C1, C2} from "./m3"; >undefined : undefined declare module "./m1" { ->"./m1" : typeof "tests/cases/compiler/m1" +>"./m1" : typeof import("tests/cases/compiler/m1") interface Cls { >Cls : Cls @@ -107,7 +107,7 @@ declare module "./m1" { } declare module "./m1" { ->"./m1" : typeof "tests/cases/compiler/m1" +>"./m1" : typeof import("tests/cases/compiler/m1") interface Cls { >Cls : Cls diff --git a/tests/baselines/reference/moduleAugmentationsImports1.types b/tests/baselines/reference/moduleAugmentationsImports1.types index 1ad997647f431..9df5d5b72d4c9 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.types +++ b/tests/baselines/reference/moduleAugmentationsImports1.types @@ -9,7 +9,7 @@ export class B {x: number;} === tests/cases/compiler/c.d.ts === declare module "C" { ->"C" : typeof "C" +>"C" : typeof import("C") class Cls {y: string; } >Cls : Cls @@ -49,7 +49,7 @@ A.prototype.getCls = function () { return undefined; } >undefined : undefined declare module "./a" { ->"./a" : typeof "tests/cases/compiler/a" +>"./a" : typeof import("tests/cases/compiler/a") interface A { >A : A @@ -61,7 +61,7 @@ declare module "./a" { } declare module "./a" { ->"./a" : typeof "tests/cases/compiler/a" +>"./a" : typeof import("tests/cases/compiler/a") interface A { >A : A diff --git a/tests/baselines/reference/moduleAugmentationsImports2.types b/tests/baselines/reference/moduleAugmentationsImports2.types index e331dbc405480..c94186c670adc 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.types +++ b/tests/baselines/reference/moduleAugmentationsImports2.types @@ -9,7 +9,7 @@ export class B {x: number;} === tests/cases/compiler/c.d.ts === declare module "C" { ->"C" : typeof "C" +>"C" : typeof import("C") class Cls {y: string; } >Cls : Cls @@ -36,7 +36,7 @@ A.prototype.getB = function () { return undefined; } >undefined : undefined declare module "./a" { ->"./a" : typeof "tests/cases/compiler/a" +>"./a" : typeof import("tests/cases/compiler/a") interface A { >A : A @@ -65,7 +65,7 @@ A.prototype.getCls = function () { return undefined; } >undefined : undefined declare module "./a" { ->"./a" : typeof "tests/cases/compiler/a" +>"./a" : typeof import("tests/cases/compiler/a") interface A { >A : A diff --git a/tests/baselines/reference/moduleAugmentationsImports3.types b/tests/baselines/reference/moduleAugmentationsImports3.types index eb460364caabc..549885a3e0db8 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.types +++ b/tests/baselines/reference/moduleAugmentationsImports3.types @@ -45,7 +45,7 @@ export class B {x: number;} === tests/cases/compiler/c.d.ts === declare module "C" { ->"C" : typeof "C" +>"C" : typeof import("C") class Cls {y: string; } >Cls : Cls @@ -54,7 +54,7 @@ declare module "C" { === tests/cases/compiler/d.d.ts === declare module "D" { ->"D" : typeof "D" +>"D" : typeof import("D") import {A} from "a"; >A : typeof A @@ -63,7 +63,7 @@ declare module "D" { >B : typeof B module "a" { ->"a" : typeof "tests/cases/compiler/a" +>"a" : typeof import("tests/cases/compiler/a") interface A { >A : A @@ -94,7 +94,7 @@ A.prototype.getCls = function () { return undefined; } >undefined : undefined declare module "./a" { ->"./a" : typeof "tests/cases/compiler/a" +>"./a" : typeof import("tests/cases/compiler/a") interface A { >A : A diff --git a/tests/baselines/reference/moduleAugmentationsImports4.types b/tests/baselines/reference/moduleAugmentationsImports4.types index db56fa15aecd7..530cc5d561915 100644 --- a/tests/baselines/reference/moduleAugmentationsImports4.types +++ b/tests/baselines/reference/moduleAugmentationsImports4.types @@ -46,7 +46,7 @@ export class B {x: number;} === tests/cases/compiler/c.d.ts === declare module "C" { ->"C" : typeof "C" +>"C" : typeof import("C") class Cls {y: string; } >Cls : Cls @@ -55,7 +55,7 @@ declare module "C" { === tests/cases/compiler/d.d.ts === declare module "D" { ->"D" : typeof "D" +>"D" : typeof import("D") import {A} from "a"; >A : typeof A @@ -64,7 +64,7 @@ declare module "D" { >B : typeof B module "a" { ->"a" : typeof "tests/cases/compiler/a" +>"a" : typeof import("tests/cases/compiler/a") interface A { >A : A @@ -79,7 +79,7 @@ declare module "D" { === tests/cases/compiler/e.d.ts === /// declare module "E" { ->"E" : typeof "E" +>"E" : typeof import("E") import {A} from "a"; >A : typeof A @@ -88,7 +88,7 @@ declare module "E" { >Cls : typeof Cls module "a" { ->"a" : typeof "tests/cases/compiler/a" +>"a" : typeof import("tests/cases/compiler/a") interface A { >A : A diff --git a/tests/baselines/reference/moduleElementsInWrongContext2.types b/tests/baselines/reference/moduleElementsInWrongContext2.types index 1f5ead892358d..14b723b37d2ed 100644 --- a/tests/baselines/reference/moduleElementsInWrongContext2.types +++ b/tests/baselines/reference/moduleElementsInWrongContext2.types @@ -17,7 +17,7 @@ function blah () { >K : any declare module "ambient" { ->"ambient" : typeof "ambient" +>"ambient" : typeof import("ambient") } diff --git a/tests/baselines/reference/moduleElementsInWrongContext3.types b/tests/baselines/reference/moduleElementsInWrongContext3.types index 86dfa2ddc22e1..b11e9d57231a4 100644 --- a/tests/baselines/reference/moduleElementsInWrongContext3.types +++ b/tests/baselines/reference/moduleElementsInWrongContext3.types @@ -17,7 +17,7 @@ module P { >K : any declare module "ambient" { ->"ambient" : typeof "ambient" +>"ambient" : typeof import("ambient") } diff --git a/tests/baselines/reference/moduleExportAlias.types b/tests/baselines/reference/moduleExportAlias.types index b1eedf8c2ab1a..ce4e1a8fe7324 100644 --- a/tests/baselines/reference/moduleExportAlias.types +++ b/tests/baselines/reference/moduleExportAlias.types @@ -105,20 +105,20 @@ b.func20; === tests/cases/conformance/salsa/b.js === var exportsAlias = exports; ->exportsAlias : typeof "tests/cases/conformance/salsa/b" ->exports : typeof "tests/cases/conformance/salsa/b" +>exportsAlias : typeof import("tests/cases/conformance/salsa/b") +>exports : typeof import("tests/cases/conformance/salsa/b") exportsAlias.func1 = function () { }; >exportsAlias.func1 = function () { } : () => void >exportsAlias.func1 : () => void ->exportsAlias : typeof "tests/cases/conformance/salsa/b" +>exportsAlias : typeof import("tests/cases/conformance/salsa/b") >func1 : () => void >function () { } : () => void exports.func2 = function () { }; >exports.func2 = function () { } : () => void >exports.func2 : () => void ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") >func2 : () => void >function () { } : () => void @@ -160,17 +160,17 @@ multipleDeclarationAlias1.func5 = function () { }; >function () { } : () => void var multipleDeclarationAlias2 = module.exports = exports; ->multipleDeclarationAlias2 : typeof "tests/cases/conformance/salsa/b" ->module.exports = exports : typeof "tests/cases/conformance/salsa/b" +>multipleDeclarationAlias2 : typeof import("tests/cases/conformance/salsa/b") +>module.exports = exports : typeof import("tests/cases/conformance/salsa/b") >module.exports : any >module : any >exports : any ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") multipleDeclarationAlias2.func6 = function () { }; >multipleDeclarationAlias2.func6 = function () { } : () => void >multipleDeclarationAlias2.func6 : () => void ->multipleDeclarationAlias2 : typeof "tests/cases/conformance/salsa/b" +>multipleDeclarationAlias2 : typeof import("tests/cases/conformance/salsa/b") >func6 : () => void >function () { } : () => void @@ -178,15 +178,15 @@ var someOtherVariable; >someOtherVariable : any var multipleDeclarationAlias3 = someOtherVariable = exports; ->multipleDeclarationAlias3 : typeof "tests/cases/conformance/salsa/b" ->someOtherVariable = exports : typeof "tests/cases/conformance/salsa/b" +>multipleDeclarationAlias3 : typeof import("tests/cases/conformance/salsa/b") +>someOtherVariable = exports : typeof import("tests/cases/conformance/salsa/b") >someOtherVariable : any ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") multipleDeclarationAlias3.func7 = function () { }; >multipleDeclarationAlias3.func7 = function () { } : () => void >multipleDeclarationAlias3.func7 : () => void ->multipleDeclarationAlias3 : typeof "tests/cases/conformance/salsa/b" +>multipleDeclarationAlias3 : typeof import("tests/cases/conformance/salsa/b") >func7 : () => void >function () { } : () => void @@ -253,7 +253,7 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports.func11 = function () { } : () => void >exports.func11 : () => void ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") >func11 : () => void >function () { } : () => void @@ -280,7 +280,7 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports.func11 = function () { } : () => void >exports.func11 : () => void ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") >func11 : () => void >function () { } : () => void @@ -305,7 +305,7 @@ exports = module.exports = {}; exports.func13 = function () { }; >exports.func13 = function () { } : () => void >exports.func13 : () => void ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") >func13 : () => void >function () { } : () => void @@ -330,7 +330,7 @@ exports = module.exports = {}; exports.func15 = function () { }; >exports.func15 = function () { } : () => void >exports.func15 : () => void ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") >func15 : () => void >function () { } : () => void @@ -355,7 +355,7 @@ module.exports = exports = {}; exports.func17 = function () { }; >exports.func17 = function () { } : () => void >exports.func17 : () => void ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") >func17 : () => void >function () { } : () => void @@ -378,7 +378,7 @@ module.exports = {}; exports.func19 = function () { }; >exports.func19 = function () { } : () => void >exports.func19 : () => void ->exports : typeof "tests/cases/conformance/salsa/b" +>exports : typeof import("tests/cases/conformance/salsa/b") >func19 : () => void >function () { } : () => void diff --git a/tests/baselines/reference/moduleMergeConstructor.types b/tests/baselines/reference/moduleMergeConstructor.types index b7e61da4687d2..9cc599b99a149 100644 --- a/tests/baselines/reference/moduleMergeConstructor.types +++ b/tests/baselines/reference/moduleMergeConstructor.types @@ -1,6 +1,6 @@ === tests/cases/compiler/foo.d.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export class Foo { >Foo : Foo @@ -13,7 +13,7 @@ declare module "foo" { === tests/cases/compiler/foo-ext.d.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export interface Foo { >Foo : Foo diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.types b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.types index 23c4b4164e7a8..427dd62b2881d 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.types +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.types @@ -5,7 +5,7 @@ import { x } from "js"; === /declarations.d.ts === declare module "js" { ->"js" : typeof "js" +>"js" : typeof import("js") export const x = 0; >x : 0 diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types index fe7d74c914c87..fabd2b69a4c82 100644 --- a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types @@ -6,7 +6,7 @@ import { x } from "../node_modules/foo"; exports.x = 0; >exports.x = 0 : 0 >exports.x : number ->exports : typeof "/node_modules/foo/index" +>exports : typeof import("/node_modules/foo/index") >x : number >0 : 0 diff --git a/tests/baselines/reference/module_augmentUninstantiatedModule.types b/tests/baselines/reference/module_augmentUninstantiatedModule.types index 1fad9ee86091f..dc887b4b17f9a 100644 --- a/tests/baselines/reference/module_augmentUninstantiatedModule.types +++ b/tests/baselines/reference/module_augmentUninstantiatedModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/module_augmentUninstantiatedModule.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") namespace M {} >M : any @@ -13,7 +13,7 @@ declare module "foo" { } declare module "bar" { ->"bar" : typeof "bar" +>"bar" : typeof import("bar") module "foo" {} >"foo" : any diff --git a/tests/baselines/reference/moduledecl.types b/tests/baselines/reference/moduledecl.types index 567ef6b8c5417..3268e10771a1b 100644 --- a/tests/baselines/reference/moduledecl.types +++ b/tests/baselines/reference/moduledecl.types @@ -303,7 +303,7 @@ declare module m55 { } declare module "m3" { ->"m3" : typeof "m3" +>"m3" : typeof import("m3") export var b: number; >b : number diff --git a/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.types b/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.types index ae94289f7100d..2f7cebd95a0dc 100644 --- a/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.types +++ b/tests/baselines/reference/multipleExportAssignmentsInAmbientDeclaration.types @@ -1,6 +1,6 @@ === tests/cases/compiler/multipleExportAssignmentsInAmbientDeclaration.ts === declare module "m1" { ->"m1" : typeof "m1" +>"m1" : typeof import("m1") var a: number >a : number diff --git a/tests/baselines/reference/nodeResolution5.types b/tests/baselines/reference/nodeResolution5.types index 453f5c319ee83..3cd5d2dd631a4 100644 --- a/tests/baselines/reference/nodeResolution5.types +++ b/tests/baselines/reference/nodeResolution5.types @@ -4,7 +4,7 @@ import y = require("a"); === tests/cases/compiler/node_modules/a.d.ts === declare module "a" { ->"a" : typeof "a" +>"a" : typeof import("a") var x: number; >x : number diff --git a/tests/baselines/reference/nodeResolution7.types b/tests/baselines/reference/nodeResolution7.types index dfe118fd39510..fb31e87a0c79c 100644 --- a/tests/baselines/reference/nodeResolution7.types +++ b/tests/baselines/reference/nodeResolution7.types @@ -4,7 +4,7 @@ import y = require("a"); === tests/cases/compiler/node_modules/a/index.d.ts === declare module "a" { ->"a" : typeof "a" +>"a" : typeof import("a") var x: number; >x : number diff --git a/tests/baselines/reference/paramTagOnCallExpression.types b/tests/baselines/reference/paramTagOnCallExpression.types index c5aa2c7c61130..2c525b61008c6 100644 --- a/tests/baselines/reference/paramTagOnCallExpression.types +++ b/tests/baselines/reference/paramTagOnCallExpression.types @@ -9,7 +9,7 @@ declare function factory(type: string): {}; exports.inherits = factory('inherits') >exports.inherits = factory('inherits') : {} >exports.inherits : {} ->exports : typeof "tests/cases/conformance/jsdoc/a" +>exports : typeof import("tests/cases/conformance/jsdoc/a") >inherits : {} >factory('inherits') : {} >factory : (type: string) => {} diff --git a/tests/baselines/reference/parserExportAssignment6.types b/tests/baselines/reference/parserExportAssignment6.types index 2a850e8a3ee07..b71064254785c 100644 --- a/tests/baselines/reference/parserExportAssignment6.types +++ b/tests/baselines/reference/parserExportAssignment6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment6.ts === declare module "M" { ->"M" : typeof "M" +>"M" : typeof import("M") export = A; >A : any diff --git a/tests/baselines/reference/parserModuleDeclaration1.d.types b/tests/baselines/reference/parserModuleDeclaration1.d.types index 0ccbe7ea89675..85c8e16f5559e 100644 --- a/tests/baselines/reference/parserModuleDeclaration1.d.types +++ b/tests/baselines/reference/parserModuleDeclaration1.d.types @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration1.d.ts === module "Foo" { ->"Foo" : typeof "Foo" +>"Foo" : typeof import("Foo") } diff --git a/tests/baselines/reference/parserModuleDeclaration1.types b/tests/baselines/reference/parserModuleDeclaration1.types index f37435dacbd49..d64ef67326407 100644 --- a/tests/baselines/reference/parserModuleDeclaration1.types +++ b/tests/baselines/reference/parserModuleDeclaration1.types @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration1.ts === module "Foo" { ->"Foo" : typeof "Foo" +>"Foo" : typeof import("Foo") } diff --git a/tests/baselines/reference/parserModuleDeclaration2.types b/tests/baselines/reference/parserModuleDeclaration2.types index 5794fdcca173b..839a7e5b23ad4 100644 --- a/tests/baselines/reference/parserModuleDeclaration2.types +++ b/tests/baselines/reference/parserModuleDeclaration2.types @@ -1,4 +1,4 @@ === tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration2.ts === declare module "Foo" { ->"Foo" : typeof "Foo" +>"Foo" : typeof import("Foo") } diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.types b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.types index 6eba8b6eb1cc1..acff252dad755 100644 --- a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.types +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.types @@ -239,7 +239,7 @@ class privateClassWithPrivateModuleGetAccessorTypes { } === tests/cases/compiler/privacyCannotNameAccessorDeclFile_GlobalWidgets.ts === declare module "GlobalWidgets" { ->"GlobalWidgets" : typeof "GlobalWidgets" +>"GlobalWidgets" : typeof import("GlobalWidgets") export class Widget3 { >Widget3 : Widget3 diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.types b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.types index 2ceffd034e16d..0263f5c82f375 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.types +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.types @@ -242,7 +242,7 @@ var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4() === tests/cases/compiler/privacyCannotNameVarTypeDeclFile_GlobalWidgets.ts === declare module "GlobalWidgets" { ->"GlobalWidgets" : typeof "GlobalWidgets" +>"GlobalWidgets" : typeof import("GlobalWidgets") export class Widget3 { >Widget3 : Widget3 diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.types b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.types index c6ea5d358be94..7c9147180f3ea 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.types +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.types @@ -434,7 +434,7 @@ function privateFunctionWithPrivateModuleParameterTypes1(param= exporter.createE } === tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_GlobalWidgets.ts === declare module "GlobalWidgets" { ->"GlobalWidgets" : typeof "GlobalWidgets" +>"GlobalWidgets" : typeof import("GlobalWidgets") export class Widget3 { >Widget3 : Widget3 diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.types b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.types index 863ca2e7c5105..a5de70a04e9c5 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.types +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.types @@ -313,7 +313,7 @@ function privateFunctionWithPrivateModuleReturnTypes1() { === tests/cases/compiler/privacyFunctionReturnTypeDeclFile_GlobalWidgets.ts === declare module "GlobalWidgets" { ->"GlobalWidgets" : typeof "GlobalWidgets" +>"GlobalWidgets" : typeof import("GlobalWidgets") export class Widget3 { >Widget3 : Widget3 diff --git a/tests/baselines/reference/privacyGloImport.types b/tests/baselines/reference/privacyGloImport.types index 263e36cbc0e76..c96cec357f428 100644 --- a/tests/baselines/reference/privacyGloImport.types +++ b/tests/baselines/reference/privacyGloImport.types @@ -230,7 +230,7 @@ module glo_M1_public { } declare module "glo_M2_public" { ->"glo_M2_public" : typeof "glo_M2_public" +>"glo_M2_public" : typeof import("glo_M2_public") export function f1(); >f1 : () => any @@ -248,7 +248,7 @@ declare module "glo_M2_public" { } declare module "use_glo_M1_public" { ->"use_glo_M1_public" : typeof "use_glo_M1_public" +>"use_glo_M1_public" : typeof import("use_glo_M1_public") import use_glo_M1_public = glo_M1_public; >use_glo_M1_public : typeof use_glo_M1_public @@ -333,7 +333,7 @@ declare module "use_glo_M1_public" { } declare module "anotherParseError" { ->"anotherParseError" : typeof "anotherParseError" +>"anotherParseError" : typeof import("anotherParseError") module m2 { >m2 : any diff --git a/tests/baselines/reference/privacyGloImportParseErrors.types b/tests/baselines/reference/privacyGloImportParseErrors.types index e6d615c355050..e1b5eecc2fe68 100644 --- a/tests/baselines/reference/privacyGloImportParseErrors.types +++ b/tests/baselines/reference/privacyGloImportParseErrors.types @@ -47,7 +47,7 @@ module m1 { } export declare module "m1_M3_public" { ->"m1_M3_public" : typeof "m1_M3_public" +>"m1_M3_public" : typeof import("m1_M3_public") export function f1(); >f1 : () => any @@ -65,7 +65,7 @@ module m1 { } declare module "m1_M4_private" { ->"m1_M4_private" : typeof "m1_M4_private" +>"m1_M4_private" : typeof import("m1_M4_private") export function f1(); >f1 : () => any @@ -343,7 +343,7 @@ module glo_M1_public { } declare module "glo_M2_public" { ->"glo_M2_public" : typeof "glo_M2_public" +>"glo_M2_public" : typeof import("glo_M2_public") export function f1(); >f1 : () => any @@ -361,7 +361,7 @@ declare module "glo_M2_public" { } declare module "use_glo_M1_public" { ->"use_glo_M1_public" : typeof "use_glo_M1_public" +>"use_glo_M1_public" : typeof import("use_glo_M1_public") import use_glo_M1_public = glo_M1_public; >use_glo_M1_public : typeof use_glo_M1_public @@ -450,13 +450,13 @@ declare module "use_glo_M1_public" { } declare module "anotherParseError" { ->"anotherParseError" : typeof "anotherParseError" +>"anotherParseError" : typeof import("anotherParseError") module m2 { >m2 : any declare module "abc" { ->"abc" : typeof "abc" +>"abc" : typeof import("abc") } } @@ -464,7 +464,7 @@ declare module "anotherParseError" { >m2 : any module "abc2" { ->"abc2" : typeof "abc2" +>"abc2" : typeof import("abc2") } } module "abc3" { diff --git a/tests/baselines/reference/privacyImportParseErrors.types b/tests/baselines/reference/privacyImportParseErrors.types index ff9bf75f2b244..2f6c9e87dee2b 100644 --- a/tests/baselines/reference/privacyImportParseErrors.types +++ b/tests/baselines/reference/privacyImportParseErrors.types @@ -47,7 +47,7 @@ export module m1 { } export declare module "m1_M3_public" { ->"m1_M3_public" : typeof "m1_M3_public" +>"m1_M3_public" : typeof import("m1_M3_public") export function f1(); >f1 : () => any @@ -65,7 +65,7 @@ export module m1 { } declare module "m1_M4_private" { ->"m1_M4_private" : typeof "m1_M4_private" +>"m1_M4_private" : typeof import("m1_M4_private") export function f1(); >f1 : () => any @@ -368,7 +368,7 @@ module m2 { } export declare module "m2_M3_public" { ->"m2_M3_public" : typeof "m2_M3_public" +>"m2_M3_public" : typeof import("m2_M3_public") export function f1(); >f1 : () => any @@ -386,7 +386,7 @@ module m2 { } declare module "m2_M4_private" { ->"m2_M4_private" : typeof "m2_M4_private" +>"m2_M4_private" : typeof import("m2_M4_private") export function f1(); >f1 : () => any @@ -665,7 +665,7 @@ export module glo_M1_public { } export declare module "glo_M2_public" { ->"glo_M2_public" : typeof "glo_M2_public" +>"glo_M2_public" : typeof import("glo_M2_public") export function f1(); >f1 : () => any @@ -705,7 +705,7 @@ export module glo_M3_private { } export declare module "glo_M4_private" { ->"glo_M4_private" : typeof "glo_M4_private" +>"glo_M4_private" : typeof import("glo_M4_private") export function f1(); >f1 : () => any @@ -963,7 +963,7 @@ export import glo_im4_public = require("glo_M4_private"); export declare module "use_glo_M1_public" { ->"use_glo_M1_public" : typeof "use_glo_M1_public" +>"use_glo_M1_public" : typeof import("use_glo_M1_public") import use_glo_M1_public = glo_M1_public; >use_glo_M1_public : typeof use_glo_M1_public @@ -1053,7 +1053,7 @@ export declare module "use_glo_M1_public" { declare module "use_glo_M3_private" { ->"use_glo_M3_private" : typeof "use_glo_M3_private" +>"use_glo_M3_private" : typeof import("use_glo_M3_private") import use_glo_M3_private = glo_M3_private; >use_glo_M3_private : typeof use_glo_M3_private @@ -1148,7 +1148,7 @@ declare module "anotherParseError" { >m2 : any declare module "abc" { ->"abc" : typeof "abc" +>"abc" : typeof import("abc") } } @@ -1156,11 +1156,11 @@ declare module "anotherParseError" { >m2 : any module "abc2" { ->"abc2" : typeof "abc2" +>"abc2" : typeof import("abc2") } } module "abc3" { ->"abc3" : typeof "abc3" +>"abc3" : typeof import("abc3") } } @@ -1171,7 +1171,7 @@ declare export module "anotherParseError2" { >m2 : any declare module "abc" { ->"abc" : typeof "abc" +>"abc" : typeof import("abc") } } @@ -1179,11 +1179,11 @@ declare export module "anotherParseError2" { >m2 : any module "abc2" { ->"abc2" : typeof "abc2" +>"abc2" : typeof import("abc2") } } module "abc3" { ->"abc3" : typeof "abc3" +>"abc3" : typeof import("abc3") } } diff --git a/tests/baselines/reference/reactNamespaceImportPresevation.types b/tests/baselines/reference/reactNamespaceImportPresevation.types index 55c11d3e44a2b..a7596dd6d8227 100644 --- a/tests/baselines/reference/reactNamespaceImportPresevation.types +++ b/tests/baselines/reference/reactNamespaceImportPresevation.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modules.d.ts === declare module "my-React-Lib" { ->"my-React-Lib" : typeof "my-React-Lib" +>"my-React-Lib" : typeof import("my-React-Lib") var a: any; >a : any diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.types b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.types index 22566d71c0f75..c168a4f2878bf 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.types +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.types @@ -12,7 +12,7 @@ export var b: ClassB; // This should result in type ClassB === tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType1_moduleDef.d.ts === declare module "moduleC" { ->"moduleC" : typeof "moduleC" +>"moduleC" : typeof import("moduleC") import self = require("moduleC"); >self : any diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.types b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.types index 9c7bb322c9303..48ed382d03577 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.types +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.types @@ -12,7 +12,7 @@ export var b: ClassB; // This should result in type ClassB === tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType2_moduleDef.d.ts === declare module "moduleC" { ->"moduleC" : typeof "moduleC" +>"moduleC" : typeof import("moduleC") import self = require("moduleD"); >self : any @@ -21,7 +21,7 @@ declare module "moduleC" { >self : any } declare module "moduleD" { ->"moduleD" : typeof "moduleD" +>"moduleD" : typeof import("moduleD") import self = require("moduleC"); >self : any diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.types b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.types index 81654cb4f7c52..758df16a80569 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.types +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.types @@ -12,7 +12,7 @@ export var b: ClassB; // This should result in type ClassB === tests/cases/compiler/recursiveExportAssignmentAndFindAliasedType3_moduleDef.d.ts === declare module "moduleC" { ->"moduleC" : typeof "moduleC" +>"moduleC" : typeof import("moduleC") import self = require("moduleD"); >self : any @@ -21,7 +21,7 @@ declare module "moduleC" { >self : any } declare module "moduleD" { ->"moduleD" : typeof "moduleD" +>"moduleD" : typeof import("moduleD") import self = require("moduleE"); >self : any @@ -30,7 +30,7 @@ declare module "moduleD" { >self : any } declare module "moduleE" { ->"moduleE" : typeof "moduleE" +>"moduleE" : typeof import("moduleE") import self = require("moduleC"); >self : any diff --git a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.types b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.types index fd732fd26201b..1023cbf00ed44 100644 --- a/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.types +++ b/tests/baselines/reference/resolveModuleNameWithSameLetDeclarationName2.types @@ -1,6 +1,6 @@ === tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts === declare module "punycode" { ->"punycode" : typeof "punycode" +>"punycode" : typeof import("punycode") interface ucs2 { >ucs2 : ucs2 diff --git a/tests/baselines/reference/shebangBeforeReferences.types b/tests/baselines/reference/shebangBeforeReferences.types index db04f7e6602ed..b8cc364cda535 100644 --- a/tests/baselines/reference/shebangBeforeReferences.types +++ b/tests/baselines/reference/shebangBeforeReferences.types @@ -17,7 +17,7 @@ use(x); === tests/cases/compiler/f.d.ts === declare module "test" { ->"test" : typeof "test" +>"test" : typeof import("test") let x: number; >x : number diff --git a/tests/baselines/reference/spellingSuggestionModule.types b/tests/baselines/reference/spellingSuggestionModule.types index 3e97894504e66..85f8b62fb6bd0 100644 --- a/tests/baselines/reference/spellingSuggestionModule.types +++ b/tests/baselines/reference/spellingSuggestionModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/spellingSuggestionModule.ts === declare module "foobar" { export const x: number; } ->"foobar" : typeof "foobar" +>"foobar" : typeof import("foobar") >x : number foobar; diff --git a/tests/baselines/reference/systemExportAssignment3.types b/tests/baselines/reference/systemExportAssignment3.types index 7265f066c8d00..e550a7de47dc6 100644 --- a/tests/baselines/reference/systemExportAssignment3.types +++ b/tests/baselines/reference/systemExportAssignment3.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modules.d.ts === declare module "a" { ->"a" : typeof "a" +>"a" : typeof import("a") var a: number; >a : number diff --git a/tests/baselines/reference/topLevelAmbientModule.types b/tests/baselines/reference/topLevelAmbientModule.types index 7edf8d7b9878f..da7db2252d7d8 100644 --- a/tests/baselines/reference/topLevelAmbientModule.types +++ b/tests/baselines/reference/topLevelAmbientModule.types @@ -13,7 +13,7 @@ var z = foo.x + 10; === tests/cases/conformance/externalModules/foo_0.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export var x: number; >x : number diff --git a/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt b/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt index cb555b7a603ca..ef8d2164d42ff 100644 --- a/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt +++ b/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/foo_2.ts(3,14): error TS2339: Property 'x' does not exist on type 'typeof "vs/foo_0"'. +tests/cases/conformance/externalModules/foo_2.ts(3,14): error TS2339: Property 'x' does not exist on type 'typeof import("vs/foo_0")'. ==== tests/cases/conformance/externalModules/foo_2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/externalModules/foo_2.ts(3,14): error TS2339: Property ' import foo = require("vs/foo_0"); var z1 = foo.x + 10; // Should error, as declaration should win ~ -!!! error TS2339: Property 'x' does not exist on type 'typeof "vs/foo_0"'. +!!! error TS2339: Property 'x' does not exist on type 'typeof import("vs/foo_0")'. var z2 = foo.y() + 10; // Should resolve ==== tests/cases/conformance/externalModules/vs/foo_0/index.ts (0 errors) ==== diff --git a/tests/baselines/reference/topLevelModuleDeclarationAndFile.types b/tests/baselines/reference/topLevelModuleDeclarationAndFile.types index a80254e7a6238..b1138fff39cab 100644 --- a/tests/baselines/reference/topLevelModuleDeclarationAndFile.types +++ b/tests/baselines/reference/topLevelModuleDeclarationAndFile.types @@ -22,7 +22,7 @@ var z2 = foo.y() + 10; // Should resolve === tests/cases/conformance/externalModules/foo_1.ts === declare module "vs/foo_0" { ->"vs/foo_0" : typeof "vs/foo_0" +>"vs/foo_0" : typeof import("vs/foo_0") export var y: () => number; >y : () => number diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.types b/tests/baselines/reference/transformNestedGeneratorsWithTry.types index 84cf51794f248..babbe8baef633 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.types +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.types @@ -38,7 +38,7 @@ async function a(): Bluebird { === tests/cases/compiler/bluebird.d.ts === declare module "bluebird" { ->"bluebird" : typeof "bluebird" +>"bluebird" : typeof import("bluebird") type Bluebird = Promise; >Bluebird : Promise diff --git a/tests/baselines/reference/tsxElementResolution19.types b/tests/baselines/reference/tsxElementResolution19.types index 03157790e7b34..e93252f20bc4a 100644 --- a/tests/baselines/reference/tsxElementResolution19.types +++ b/tests/baselines/reference/tsxElementResolution19.types @@ -1,6 +1,6 @@ === tests/cases/conformance/jsx/react.d.ts === declare module "react" { ->"react" : typeof "react" +>"react" : typeof import("react") } diff --git a/tests/baselines/reference/typeAliasExport.types b/tests/baselines/reference/typeAliasExport.types index 5cbea867ad3be..906e1a0515d6d 100644 --- a/tests/baselines/reference/typeAliasExport.types +++ b/tests/baselines/reference/typeAliasExport.types @@ -1,6 +1,6 @@ === tests/cases/compiler/typeAliasExport.ts === declare module "a" { ->"a" : typeof "a" +>"a" : typeof import("a") export default undefined >undefined : undefined diff --git a/tests/baselines/reference/typeFromParamTagForFunction.types b/tests/baselines/reference/typeFromParamTagForFunction.types index 98bd16824557a..ff2403653d3bd 100644 --- a/tests/baselines/reference/typeFromParamTagForFunction.types +++ b/tests/baselines/reference/typeFromParamTagForFunction.types @@ -11,7 +11,7 @@ declare var module: any, exports: any; exports.A = function () { >exports.A = function () { this.x = 1;} : () => void >exports.A : () => void ->exports : typeof "tests/cases/conformance/salsa/a-ext" +>exports : typeof import("tests/cases/conformance/salsa/a-ext") >A : () => void >function () { this.x = 1;} : () => void @@ -27,7 +27,7 @@ exports.A = function () { === tests/cases/conformance/salsa/a.js === const { A } = require("./a-ext"); >A : () => void ->require("./a-ext") : typeof "tests/cases/conformance/salsa/a-ext" +>require("./a-ext") : typeof import("tests/cases/conformance/salsa/a-ext") >require : (id: string) => any >"./a-ext" : "./a-ext" @@ -43,7 +43,7 @@ function a(p) { p.x; } exports.B = class { >exports.B = class { constructor() { this.x = 1; }} : typeof (Anonymous class) >exports.B : typeof (Anonymous class) ->exports : typeof "tests/cases/conformance/salsa/b-ext" +>exports : typeof import("tests/cases/conformance/salsa/b-ext") >B : typeof (Anonymous class) >class { constructor() { this.x = 1; }} : typeof (Anonymous class) @@ -60,7 +60,7 @@ exports.B = class { === tests/cases/conformance/salsa/b.js === const { B } = require("./b-ext"); >B : typeof (Anonymous class) ->require("./b-ext") : typeof "tests/cases/conformance/salsa/b-ext" +>require("./b-ext") : typeof import("tests/cases/conformance/salsa/b-ext") >require : (id: string) => any >"./b-ext" : "./b-ext" @@ -87,7 +87,7 @@ export function C() { === tests/cases/conformance/salsa/c.js === const { C } = require("./c-ext"); >C : () => void ->require("./c-ext") : typeof "tests/cases/conformance/salsa/c-ext" +>require("./c-ext") : typeof import("tests/cases/conformance/salsa/c-ext") >require : (id: string) => any >"./c-ext" : "./c-ext" @@ -116,7 +116,7 @@ export var D = function() { === tests/cases/conformance/salsa/d.js === const { D } = require("./d-ext"); >D : () => void ->require("./d-ext") : typeof "tests/cases/conformance/salsa/d-ext" +>require("./d-ext") : typeof import("tests/cases/conformance/salsa/d-ext") >require : (id: string) => any >"./d-ext" : "./d-ext" @@ -145,7 +145,7 @@ export class E { === tests/cases/conformance/salsa/e.js === const { E } = require("./e-ext"); >E : typeof E ->require("./e-ext") : typeof "tests/cases/conformance/salsa/e-ext" +>require("./e-ext") : typeof import("tests/cases/conformance/salsa/e-ext") >require : (id: string) => any >"./e-ext" : "./e-ext" diff --git a/tests/baselines/reference/typeReferenceDirectives12.types b/tests/baselines/reference/typeReferenceDirectives12.types index 3503de37ad3b1..552f6f2dbf0cf 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.types +++ b/tests/baselines/reference/typeReferenceDirectives12.types @@ -53,7 +53,7 @@ Cls.prototype.foo = function() { return undefined; } >undefined : undefined declare module "./main" { ->"./main" : typeof "/main" +>"./main" : typeof import("/main") interface Cls { >Cls : Cls diff --git a/tests/baselines/reference/typeReferenceDirectives9.types b/tests/baselines/reference/typeReferenceDirectives9.types index 3503de37ad3b1..552f6f2dbf0cf 100644 --- a/tests/baselines/reference/typeReferenceDirectives9.types +++ b/tests/baselines/reference/typeReferenceDirectives9.types @@ -53,7 +53,7 @@ Cls.prototype.foo = function() { return undefined; } >undefined : undefined declare module "./main" { ->"./main" : typeof "/main" +>"./main" : typeof import("/main") interface Cls { >Cls : Cls diff --git a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types index 94411e4cfda68..d0ba83364fd5e 100644 --- a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types +++ b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types @@ -17,7 +17,7 @@ x + y + z; === /node_modules/@types/dopey/index.d.ts === declare module "xyz" { ->"xyz" : typeof "xyz" +>"xyz" : typeof import("xyz") export const x: number; >x : number @@ -25,7 +25,7 @@ declare module "xyz" { === /foo/node_modules/@types/grumpy/index.d.ts === declare module "pdq" { ->"pdq" : typeof "pdq" +>"pdq" : typeof import("pdq") export const y: number; >y : number @@ -33,7 +33,7 @@ declare module "pdq" { === /foo/node_modules/@types/sneezy/index.d.ts === declare module "abc" { ->"abc" : typeof "abc" +>"abc" : typeof import("abc") export const z: number; >z : number diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types index 9288256420df6..f1651eeec2a9e 100644 --- a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types @@ -7,7 +7,7 @@ x; === /node_modules/@types/foo/index.d.ts === declare module "xyz" { ->"xyz" : typeof "xyz" +>"xyz" : typeof import("xyz") export const x: number; >x : number diff --git a/tests/baselines/reference/typeofAmbientExternalModules.errors.txt b/tests/baselines/reference/typeofAmbientExternalModules.errors.txt index 9046972c895c1..a3f8266dd8af3 100644 --- a/tests/baselines/reference/typeofAmbientExternalModules.errors.txt +++ b/tests/baselines/reference/typeofAmbientExternalModules.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/typeofAmbientExternalModules_2.ts(7,1): error TS2322: Type 'typeof D' is not assignable to type 'typeof "tests/cases/compiler/typeofAmbientExternalModules_0"'. +tests/cases/compiler/typeofAmbientExternalModules_2.ts(7,1): error TS2322: Type 'typeof D' is not assignable to type 'typeof import("tests/cases/compiler/typeofAmbientExternalModules_0")'. Property 'C' is missing in type 'typeof D'. -tests/cases/compiler/typeofAmbientExternalModules_2.ts(9,1): error TS2322: Type 'typeof "tests/cases/compiler/typeofAmbientExternalModules_0"' is not assignable to type 'typeof D'. - Property 'prototype' is missing in type 'typeof "tests/cases/compiler/typeofAmbientExternalModules_0"'. +tests/cases/compiler/typeofAmbientExternalModules_2.ts(9,1): error TS2322: Type 'typeof import("tests/cases/compiler/typeofAmbientExternalModules_0")' is not assignable to type 'typeof D'. + Property 'prototype' is missing in type 'typeof import("tests/cases/compiler/typeofAmbientExternalModules_0")'. ==== tests/cases/compiler/typeofAmbientExternalModules_2.ts (2 errors) ==== @@ -13,13 +13,13 @@ tests/cases/compiler/typeofAmbientExternalModules_2.ts(9,1): error TS2322: Type var y1: typeof ext = ext; y1 = exp; ~~ -!!! error TS2322: Type 'typeof D' is not assignable to type 'typeof "tests/cases/compiler/typeofAmbientExternalModules_0"'. +!!! error TS2322: Type 'typeof D' is not assignable to type 'typeof import("tests/cases/compiler/typeofAmbientExternalModules_0")'. !!! error TS2322: Property 'C' is missing in type 'typeof D'. var y2: typeof exp = exp; y2 = ext; ~~ -!!! error TS2322: Type 'typeof "tests/cases/compiler/typeofAmbientExternalModules_0"' is not assignable to type 'typeof D'. -!!! error TS2322: Property 'prototype' is missing in type 'typeof "tests/cases/compiler/typeofAmbientExternalModules_0"'. +!!! error TS2322: Type 'typeof import("tests/cases/compiler/typeofAmbientExternalModules_0")' is not assignable to type 'typeof D'. +!!! error TS2322: Property 'prototype' is missing in type 'typeof import("tests/cases/compiler/typeofAmbientExternalModules_0")'. ==== tests/cases/compiler/typeofAmbientExternalModules_0.ts (0 errors) ==== export class C { foo: string; } diff --git a/tests/baselines/reference/typeofExternalModules.errors.txt b/tests/baselines/reference/typeofExternalModules.errors.txt index 0290a40c3263f..46b9d49d900b5 100644 --- a/tests/baselines/reference/typeofExternalModules.errors.txt +++ b/tests/baselines/reference/typeofExternalModules.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/typeofExternalModules_core.ts(5,1): error TS2322: Type 'typeof D' is not assignable to type 'typeof "tests/cases/compiler/typeofExternalModules_external"'. +tests/cases/compiler/typeofExternalModules_core.ts(5,1): error TS2322: Type 'typeof D' is not assignable to type 'typeof import("tests/cases/compiler/typeofExternalModules_external")'. Property 'C' is missing in type 'typeof D'. -tests/cases/compiler/typeofExternalModules_core.ts(7,1): error TS2322: Type 'typeof "tests/cases/compiler/typeofExternalModules_external"' is not assignable to type 'typeof D'. - Property 'prototype' is missing in type 'typeof "tests/cases/compiler/typeofExternalModules_external"'. +tests/cases/compiler/typeofExternalModules_core.ts(7,1): error TS2322: Type 'typeof import("tests/cases/compiler/typeofExternalModules_external")' is not assignable to type 'typeof D'. + Property 'prototype' is missing in type 'typeof import("tests/cases/compiler/typeofExternalModules_external")'. ==== tests/cases/compiler/typeofExternalModules_core.ts (2 errors) ==== @@ -11,13 +11,13 @@ tests/cases/compiler/typeofExternalModules_core.ts(7,1): error TS2322: Type 'typ var y1: typeof ext = ext; y1 = exp; ~~ -!!! error TS2322: Type 'typeof D' is not assignable to type 'typeof "tests/cases/compiler/typeofExternalModules_external"'. +!!! error TS2322: Type 'typeof D' is not assignable to type 'typeof import("tests/cases/compiler/typeofExternalModules_external")'. !!! error TS2322: Property 'C' is missing in type 'typeof D'. var y2: typeof exp = exp; y2 = ext; ~~ -!!! error TS2322: Type 'typeof "tests/cases/compiler/typeofExternalModules_external"' is not assignable to type 'typeof D'. -!!! error TS2322: Property 'prototype' is missing in type 'typeof "tests/cases/compiler/typeofExternalModules_external"'. +!!! error TS2322: Type 'typeof import("tests/cases/compiler/typeofExternalModules_external")' is not assignable to type 'typeof D'. +!!! error TS2322: Property 'prototype' is missing in type 'typeof import("tests/cases/compiler/typeofExternalModules_external")'. ==== tests/cases/compiler/typeofExternalModules_external.ts (0 errors) ==== export class C { } diff --git a/tests/baselines/reference/typesOnlyExternalModuleStillHasInstance.errors.txt b/tests/baselines/reference/typesOnlyExternalModuleStillHasInstance.errors.txt index 4af38220c078c..6f8a0e185954a 100644 --- a/tests/baselines/reference/typesOnlyExternalModuleStillHasInstance.errors.txt +++ b/tests/baselines/reference/typesOnlyExternalModuleStillHasInstance.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/externalModules/foo_1.ts(5,5): error TS2322: Type 'typeof "tests/cases/conformance/externalModules/foo_0"' is not assignable to type '{ M2: Object; }'. - Property 'M2' is missing in type 'typeof "tests/cases/conformance/externalModules/foo_0"'. +tests/cases/conformance/externalModules/foo_1.ts(5,5): error TS2322: Type 'typeof import("tests/cases/conformance/externalModules/foo_0")' is not assignable to type '{ M2: Object; }'. + Property 'M2' is missing in type 'typeof import("tests/cases/conformance/externalModules/foo_0")'. ==== tests/cases/conformance/externalModules/foo_1.ts (1 errors) ==== @@ -9,8 +9,8 @@ tests/cases/conformance/externalModules/foo_1.ts(5,5): error TS2322: Type 'typeo var x: typeof foo0 = {}; var y: {M2: Object} = foo0; ~ -!!! error TS2322: Type 'typeof "tests/cases/conformance/externalModules/foo_0"' is not assignable to type '{ M2: Object; }'. -!!! error TS2322: Property 'M2' is missing in type 'typeof "tests/cases/conformance/externalModules/foo_0"'. +!!! error TS2322: Type 'typeof import("tests/cases/conformance/externalModules/foo_0")' is not assignable to type '{ M2: Object; }'. +!!! error TS2322: Property 'M2' is missing in type 'typeof import("tests/cases/conformance/externalModules/foo_0")'. ==== tests/cases/conformance/externalModules/foo_0.ts (0 errors) ==== export interface Person { diff --git a/tests/baselines/reference/umd-augmentation-1.types b/tests/baselines/reference/umd-augmentation-1.types index 0df11a2009a15..9909c549ecc44 100644 --- a/tests/baselines/reference/umd-augmentation-1.types +++ b/tests/baselines/reference/umd-augmentation-1.types @@ -47,7 +47,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof "tests/cases/conformance/externalModules/node_modules/math2d/index" +>Math2d : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index") export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index 2effb43fb7693..d84c4d4a0207e 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -45,7 +45,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof "tests/cases/conformance/externalModules/node_modules/math2d/index" +>Math2d : typeof import("tests/cases/conformance/externalModules/node_modules/math2d/index") export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-errors.types b/tests/baselines/reference/umd-errors.types index 5464613dc1421..6aaddbc07d20e 100644 --- a/tests/baselines/reference/umd-errors.types +++ b/tests/baselines/reference/umd-errors.types @@ -6,7 +6,7 @@ export as namespace Foo; === tests/cases/conformance/externalModules/err2.d.ts === // Illegal, can't be in external ambient module declare module "Foo" { ->"Foo" : typeof "Foo" +>"Foo" : typeof import("Foo") export as namespace Bar; >Bar : No type information available! @@ -18,16 +18,16 @@ export var p; >p : any static export as namespace oo1; ->oo1 : typeof "tests/cases/conformance/externalModules/err3" +>oo1 : typeof import("tests/cases/conformance/externalModules/err3") declare export as namespace oo2; ->oo2 : typeof "tests/cases/conformance/externalModules/err3" +>oo2 : typeof import("tests/cases/conformance/externalModules/err3") public export as namespace oo3; ->oo3 : typeof "tests/cases/conformance/externalModules/err3" +>oo3 : typeof import("tests/cases/conformance/externalModules/err3") const export as namespace oo4; ->oo4 : typeof "tests/cases/conformance/externalModules/err3" +>oo4 : typeof import("tests/cases/conformance/externalModules/err3") === tests/cases/conformance/externalModules/err4.d.ts === // Illegal, must be at top-level diff --git a/tests/baselines/reference/umd1.types b/tests/baselines/reference/umd1.types index b84aaf3ad7031..ca4a06270eb5d 100644 --- a/tests/baselines/reference/umd1.types +++ b/tests/baselines/reference/umd1.types @@ -30,5 +30,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof "tests/cases/conformance/externalModules/foo" +>Foo : typeof import("tests/cases/conformance/externalModules/foo") diff --git a/tests/baselines/reference/umd3.types b/tests/baselines/reference/umd3.types index ef54806a174e9..96175ceaf3017 100644 --- a/tests/baselines/reference/umd3.types +++ b/tests/baselines/reference/umd3.types @@ -32,5 +32,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof "tests/cases/conformance/externalModules/foo" +>Foo : typeof import("tests/cases/conformance/externalModules/foo") diff --git a/tests/baselines/reference/umd4.types b/tests/baselines/reference/umd4.types index 3b6ebfa6ca78e..0005c0d83aa2a 100644 --- a/tests/baselines/reference/umd4.types +++ b/tests/baselines/reference/umd4.types @@ -32,5 +32,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof "tests/cases/conformance/externalModules/foo" +>Foo : typeof import("tests/cases/conformance/externalModules/foo") diff --git a/tests/baselines/reference/umd5.types b/tests/baselines/reference/umd5.types index abd1c2b7d4767..ef790eba28809 100644 --- a/tests/baselines/reference/umd5.types +++ b/tests/baselines/reference/umd5.types @@ -37,5 +37,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof "tests/cases/conformance/externalModules/foo" +>Foo : typeof import("tests/cases/conformance/externalModules/foo") diff --git a/tests/baselines/reference/umdGlobalConflict.types b/tests/baselines/reference/umdGlobalConflict.types index 0bb26b47918bc..1d7cc259a3374 100644 --- a/tests/baselines/reference/umdGlobalConflict.types +++ b/tests/baselines/reference/umdGlobalConflict.types @@ -1,13 +1,13 @@ === tests/cases/compiler/v1/index.d.ts === export as namespace Alpha; ->Alpha : typeof "tests/cases/compiler/v1/index" +>Alpha : typeof import("tests/cases/compiler/v1/index") export var x: string; >x : string === tests/cases/compiler/v2/index.d.ts === export as namespace Alpha; ->Alpha : typeof "tests/cases/compiler/v2/index" +>Alpha : typeof import("tests/cases/compiler/v2/index") export var y: number; >y : number diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.types b/tests/baselines/reference/untypedModuleImport_allowJs.types index 2a854ce9d232f..91cd7614eee99 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.types +++ b/tests/baselines/reference/untypedModuleImport_allowJs.types @@ -14,7 +14,7 @@ foo.bar(); exports.default = { bar() { return 0; } } >exports.default = { bar() { return 0; } } : { [x: string]: any; bar(): number; } >exports.default : { [x: string]: any; bar(): number; } ->exports : typeof "/node_modules/foo/index" +>exports : typeof import("/node_modules/foo/index") >default : { [x: string]: any; bar(): number; } >{ bar() { return 0; } } : { [x: string]: any; bar(): number; } >bar : () => number diff --git a/tests/baselines/reference/untypedModuleImport_vsAmbient.types b/tests/baselines/reference/untypedModuleImport_vsAmbient.types index f1991818ad194..ff0ee7fe2fff3 100644 --- a/tests/baselines/reference/untypedModuleImport_vsAmbient.types +++ b/tests/baselines/reference/untypedModuleImport_vsAmbient.types @@ -8,7 +8,7 @@ x; === /declarations.d.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export const x: number; >x : number diff --git a/tests/baselines/reference/untypedModuleImport_withAugmentation.types b/tests/baselines/reference/untypedModuleImport_withAugmentation.types index 8bd23ca6aa5e9..665b955564a6e 100644 --- a/tests/baselines/reference/untypedModuleImport_withAugmentation.types +++ b/tests/baselines/reference/untypedModuleImport_withAugmentation.types @@ -1,6 +1,6 @@ === /a.ts === declare module "foo" { ->"foo" : typeof "foo" +>"foo" : typeof import("foo") export const x: number; >x : number diff --git a/tests/baselines/reference/untypedModuleImport_withAugmentation2.types b/tests/baselines/reference/untypedModuleImport_withAugmentation2.types index 89637715584d5..cbc00c5f12e08 100644 --- a/tests/baselines/reference/untypedModuleImport_withAugmentation2.types +++ b/tests/baselines/reference/untypedModuleImport_withAugmentation2.types @@ -5,7 +5,7 @@ No type information for this code.=== /node_modules/augmenter/index.d.ts === // This tests that augmenting an untyped module is forbidden even in an ambient context. Contrast with `moduleAugmentationInDependency.ts`. declare module "js" { ->"js" : typeof "js" +>"js" : typeof import("js") export const j: number; >j : number diff --git a/tests/baselines/reference/varRequireFromJavascript.types b/tests/baselines/reference/varRequireFromJavascript.types index b17cc3f6f3b08..7eee4ec188a45 100644 --- a/tests/baselines/reference/varRequireFromJavascript.types +++ b/tests/baselines/reference/varRequireFromJavascript.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/use.js === var ex = require('./ex') ->ex : typeof "tests/cases/conformance/salsa/ex" ->require('./ex') : typeof "tests/cases/conformance/salsa/ex" +>ex : typeof import("tests/cases/conformance/salsa/ex") +>require('./ex') : typeof import("tests/cases/conformance/salsa/ex") >require : any >'./ex' : "./ex" @@ -10,7 +10,7 @@ var crunch = new ex.Crunch(1); >crunch : Crunch >new ex.Crunch(1) : Crunch >ex.Crunch : typeof Crunch ->ex : typeof "tests/cases/conformance/salsa/ex" +>ex : typeof import("tests/cases/conformance/salsa/ex") >Crunch : typeof Crunch >1 : 1 diff --git a/tests/baselines/reference/varRequireFromTypescript.types b/tests/baselines/reference/varRequireFromTypescript.types index 78f0790239e78..496b691d0173f 100644 --- a/tests/baselines/reference/varRequireFromTypescript.types +++ b/tests/baselines/reference/varRequireFromTypescript.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/use.js === var ex = require('./ex') ->ex : typeof "tests/cases/conformance/salsa/ex" ->require('./ex') : typeof "tests/cases/conformance/salsa/ex" +>ex : typeof import("tests/cases/conformance/salsa/ex") +>require('./ex') : typeof import("tests/cases/conformance/salsa/ex") >require : any >'./ex' : "./ex" @@ -10,7 +10,7 @@ var crunch = new ex.Crunch(1); >crunch : Crunch >new ex.Crunch(1) : Crunch >ex.Crunch : typeof Crunch ->ex : typeof "tests/cases/conformance/salsa/ex" +>ex : typeof import("tests/cases/conformance/salsa/ex") >Crunch : typeof Crunch >1 : 1 diff --git a/tests/cases/fourslash/jsRequireQuickInfo.ts b/tests/cases/fourslash/jsRequireQuickInfo.ts index df8bc10ce6cf5..5c78e87815a60 100644 --- a/tests/cases/fourslash/jsRequireQuickInfo.ts +++ b/tests/cases/fourslash/jsRequireQuickInfo.ts @@ -7,4 +7,4 @@ // @Filename: b.js ////exports.x = 0; -verify.quickInfoAt("",'const x: typeof "/tests/cases/fourslash/b"'); +verify.quickInfoAt("",'const x: typeof import("/tests/cases/fourslash/b")'); From fefa9daa8349036f8baeb36b3dea2f206c984f76 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 23 Mar 2018 17:00:54 -0700 Subject: [PATCH 11/21] Wire up go to definition for import types --- src/compiler/checker.ts | 37 ++++++++++++++++--- .../fourslash/importTypeNodeGoToDefinition.ts | 22 +++++++++++ 2 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/importTypeNodeGoToDefinition.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bae7befb6e112..7a03a6e682e02 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8499,6 +8499,8 @@ namespace ts { error(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current)); return links.resolvedType = anyType; } + getNodeLinks(current).resolvedSymbol = next; + getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } resolveImportSymbolType(node, links, currentNamespace, targetMeaning); @@ -25080,6 +25082,18 @@ namespace ts { } } + function isImportTypeQualifierPart(node: EntityName): ImportTypeNode | undefined { + let parent = node.parent; + while (isQualifiedName(parent)) { + node = parent; + parent = parent.parent; + } + if (parent && parent.kind === SyntaxKind.ImportTypeNode && (parent as ImportTypeNode).qualifier === node) { + return parent as ImportTypeNode; + } + return undefined; + } + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol | undefined { if (isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); @@ -25100,11 +25114,19 @@ namespace ts { /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } - if (entityName.kind !== SyntaxKind.PropertyAccessExpression && isInRightSideOfImportOrExportAssignment(entityName)) { - // Since we already checked for ExportAssignment, this really could only be an Import - const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); - Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); + if (!isPropertyAccessExpression(entityName)) { + if (isInRightSideOfImportOrExportAssignment(entityName)) { + // Since we already checked for ExportAssignment, this really could only be an Import + const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); + Debug.assert(importEqualsDeclaration !== undefined); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); + } + const possibleImportNode = isImportTypeQualifierPart(entityName); + if (possibleImportNode) { + getTypeFromTypeNode(possibleImportNode); + const sym = getNodeLinks(entityName).resolvedSymbol; + return sym === unknownSymbol ? undefined : sym; + } } while (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { @@ -25260,9 +25282,12 @@ namespace ts { // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript + // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || ((node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration) && (node.parent).moduleSpecifier === node) || - ((isInJavaScriptFile(node) && isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || isImportCall(node.parent))) { + ((isInJavaScriptFile(node) && isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || isImportCall(node.parent)) || + (isLiteralTypeNode(node.parent) && isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent) + ) { return resolveExternalModuleName(node, node); } // falls through diff --git a/tests/cases/fourslash/importTypeNodeGoToDefinition.ts b/tests/cases/fourslash/importTypeNodeGoToDefinition.ts new file mode 100644 index 0000000000000..31b5c270ec655 --- /dev/null +++ b/tests/cases/fourslash/importTypeNodeGoToDefinition.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: /ns.ts +/////*refFile*/export namespace /*refFoo*/Foo { +//// export namespace /*refBar*/Bar { +//// export class /*refBaz*/Baz {} +//// } +////} + +// @Filename: /usage.ts +////type A = typeof import([|/*1*/"./ns"|]).[|/*2*/Foo|].[|/*3*/Bar|]; +////type B = import([|/*4*/"./ns"|]).[|/*5*/Foo|].[|/*6*/Bar|].[|/*7*/Baz|]; + +verify.goToDefinition([ + ["1", "refFile"], + ["2", "refFoo"], + ["3", "refBar"], + ["4", "refFile"], + ["5", "refFoo"], + ["6", "refBar"], + ["7", "refBaz"], +]); From b07fe67a94ee512f6ada6ed0693709b55207092d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 23 Mar 2018 17:04:38 -0700 Subject: [PATCH 12/21] Accept updated type/symbol baselines now that symbols are wired in --- tests/baselines/reference/importTypeAmbient.symbols | 2 ++ tests/baselines/reference/importTypeAmbient.types | 2 +- tests/baselines/reference/importTypeGenericTypes.symbols | 2 ++ tests/baselines/reference/importTypeGenericTypes.types | 2 +- tests/baselines/reference/importTypeLocal.symbols | 2 ++ tests/baselines/reference/importTypeLocal.types | 2 +- tests/baselines/reference/importTypeLocalMissing.symbols | 1 + tests/baselines/reference/importTypeNested.symbols | 2 ++ tests/baselines/reference/importTypeNested.types | 4 ++-- tests/baselines/reference/importTypeNestedNoRef.symbols | 1 + tests/baselines/reference/importTypeNestedNoRef.types | 2 +- 11 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/importTypeAmbient.symbols b/tests/baselines/reference/importTypeAmbient.symbols index d20bf68a29577..4e8078d021f58 100644 --- a/tests/baselines/reference/importTypeAmbient.symbols +++ b/tests/baselines/reference/importTypeAmbient.symbols @@ -67,6 +67,8 @@ declare module "foo2" { let y: import("foo2").Bar.I = { a: "", b: 0 }; >y : Symbol(y, Decl(importTypeAmbient.ts, 30, 3)) +>Bar : Symbol(Bar, Decl(importTypeAmbient.ts, 9, 23), Decl(importTypeAmbient.ts, 22, 5)) +>I : Symbol(Bar.I, Decl(importTypeAmbient.ts, 10, 19)) >a : Symbol(a, Decl(importTypeAmbient.ts, 30, 31)) >b : Symbol(b, Decl(importTypeAmbient.ts, 30, 38)) diff --git a/tests/baselines/reference/importTypeAmbient.types b/tests/baselines/reference/importTypeAmbient.types index bfa3c1b4ef4c7..f0bef838b97e9 100644 --- a/tests/baselines/reference/importTypeAmbient.types +++ b/tests/baselines/reference/importTypeAmbient.types @@ -71,7 +71,7 @@ declare module "foo2" { let y: import("foo2").Bar.I = { a: "", b: 0 }; >y : Bar.I >Bar : any ->I : No type information available! +>I : Bar.I >{ a: "", b: 0 } : { a: string; b: number; } >a : string >"" : "" diff --git a/tests/baselines/reference/importTypeGenericTypes.symbols b/tests/baselines/reference/importTypeGenericTypes.symbols index 1413fc64bc069..b20e5be9cc6d4 100644 --- a/tests/baselines/reference/importTypeGenericTypes.symbols +++ b/tests/baselines/reference/importTypeGenericTypes.symbols @@ -85,6 +85,8 @@ export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} }; export let y: import("./foo2").Bar.I<{x: number}> = { a: "", b: 0, data: {x: 12} }; >y : Symbol(y, Decl(usage.ts, 1, 10)) +>Bar : Symbol(Bar, Decl(foo2.ts, 20, 8)) +>I : Symbol(Bar.I, Decl(foo2.ts, 0, 15)) >x : Symbol(x, Decl(usage.ts, 1, 38)) >a : Symbol(a, Decl(usage.ts, 1, 53)) >b : Symbol(b, Decl(usage.ts, 1, 60)) diff --git a/tests/baselines/reference/importTypeGenericTypes.types b/tests/baselines/reference/importTypeGenericTypes.types index 6eb17e2a183c5..19611db696365 100644 --- a/tests/baselines/reference/importTypeGenericTypes.types +++ b/tests/baselines/reference/importTypeGenericTypes.types @@ -91,7 +91,7 @@ export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} }; export let y: import("./foo2").Bar.I<{x: number}> = { a: "", b: 0, data: {x: 12} }; >y : Bar.I<{ x: number; }> >Bar : any ->I : No type information available! +>I : Bar.I >x : number >{ a: "", b: 0, data: {x: 12} } : { a: string; b: number; data: { x: number; }; } >a : string diff --git a/tests/baselines/reference/importTypeLocal.symbols b/tests/baselines/reference/importTypeLocal.symbols index 385a6794d37d9..ac411e4f684d6 100644 --- a/tests/baselines/reference/importTypeLocal.symbols +++ b/tests/baselines/reference/importTypeLocal.symbols @@ -64,6 +64,8 @@ export const x: import("./foo") = { x: 0, y: 0 }; export let y: import("./foo2").Bar.I = { a: "", b: 0 }; >y : Symbol(y, Decl(usage.ts, 1, 10)) +>Bar : Symbol(Bar, Decl(foo2.ts, 18, 8)) +>I : Symbol(Bar.I, Decl(foo2.ts, 0, 15)) >a : Symbol(a, Decl(usage.ts, 1, 40)) >b : Symbol(b, Decl(usage.ts, 1, 47)) diff --git a/tests/baselines/reference/importTypeLocal.types b/tests/baselines/reference/importTypeLocal.types index 955a3a6bf46bc..ed7f28b291006 100644 --- a/tests/baselines/reference/importTypeLocal.types +++ b/tests/baselines/reference/importTypeLocal.types @@ -68,7 +68,7 @@ export const x: import("./foo") = { x: 0, y: 0 }; export let y: import("./foo2").Bar.I = { a: "", b: 0 }; >y : Bar.I >Bar : any ->I : No type information available! +>I : Bar.I >{ a: "", b: 0 } : { a: string; b: number; } >a : string >"" : "" diff --git a/tests/baselines/reference/importTypeLocalMissing.symbols b/tests/baselines/reference/importTypeLocalMissing.symbols index 9dd63ef30997d..79e6dc7f17c08 100644 --- a/tests/baselines/reference/importTypeLocalMissing.symbols +++ b/tests/baselines/reference/importTypeLocalMissing.symbols @@ -69,6 +69,7 @@ export let y: import("./fo2").Bar.I = { a: "", b: 0 }; export let z: import("./foo2").Bar.Q = { a: "", b: 0 }; >z : Symbol(z, Decl(usage.ts, 2, 10)) +>Bar : Symbol(Bar, Decl(foo2.ts, 18, 8)) >a : Symbol(a, Decl(usage.ts, 2, 40)) >b : Symbol(b, Decl(usage.ts, 2, 47)) diff --git a/tests/baselines/reference/importTypeNested.symbols b/tests/baselines/reference/importTypeNested.symbols index ba72e64ad3736..058acec1edc41 100644 --- a/tests/baselines/reference/importTypeNested.symbols +++ b/tests/baselines/reference/importTypeNested.symbols @@ -9,4 +9,6 @@ export type Value = "yes"; === tests/cases/conformance/types/import/chainer.ts === export const x: import(import("./a").LookAt).Value = "yes"; >x : Symbol(x, Decl(chainer.ts, 0, 12)) +>LookAt : Symbol(LookAt, Decl(a.d.ts, 0, 0)) +>Value : Symbol(Value, Decl(b.d.ts, 0, 0)) diff --git a/tests/baselines/reference/importTypeNested.types b/tests/baselines/reference/importTypeNested.types index f04cb4d92a723..fb991e5a7d0b0 100644 --- a/tests/baselines/reference/importTypeNested.types +++ b/tests/baselines/reference/importTypeNested.types @@ -9,7 +9,7 @@ export type Value = "yes"; === tests/cases/conformance/types/import/chainer.ts === export const x: import(import("./a").LookAt).Value = "yes"; >x : "yes" ->LookAt : No type information available! ->Value : No type information available! +>LookAt : "./b" +>Value : "yes" >"yes" : "yes" diff --git a/tests/baselines/reference/importTypeNestedNoRef.symbols b/tests/baselines/reference/importTypeNestedNoRef.symbols index 832fbba020ba9..f35f21a3f736f 100644 --- a/tests/baselines/reference/importTypeNestedNoRef.symbols +++ b/tests/baselines/reference/importTypeNestedNoRef.symbols @@ -1,6 +1,7 @@ === tests/cases/conformance/types/import/chainer.ts === export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build >x : Symbol(x, Decl(chainer.ts, 0, 12)) +>LookAt : Symbol(LookAt, Decl(a.d.ts, 0, 0)) === tests/cases/conformance/types/import/a.d.ts === export type LookAt = "./b"; diff --git a/tests/baselines/reference/importTypeNestedNoRef.types b/tests/baselines/reference/importTypeNestedNoRef.types index 899ebb198400f..3a7951fdc2fea 100644 --- a/tests/baselines/reference/importTypeNestedNoRef.types +++ b/tests/baselines/reference/importTypeNestedNoRef.types @@ -1,7 +1,7 @@ === tests/cases/conformance/types/import/chainer.ts === export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build >x : any ->LookAt : No type information available! +>LookAt : "./b" >Value : No type information available! >"yes" : "yes" From 20950c5293e2c5540eb8468ce7eb89ca419e75f8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 10:33:49 -0700 Subject: [PATCH 13/21] PR feedback --- src/compiler/checker.ts | 18 ++++++------------ src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7a03a6e682e02..eef028be9abbe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8453,9 +8453,9 @@ namespace ts { const links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments - error(node, Diagnostics.type_arguments_can_only_be_used_in_a_ts_file); + error(node, Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = anyType; + return links.resolvedType = unknownType; } const argumentType = getTypeFromTypeNode(node.argument); const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; @@ -8463,21 +8463,15 @@ namespace ts { if (!argumentType || !(argumentType.flags & TypeFlags.StringLiteral)) { error(node.argument, Diagnostics.Import_specifier_must_be_a_string_literal_type_but_here_is_0, argumentType ? typeToString(argumentType) : "undefined"); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = anyType; + return links.resolvedType = unknownType; } const moduleName = (argumentType as StringLiteralType).value; const innerModuleSymbol = resolveExternalModule(node, moduleName, Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); if (!innerModuleSymbol) { - error(node, Diagnostics.Cannot_find_module_0, moduleName); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = anyType; + return links.resolvedType = unknownType; } const moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); - if (!moduleSymbol) { - error(node, Diagnostics.Cannot_find_module_0, moduleName); - links.resolvedSymbol = unknownSymbol; - return links.resolvedType = anyType; - } if (node.qualifier) { const nameStack: Identifier[] = []; let currentNamespace = moduleSymbol; @@ -8497,7 +8491,7 @@ namespace ts { const next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current)); - return links.resolvedType = anyType; + return links.resolvedType = unknownType; } getNodeLinks(current).resolvedSymbol = next; getNodeLinks(current.parent).resolvedSymbol = next; @@ -8512,7 +8506,7 @@ namespace ts { else { error(node, targetMeaning === SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); links.resolvedSymbol = unknownSymbol; - links.resolvedType = anyType; + links.resolvedType = unknownType; } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b17c8bae72a38..6ff4841b958ca 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -963,6 +963,10 @@ "category": "Error", "code": 1341 }, + "Type arguments cannot be used here.": { + "category": "Error", + "code": 1342 + }, "Duplicate identifier '{0}'.": { "category": "Error", From 7521c6361cb2e2eefea7d76339dd9e3394cdc933 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 13:16:05 -0700 Subject: [PATCH 14/21] Fix changes from merge --- src/compiler/checker.ts | 12 ++++++------ src/services/codefixes/fixSpelling.ts | 2 +- .../esModuleInteropImportTSLibHasImport.types | 2 +- .../reference/systemDefaultImportCallable.types | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a9e2a3556ddc9..5aadef331818f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25198,14 +25198,14 @@ namespace ts { return success; } } + else if (!isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { + // Since we already checked for ExportAssignment, this really could only be an Import + const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); + Debug.assert(importEqualsDeclaration !== undefined); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); + } if (!isPropertyAccessExpression(entityName)) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - // Since we already checked for ExportAssignment, this really could only be an Import - const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); - Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); - } const possibleImportNode = isImportTypeQualifierPart(entityName); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index 851b749d29bc0..ff53f5b378639 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -75,7 +75,7 @@ namespace ts.codefix { function getResolvedSourceFileFromImportDeclaration (sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined { if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined; - const resolvedModule = getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text); + const resolvedModule = getResolvedModuleFromState(getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text)); if (!resolvedModule) return undefined; return context.program.getSourceFile(resolvedModule.resolvedFileName); diff --git a/tests/baselines/reference/esModuleInteropImportTSLibHasImport.types b/tests/baselines/reference/esModuleInteropImportTSLibHasImport.types index 00802b78291fc..5851ad03565bf 100644 --- a/tests/baselines/reference/esModuleInteropImportTSLibHasImport.types +++ b/tests/baselines/reference/esModuleInteropImportTSLibHasImport.types @@ -1,6 +1,6 @@ === tests/cases/compiler/types.d.ts === declare module "tslib" { export const __exportStar: any; export const __importDefault: any; export const __importStar: any; } ->"tslib" : typeof "tslib" +>"tslib" : typeof import("tslib") >__exportStar : any >__importDefault : any >__importStar : any diff --git a/tests/baselines/reference/systemDefaultImportCallable.types b/tests/baselines/reference/systemDefaultImportCallable.types index 878a1f879d1b1..f17184cea5865 100644 --- a/tests/baselines/reference/systemDefaultImportCallable.types +++ b/tests/baselines/reference/systemDefaultImportCallable.types @@ -13,7 +13,7 @@ declare module core { }; } declare module "core-js/fn/string/repeat" { ->"core-js/fn/string/repeat" : typeof "core-js/fn/string/repeat" +>"core-js/fn/string/repeat" : typeof import("core-js/fn/string/repeat") var repeat: typeof core.String.repeat; >repeat : (text: string, count: number) => string From 257b848d437e1e2f128a8f3dd0180b49fc7f241b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 13:45:34 -0700 Subject: [PATCH 15/21] Walk back late import handling --- src/compiler/checker.ts | 21 +++++----------- src/compiler/program.ts | 24 ++++++++++++------- src/compiler/types.ts | 10 +------- src/compiler/utilities.ts | 21 ++++++---------- .../unittests/reuseProgramStructure.ts | 14 +---------- src/server/project.ts | 2 +- src/services/codefixes/convertToEs6Module.ts | 2 +- src/services/codefixes/fixSpelling.ts | 2 +- src/services/codefixes/importFixes.ts | 3 +-- src/services/services.ts | 2 +- src/services/suggestionDiagnostics.ts | 2 +- .../reference/importTypeGeneric.errors.txt | 8 +++---- .../reference/importTypeNested.errors.txt | 12 ++++++++++ .../reference/importTypeNested.symbols | 1 - .../reference/importTypeNested.types | 4 ++-- .../importTypeNestedNoRef.errors.txt | 6 ++--- .../reference/importTypeNonString.errors.txt | 4 ++-- ...ugmentationDisallowedExtensions.errors.txt | 14 ++++++++++- ...duleAugmentationDisallowedExtensions.types | 6 ++--- ...eAugmentationImportsAndExports2.errors.txt | 8 ++++++- ...moduleAugmentationImportsAndExports2.types | 8 +++---- ...eAugmentationImportsAndExports3.errors.txt | 5 +++- ...duleAugmentationImportsAndExports3.symbols | 2 -- ...moduleAugmentationImportsAndExports3.types | 22 ++++++++--------- 24 files changed, 101 insertions(+), 102 deletions(-) create mode 100644 tests/baselines/reference/importTypeNested.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5aadef331818f..c7f96383b5a22 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2116,16 +2116,7 @@ namespace ts { return ambientModule; } const currentSourceFile = getSourceFileOfNode(location); - const resolvedModuleState = getResolvedModule(currentSourceFile, moduleReference); - let resolvedModule: ResolvedModuleFull; - if (currentSourceFile && resolvedModuleState === undefined) { - // Fallback to uncached lookup for late-bound module names which have not been resolved - const resolutions = host.resolveModuleName([moduleReference], currentSourceFile.fileName); - resolvedModule = firstOrUndefined(resolutions); - } - else { - resolvedModule = getResolvedModuleFromState(resolvedModuleState); - } + const resolvedModule = getResolvedModule(currentSourceFile, moduleReference); const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule); const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { @@ -8513,14 +8504,14 @@ namespace ts { links.resolvedSymbol = unknownSymbol; return links.resolvedType = unknownType; } - const argumentType = getTypeFromTypeNode(node.argument); - const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; - // TODO: Future work: support unions/generics/whatever via a deferred import-type - if (!argumentType || !(argumentType.flags & TypeFlags.StringLiteral)) { - error(node.argument, Diagnostics.Import_specifier_must_be_a_string_literal_type_but_here_is_0, argumentType ? typeToString(argumentType) : "undefined"); + if (!isLiteralImportTypeNode(node)) { + error(node.argument, Diagnostics.String_literal_expected); links.resolvedSymbol = unknownSymbol; return links.resolvedType = unknownType; } + const argumentType = getTypeFromTypeNode(node.argument); + const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; + // TODO: Future work: support unions/generics/whatever via a deferred import-type const moduleName = (argumentType as StringLiteralType).value; const innerModuleSymbol = resolveExternalModule(node, moduleName, Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); if (!innerModuleSymbol) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 9889eaae96cce..67b9a0095d4b6 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -674,8 +674,7 @@ namespace ts { sourceFileToPackageName, redirectTargetsSet, isEmittedFile, - getConfigFileParsingDiagnostics, - resolveModuleName: resolveModuleNamesWorker + getConfigFileParsingDiagnostics }; verifyCompilerOptions(); @@ -749,7 +748,7 @@ namespace ts { const result: ResolvedModuleFull[] = []; for (const moduleName of moduleNames) { const resolvedModule = file.resolvedModules.get(moduleName); - result.push(getResolvedModuleFromState(resolvedModule)); + result.push(resolvedModule); } return result; } @@ -778,7 +777,7 @@ namespace ts { const moduleName = moduleNames[i]; // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) { - const oldResolvedModule = getResolvedModuleFromState(oldSourceFile && oldSourceFile.resolvedModules.get(moduleName)); + const oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName); if (oldResolvedModule) { if (isTraceEnabled(options, host)) { trace(host, Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile); @@ -844,7 +843,7 @@ namespace ts { // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState: OldProgramState): boolean { - const resolutionToFile = getResolvedModuleFromState(getResolvedModule(oldProgramState.oldSourceFile, moduleName)); + const resolutionToFile = getResolvedModule(oldProgramState.oldSourceFile, moduleName); const resolvedFile = resolutionToFile && oldProgramState.program && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same @@ -1027,10 +1026,10 @@ namespace ts { const oldProgramState: OldProgramState = { program: oldProgram, oldSourceFile, modifiedFilePaths }; const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); // ensure that module resolution results are still correct - const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo, getResolvedModuleFromState); + const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo); if (resolutionsChanged) { oldProgram.structureIsReused = StructureIsReused.SafeModules; - newSourceFile.resolvedModules = zipToMap(moduleNames, map(resolutions, r => ({ tag: "success" as "success", data: r }))); + newSourceFile.resolvedModules = zipToMap(moduleNames, resolutions); } else { newSourceFile.resolvedModules = oldSourceFile.resolvedModules; @@ -1688,12 +1687,19 @@ namespace ts { imports = append(imports, node.arguments[0] as StringLiteralLike); } else if (isLiteralImportTypeNode(node)) { - (imports || (imports = [])).push(node.argument.literal); + imports = append(imports, node.argument.literal); } else { - forEachChild(node, collectDynamicImportOrRequireCalls); + collectDynamicImportOrRequireCallsForEachChild(node); + if (hasJSDocNodes(node)) { + forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild); + } } } + + function collectDynamicImportOrRequireCallsForEachChild(node: Node) { + forEachChild(node, collectDynamicImportOrRequireCalls); + } } /** This should have similar behavior to 'processSourceFile' without diagnostics or mutation. */ diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0ed540dfb569c..ad2ea833b22bf 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2584,7 +2584,7 @@ namespace ts { // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead - /* @internal */ resolvedModules: Map; + /* @internal */ resolvedModules: Map; /* @internal */ resolvedTypeReferenceDirectiveNames: Map; /* @internal */ imports: ReadonlyArray; // Identifier only if `declare global` @@ -2598,9 +2598,6 @@ namespace ts { /* @internal */ localJsxFactory?: EntityName; } - /* @internal */ - export type ResolvedModuleState = { tag: "success", data: ResolvedModuleFull } | { tag: "fail" }; - export interface Bundle extends Node { kind: SyntaxKind.Bundle; sourceFiles: ReadonlyArray; @@ -2725,9 +2722,6 @@ namespace ts { /* @internal */ redirectTargetsSet: Map; /** Is the file emitted file */ /* @internal */ isEmittedFile(file: string): boolean; - - /* Used by the type checker to resolve module names which are encountered late */ - /* @internal */ resolveModuleName(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModuleFull[]; } /* @internal */ @@ -2801,8 +2795,6 @@ namespace ts { getSourceFiles(): ReadonlyArray; getSourceFile(fileName: string): SourceFile | undefined; getResolvedTypeReferenceDirectives(): ReadonlyMap; - - resolveModuleName(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModuleFull[]; } export interface TypeChecker { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7f8b86d5783df..4a6e009cb8d5c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -83,21 +83,16 @@ namespace ts { return node.end - node.pos; } - export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleState { + export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull { return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText); } - export function getResolvedModuleFromState(state: ResolvedModuleState): ResolvedModuleFull | undefined { - return state && state.tag === "success" ? state.data : undefined; - } - - const failedLookup: { tag: "fail" } = { tag: "fail" }; export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void { if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = createMap(); + sourceFile.resolvedModules = createMap(); } - sourceFile.resolvedModules.set(moduleNameText, resolvedModule ? { tag: "success", data: resolvedModule } : failedLookup); + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void { @@ -129,18 +124,16 @@ namespace ts { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; } - export function hasChangesInResolutions( + export function hasChangesInResolutions( names: ReadonlyArray, newResolutions: ReadonlyArray, - oldResolutions: ReadonlyMap, - comparer: (oldResolution: T, newResolution: T) => boolean, - oldMapper?: (x: U) => T): boolean { + oldResolutions: ReadonlyMap, + comparer: (oldResolution: T, newResolution: T) => boolean): boolean { Debug.assert(names.length === newResolutions.length); for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; - const oldRes = oldResolutions && oldResolutions.get(names[i]); - const oldResolution = oldMapper ? oldMapper(oldRes) : oldRes as {} as T; + const oldResolution = oldResolutions && oldResolutions.get(names[i]); const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 0eecb13d2a2e8..0ba9e6f63518c 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -219,19 +219,7 @@ namespace ts { } function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { - checkCache("resolved modules", program, fileName, expectedContent, f => { - if (!f.resolvedModules) return undefined; - const mapped: Map = createMap(); - forEachEntry(f.resolvedModules, (value, key) => { - if (value.tag === "success") { - mapped.set(key, value.data); - } - else { - mapped.set(key, undefined); - } - }); - return mapped; - }, checkResolvedModule); + checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule); } function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: Map): void { diff --git a/src/server/project.ts b/src/server/project.ts index 6775de3228084..c7239fdc94d66 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -780,7 +780,7 @@ namespace ts.server { if (file.resolvedModules) { file.resolvedModules.forEach((resolvedModule, name) => { // pick unresolved non-relative names - if (!getResolvedModuleFromState(resolvedModule) && !isExternalModuleNameRelative(name) && !isAmbientlyDeclaredModule(name)) { + if (!resolvedModule && !isExternalModuleNameRelative(name) && !isAmbientlyDeclaredModule(name)) { // for non-scoped names extract part up-to the first slash // for scoped names - extract up to the second slash let trimmed = name.trim(); diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts index cd735f7460cbd..b8c78d57827de 100644 --- a/src/services/codefixes/convertToEs6Module.ts +++ b/src/services/codefixes/convertToEs6Module.ts @@ -19,7 +19,7 @@ namespace ts.codefix { function fixImportOfModuleExports(importingFile: SourceFile, exportingFile: SourceFile, changes: textChanges.ChangeTracker) { for (const moduleSpecifier of importingFile.imports) { - const imported = getResolvedModuleFromState(getResolvedModule(importingFile, moduleSpecifier.text)); + const imported = getResolvedModule(importingFile, moduleSpecifier.text); if (!imported || imported.resolvedFileName !== exportingFile.fileName) { continue; } diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index ff53f5b378639..851b749d29bc0 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -75,7 +75,7 @@ namespace ts.codefix { function getResolvedSourceFileFromImportDeclaration (sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined { if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined; - const resolvedModule = getResolvedModuleFromState(getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text)); + const resolvedModule = getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text); if (!resolvedModule) return undefined; return context.program.getSourceFile(resolvedModule.resolvedFileName); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index d9609b14563ea..f96cb359dcd9c 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -323,8 +323,7 @@ namespace ts.codefix { */ function getAllModulePaths(program: Program, { fileName }: SourceFile): ReadonlyArray { const symlinks = mapDefined(program.getSourceFiles(), sf => - sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), state => { - const res = getResolvedModuleFromState(state); + sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => { return res && res.resolvedFileName === fileName ? res.originalPath : undefined; })); return symlinks.length === 0 ? [fileName] : symlinks; diff --git a/src/services/services.ts b/src/services/services.ts index 151e9edf5ef3a..dbab3436ec306 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -572,7 +572,7 @@ namespace ts { public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: UnderscoreEscapedMap; - public resolvedModules: Map; + public resolvedModules: Map; public resolvedTypeReferenceDirectiveNames: Map; public imports: ReadonlyArray; public moduleAugmentations: StringLiteral[]; diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 0705d357917b1..1fc1d671e4316 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -37,7 +37,7 @@ namespace ts { const importNode = importFromModuleSpecifier(moduleSpecifier); const name = importNameForConvertToDefaultImport(importNode); if (!name) continue; - const module = getResolvedModuleFromState(getResolvedModule(sourceFile, moduleSpecifier.text)); + const module = getResolvedModule(sourceFile, moduleSpecifier.text); const resolvedFile = module && program.getSourceFile(module.resolvedFileName); if (resolvedFile && resolvedFile.externalModuleIndicator && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) { diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import)); diff --git a/tests/baselines/reference/importTypeGeneric.errors.txt b/tests/baselines/reference/importTypeGeneric.errors.txt index 1efbbd38615a0..e8db55d336ca3 100644 --- a/tests/baselines/reference/importTypeGeneric.errors.txt +++ b/tests/baselines/reference/importTypeGeneric.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/import/usage.ts(1,67): error TS1341: Import specifier must be a string literal type, but here is 'T'. -tests/cases/conformance/types/import/usage.ts(5,72): error TS1341: Import specifier must be a string literal type, but here is 'T'. +tests/cases/conformance/types/import/usage.ts(1,67): error TS1141: String literal expected. +tests/cases/conformance/types/import/usage.ts(5,72): error TS1141: String literal expected. ==== tests/cases/conformance/types/import/a.d.ts (0 errors) ==== @@ -13,13 +13,13 @@ tests/cases/conformance/types/import/usage.ts(5,72): error TS1341: Import specif ==== tests/cases/conformance/types/import/usage.ts (2 errors) ==== export function getFooFrom(v: T): import(T).Foo { ~ -!!! error TS1341: Import specifier must be a string literal type, but here is 'T'. +!!! error TS1141: String literal expected. return undefined as any; } export function getFooValueFrom(v: T): import(T).Foo["a"] { ~ -!!! error TS1341: Import specifier must be a string literal type, but here is 'T'. +!!! error TS1141: String literal expected. return undefined as any; } \ No newline at end of file diff --git a/tests/baselines/reference/importTypeNested.errors.txt b/tests/baselines/reference/importTypeNested.errors.txt new file mode 100644 index 0000000000000..dc33e58176556 --- /dev/null +++ b/tests/baselines/reference/importTypeNested.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/types/import/chainer.ts(1,24): error TS1141: String literal expected. + + +==== tests/cases/conformance/types/import/a.d.ts (0 errors) ==== + export type LookAt = "./b"; +==== tests/cases/conformance/types/import/b.d.ts (0 errors) ==== + export type Value = "yes"; +==== tests/cases/conformance/types/import/chainer.ts (1 errors) ==== + export const x: import(import("./a").LookAt).Value = "yes"; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1141: String literal expected. + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeNested.symbols b/tests/baselines/reference/importTypeNested.symbols index 058acec1edc41..df129ec04388d 100644 --- a/tests/baselines/reference/importTypeNested.symbols +++ b/tests/baselines/reference/importTypeNested.symbols @@ -10,5 +10,4 @@ export type Value = "yes"; export const x: import(import("./a").LookAt).Value = "yes"; >x : Symbol(x, Decl(chainer.ts, 0, 12)) >LookAt : Symbol(LookAt, Decl(a.d.ts, 0, 0)) ->Value : Symbol(Value, Decl(b.d.ts, 0, 0)) diff --git a/tests/baselines/reference/importTypeNested.types b/tests/baselines/reference/importTypeNested.types index fb991e5a7d0b0..8dbdd3fd04a57 100644 --- a/tests/baselines/reference/importTypeNested.types +++ b/tests/baselines/reference/importTypeNested.types @@ -8,8 +8,8 @@ export type Value = "yes"; === tests/cases/conformance/types/import/chainer.ts === export const x: import(import("./a").LookAt).Value = "yes"; ->x : "yes" +>x : any >LookAt : "./b" ->Value : "yes" +>Value : No type information available! >"yes" : "yes" diff --git a/tests/baselines/reference/importTypeNestedNoRef.errors.txt b/tests/baselines/reference/importTypeNestedNoRef.errors.txt index 51b03a4f7c47a..1c26bb8840fa3 100644 --- a/tests/baselines/reference/importTypeNestedNoRef.errors.txt +++ b/tests/baselines/reference/importTypeNestedNoRef.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/types/import/chainer.ts(1,17): error TS2307: Cannot find module './b'. +tests/cases/conformance/types/import/chainer.ts(1,24): error TS1141: String literal expected. ==== tests/cases/conformance/types/import/chainer.ts (1 errors) ==== export const x: import(import("./a").LookAt).Value = "yes"; // expect outter import to fail, since b.d.ts isn't in the build - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module './b'. + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1141: String literal expected. ==== tests/cases/conformance/types/import/a.d.ts (0 errors) ==== export type LookAt = "./b"; diff --git a/tests/baselines/reference/importTypeNonString.errors.txt b/tests/baselines/reference/importTypeNonString.errors.txt index cd723d6cf77f6..a50d44c0c7361 100644 --- a/tests/baselines/reference/importTypeNonString.errors.txt +++ b/tests/baselines/reference/importTypeNonString.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/import/importTypeNonString.ts(1,24): error TS1341: Import specifier must be a string literal type, but here is '{ x: 12; }'. +tests/cases/conformance/types/import/importTypeNonString.ts(1,24): error TS1141: String literal expected. ==== tests/cases/conformance/types/import/importTypeNonString.ts (1 errors) ==== export const x: import({x: 12}) = undefined as any; ~~~~~~~ -!!! error TS1341: Import specifier must be a string literal type, but here is '{ x: 12; }'. +!!! error TS1141: String literal expected. \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt index 5104e9dca5da4..cacd821168cd8 100644 --- a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.errors.txt @@ -1,14 +1,18 @@ tests/cases/compiler/x.ts(17,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/x.ts(17,26): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(18,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/x.ts(18,21): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(19,5): error TS2666: Exports and export assignments are not permitted in module augmentations. +tests/cases/compiler/x.ts(19,19): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(20,5): error TS2666: Exports and export assignments are not permitted in module augmentations. +tests/cases/compiler/x.ts(20,21): error TS2307: Cannot find module './x0'. tests/cases/compiler/x.ts(24,5): error TS2666: Exports and export assignments are not permitted in module augmentations. ==== tests/cases/compiler/x0.ts (0 errors) ==== export let a = 1; -==== tests/cases/compiler/x.ts (5 errors) ==== +==== tests/cases/compiler/x.ts (9 errors) ==== namespace N1 { export let x = 1; } @@ -28,15 +32,23 @@ tests/cases/compiler/x.ts(24,5): error TS2666: Exports and export assignments ar import * as all from "./x0"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. import {a} from "./x0"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. export * from "./x0"; ~~~~~~ !!! error TS2666: Exports and export assignments are not permitted in module augmentations. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. export {a} from "./x0"; ~~~~~~ !!! error TS2666: Exports and export assignments are not permitted in module augmentations. + ~~~~~~ +!!! error TS2307: Cannot find module './x0'. } declare module "./test" { diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types index 0674941e2577a..5da1649511d91 100644 --- a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.types @@ -61,14 +61,14 @@ declare module "./observable" { >T : number import * as all from "./x0"; ->all : typeof all +>all : any import {a} from "./x0"; ->a : number +>a : any export * from "./x0"; export {a} from "./x0"; ->a : number +>a : any } declare module "./test" { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt index 12bc41512efb3..5f57081357e8a 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt @@ -1,6 +1,8 @@ tests/cases/compiler/f3.ts(3,13): error TS2339: Property 'foo' does not exist on type 'A'. tests/cases/compiler/f3.ts(11,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'. tests/cases/compiler/f3.ts(12,5): error TS2666: Exports and export assignments are not permitted in module augmentations. +tests/cases/compiler/f3.ts(12,21): error TS2307: Cannot find module './f2'. tests/cases/compiler/f3.ts(13,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'I' is using private name 'N'. tests/cases/compiler/f3.ts(14,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. @@ -16,7 +18,7 @@ tests/cases/compiler/f4.ts(5,11): error TS2339: Property 'foo' does not exist on n: number; } -==== tests/cases/compiler/f3.ts (7 errors) ==== +==== tests/cases/compiler/f3.ts (9 errors) ==== import {A} from "./f1"; A.prototype.foo = function () { return undefined; } @@ -32,9 +34,13 @@ tests/cases/compiler/f4.ts(5,11): error TS2339: Property 'foo' does not exist on import {B} from "./f2"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './f2'. export {B} from "./f2"; ~~~~~~ !!! error TS2666: Exports and export assignments are not permitted in module augmentations. + ~~~~~~ +!!! error TS2307: Cannot find module './f2'. import I = N.Ifc; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.types b/tests/baselines/reference/moduleAugmentationImportsAndExports2.types index a2340092e5275..56c333959251e 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.types @@ -40,10 +40,10 @@ declare module "./f1" { >"./f1" : typeof import("tests/cases/compiler/f1") import {B} from "./f2"; ->B : typeof B +>B : any export {B} from "./f2"; ->B : typeof B +>B : any import I = N.Ifc; >I : any @@ -60,8 +60,8 @@ declare module "./f1" { >A : A foo(): B; ->foo : () => B ->B : B +>foo : () => any +>B : any bar(): I; >bar : () => I diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt index e386914992d31..33732c0552f34 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/f3.ts(11,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. +tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'. tests/cases/compiler/f3.ts(12,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. tests/cases/compiler/f3.ts(12,16): error TS4000: Import declaration 'I' is using private name 'N'. tests/cases/compiler/f3.ts(13,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. @@ -13,7 +14,7 @@ tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'C' is using n: number; } -==== tests/cases/compiler/f3.ts (5 errors) ==== +==== tests/cases/compiler/f3.ts (6 errors) ==== import {A} from "./f1"; A.prototype.foo = function () { return undefined; } @@ -27,6 +28,8 @@ tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'C' is using import {B} from "./f2"; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. + ~~~~~~ +!!! error TS2307: Cannot find module './f2'. import I = N.Ifc; ~~~~~~ !!! error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols index 3506042d8b291..f28f846de189a 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.symbols @@ -79,9 +79,7 @@ let a: A; let b = a.foo().n; >b : Symbol(b, Decl(f4.ts, 4, 3)) ->a.foo().n : Symbol(B.n, Decl(f2.ts, 0, 16)) >a.foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) >a : Symbol(a, Decl(f4.ts, 3, 3)) >foo : Symbol(A.foo, Decl(f3.ts, 13, 17)) ->n : Symbol(B.n, Decl(f2.ts, 0, 16)) diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types index 088ffc66c58fc..0d56636e3bdd3 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types @@ -16,11 +16,11 @@ import {A} from "./f1"; A.prototype.foo = function () { return undefined; } >A.prototype.foo = function () { return undefined; } : () => any ->A.prototype.foo : () => B +>A.prototype.foo : () => any >A.prototype : A >A : typeof A >prototype : A ->foo : () => B +>foo : () => any >function () { return undefined; } : () => any >undefined : undefined @@ -40,7 +40,7 @@ declare module "./f1" { >"./f1" : typeof import("tests/cases/compiler/f1") import {B} from "./f2"; ->B : typeof B +>B : any import I = N.Ifc; >I : any @@ -56,8 +56,8 @@ declare module "./f1" { >A : A foo(): B; ->foo : () => B ->B : B +>foo : () => any +>B : any bar(): I; >bar : () => I @@ -80,11 +80,11 @@ let a: A; >A : A let b = a.foo().n; ->b : number ->a.foo().n : number ->a.foo() : B ->a.foo : () => B +>b : any +>a.foo().n : any +>a.foo() : any +>a.foo : () => any >a : A ->foo : () => B ->n : number +>foo : () => any +>n : any From a06607af2c3d160e6a320c3be5d156c8edbdbea2 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 13:46:34 -0700 Subject: [PATCH 16/21] Remove unused diagnostic --- src/compiler/diagnosticMessages.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 17dde77073163..0bf047c770d0e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -963,10 +963,6 @@ "category": "Error", "code": 1340 }, - "Import specifier must be a string literal type, but here is '{0}'.": { - "category": "Error", - "code": 1341 - }, "Type arguments cannot be used here.": { "category": "Error", "code": 1342 From 87b102e0ceb1336d37dea47c2a32a30d7eea4ba3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 13:50:42 -0700 Subject: [PATCH 17/21] Remove unrelated changes --- src/compiler/utilities.ts | 2 +- src/services/codefixes/importFixes.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4a6e009cb8d5c..3bf4afe556dc7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -83,7 +83,7 @@ namespace ts { return node.end - node.pos; } - export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull { + export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull | undefined { return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText); } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index f96cb359dcd9c..95cd84ee620bf 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -323,9 +323,8 @@ namespace ts.codefix { */ function getAllModulePaths(program: Program, { fileName }: SourceFile): ReadonlyArray { const symlinks = mapDefined(program.getSourceFiles(), sf => - sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; - })); + sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => + res && res.resolvedFileName === fileName ? res.originalPath : undefined)); return symlinks.length === 0 ? [fileName] : symlinks; } From 7770788203178501984b3d7a75935307b6ef52d2 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 13:56:54 -0700 Subject: [PATCH 18/21] Use recursive function over loop --- src/compiler/checker.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c7f96383b5a22..bf0e5cef8396f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8496,6 +8496,15 @@ namespace ts { return links.resolvedType; } + function getIdentifierChain(node: EntityName): Identifier[] { + if (isIdentifier(node)) { + return [node]; + } + else { + return append(getIdentifierChain(node.left), node.right); + } + } + function getTypeFromImportTypeNode(node: ImportTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { @@ -8520,20 +8529,10 @@ namespace ts { } const moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (node.qualifier) { - const nameStack: Identifier[] = []; + const nameStack: Identifier[] = getIdentifierChain(node.qualifier); let currentNamespace = moduleSymbol; - let current = node.qualifier; - while (true) { - if (current.kind === SyntaxKind.Identifier) { - nameStack.push(current); - break; - } - else { - nameStack.push(current.right); - current = current.left; - } - } - while (current = nameStack.pop()) { + let current: Identifier | undefined; + while (current = nameStack.shift()) { const meaning = nameStack.length ? SymbolFlags.Namespace : targetMeaning; const next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { From d24ae2e6e327de502a5e6fe20e8032999807ae3b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 14:00:23 -0700 Subject: [PATCH 19/21] Emit type arguments --- src/compiler/emitter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 40d95dd323244..36c218ba5afc7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1353,6 +1353,7 @@ namespace ts { writePunctuation("."); emit(node.qualifier); } + emitTypeArguments(node, node.typeArguments); } // From fbd6ce8d45b4fc281376011cf5d8ae87c2423ba9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 14:01:28 -0700 Subject: [PATCH 20/21] undo unrelated change --- src/compiler/types.ts | 2 +- .../reference/importTypeGenericTypes.js | 64 ++----------------- 2 files changed, 7 insertions(+), 59 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ad2ea833b22bf..2201eb58e1cd6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2584,7 +2584,7 @@ namespace ts { // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead - /* @internal */ resolvedModules: Map; + /* @internal */ resolvedModules: Map; /* @internal */ resolvedTypeReferenceDirectiveNames: Map; /* @internal */ imports: ReadonlyArray; // Identifier only if `declare global` diff --git a/tests/baselines/reference/importTypeGenericTypes.js b/tests/baselines/reference/importTypeGenericTypes.js index 5222f7ff678bd..ec44bc558297c 100644 --- a/tests/baselines/reference/importTypeGenericTypes.js +++ b/tests/baselines/reference/importTypeGenericTypes.js @@ -101,8 +101,12 @@ declare class Bar { } export { Bar }; //// [usage.d.ts] -export declare const x: import("./foo"); -export declare let y: import("./foo2").Bar.I; +export declare const x: import("./foo")<{ + x: number; +}>; +export declare let y: import("./foo2").Bar.I<{ + x: number; +}>; export declare class Bar2 { item: { a: string; @@ -113,59 +117,3 @@ export declare class Bar2 { constructor(input?: any); } export declare let shim: typeof import("./foo2"); - - -//// [DtsFileErrors] - - -tests/cases/conformance/types/import/usage.d.ts(1,25): error TS2314: Generic type 'Point' requires 1 type argument(s). -tests/cases/conformance/types/import/usage.d.ts(2,23): error TS2314: Generic type 'I' requires 1 type argument(s). - - -==== tests/cases/conformance/types/import/foo.d.ts (0 errors) ==== - interface Point { - x: number; - y: number; - data: T; - } - export = Point; - -==== tests/cases/conformance/types/import/foo2.d.ts (0 errors) ==== - declare namespace Bar { - interface I { - a: string; - b: number; - data: T; - } - } - export declare namespace Baz { - interface J { - a: number; - b: string; - data: T; - } - } - declare class Bar { - item: Bar.I; - constructor(input: Baz.J); - } - export { Bar }; - -==== tests/cases/conformance/types/import/usage.d.ts (2 errors) ==== - export declare const x: import("./foo"); - ~~~~~~~~~~~~~~~ -!!! error TS2314: Generic type 'Point' requires 1 type argument(s). - export declare let y: import("./foo2").Bar.I; - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2314: Generic type 'I' requires 1 type argument(s). - export declare class Bar2 { - item: { - a: string; - b: number; - c: object; - data: T; - }; - constructor(input?: any); - } - export declare let shim: typeof import("./foo2"); - \ No newline at end of file From 0c143a0cf02b5f1d135d8ade159fbb440ebddf90 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 30 Mar 2018 14:20:02 -0700 Subject: [PATCH 21/21] Test for and support import type nodes in bundled declaration emit --- src/compiler/checker.ts | 2 +- src/compiler/transformers/declarations.ts | 18 +++++-- src/compiler/types.ts | 2 +- src/compiler/utilities.ts | 6 ++- .../reference/importTypeAmdBundleRewrite.js | 48 +++++++++++++++++++ .../importTypeAmdBundleRewrite.symbols | 24 ++++++++++ .../importTypeAmdBundleRewrite.types | 28 +++++++++++ .../import/importTypeAmdBundleRewrite.ts | 14 ++++++ 8 files changed, 135 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/importTypeAmdBundleRewrite.js create mode 100644 tests/baselines/reference/importTypeAmdBundleRewrite.symbols create mode 100644 tests/baselines/reference/importTypeAmdBundleRewrite.types create mode 100644 tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bf0e5cef8396f..25502f5a3bfff 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -26207,7 +26207,7 @@ namespace ts { } } - function getExternalModuleFileFromDeclaration(declaration: AnyImportOrReExport | ModuleDeclaration): SourceFile { + function getExternalModuleFileFromDeclaration(declaration: AnyImportOrReExport | ModuleDeclaration | ImportTypeNode): SourceFile { const specifier = declaration.kind === SyntaxKind.ModuleDeclaration ? tryCast(declaration.name, isStringLiteral) : getExternalModuleName(declaration); const moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); if (!moduleSymbol) { diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 8ce0e32a3bab2..b5fdf3ab6ea31 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -450,9 +450,9 @@ namespace ts { return setCommentRange(updated, getCommentRange(original)); } - function rewriteModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration, input: T): T | StringLiteral { + function rewriteModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode, input: T): T | StringLiteral { if (!input) return; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== SyntaxKind.ModuleDeclaration; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== SyntaxKind.ModuleDeclaration && parent.kind !== SyntaxKind.ImportTypeNode); if (input.kind === SyntaxKind.StringLiteral && isBundledEmit) { const newName = getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -765,6 +765,16 @@ namespace ts { case SyntaxKind.ConstructorType: { return cleanup(updateConstructorTypeNode(input, visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), visitNode(input.type, visitDeclarationSubtree))); } + case SyntaxKind.ImportTypeNode: { + if (!isLiteralImportTypeNode(input)) return cleanup(input); + return cleanup(updateImportTypeNode( + input, + updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), + input.qualifier, + visitNodes(input.typeArguments, visitDeclarationSubtree, isTypeNode), + input.isTypeOf + )); + } default: Debug.assertNever(input, `Attempted to process unhandled node kind: ${(ts as any).SyntaxKind[(input as any).kind]}`); } } @@ -1264,7 +1274,8 @@ namespace ts { | TypeReferenceNode | ConditionalTypeNode | FunctionTypeNode - | ConstructorTypeNode; + | ConstructorTypeNode + | ImportTypeNode; function isProcessedComponent(node: Node): node is ProcessedComponent { switch (node.kind) { @@ -1285,6 +1296,7 @@ namespace ts { case SyntaxKind.ConditionalType: case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: + case SyntaxKind.ImportTypeNode: return true; } return false; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2201eb58e1cd6..6583111eb4211 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3256,7 +3256,7 @@ namespace ts { isOptionalParameter(node: ParameterDeclaration): boolean; moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; isArgumentsLocalBinding(node: Identifier): boolean; - getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; + getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): SourceFile; getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3bf4afe556dc7..d0089f2f261db 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1686,13 +1686,15 @@ namespace ts { } } - export function getExternalModuleName(node: AnyImportOrReExport): Expression { + export function getExternalModuleName(node: AnyImportOrReExport | ImportTypeNode): Expression { switch (node.kind) { case SyntaxKind.ImportDeclaration: case SyntaxKind.ExportDeclaration: return node.moduleSpecifier; case SyntaxKind.ImportEqualsDeclaration: return node.moduleReference.kind === SyntaxKind.ExternalModuleReference ? node.moduleReference.expression : undefined; + case SyntaxKind.ImportTypeNode: + return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return Debug.assertNever(node); } @@ -2794,7 +2796,7 @@ namespace ts { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); } - export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string { + export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string { const file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; diff --git a/tests/baselines/reference/importTypeAmdBundleRewrite.js b/tests/baselines/reference/importTypeAmdBundleRewrite.js new file mode 100644 index 0000000000000..2660d7cacfe61 --- /dev/null +++ b/tests/baselines/reference/importTypeAmdBundleRewrite.js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts] //// + +//// [c.ts] +export interface Foo { + x: 12; +} +//// [inner.ts] +const c: import("./b/c").Foo = {x: 12}; +export {c}; + +//// [index.ts] +const d: typeof import("./a/inner")["c"] = {x: 12}; +export {d}; + + +//// [bundle.js] +define("a/b/c", ["require", "exports"], function (require, exports) { + "use strict"; + exports.__esModule = true; +}); +define("a/inner", ["require", "exports"], function (require, exports) { + "use strict"; + exports.__esModule = true; + var c = { x: 12 }; + exports.c = c; +}); +define("index", ["require", "exports"], function (require, exports) { + "use strict"; + exports.__esModule = true; + var d = { x: 12 }; + exports.d = d; +}); + + +//// [bundle.d.ts] +declare module "a/b/c" { + export interface Foo { + x: 12; + } +} +declare module "a/inner" { + const c: import("a/b/c").Foo; + export { c }; +} +declare module "index" { + const d: typeof import("a/inner")["c"]; + export { d }; +} diff --git a/tests/baselines/reference/importTypeAmdBundleRewrite.symbols b/tests/baselines/reference/importTypeAmdBundleRewrite.symbols new file mode 100644 index 0000000000000..105c8b1aec23e --- /dev/null +++ b/tests/baselines/reference/importTypeAmdBundleRewrite.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/types/import/a/b/c.ts === +export interface Foo { +>Foo : Symbol(Foo, Decl(c.ts, 0, 0)) + + x: 12; +>x : Symbol(Foo.x, Decl(c.ts, 0, 22)) +} +=== tests/cases/conformance/types/import/a/inner.ts === +const c: import("./b/c").Foo = {x: 12}; +>c : Symbol(c, Decl(inner.ts, 0, 5)) +>Foo : Symbol(Foo, Decl(c.ts, 0, 0)) +>x : Symbol(x, Decl(inner.ts, 0, 32)) + +export {c}; +>c : Symbol(c, Decl(inner.ts, 1, 8)) + +=== tests/cases/conformance/types/import/index.ts === +const d: typeof import("./a/inner")["c"] = {x: 12}; +>d : Symbol(d, Decl(index.ts, 0, 5)) +>x : Symbol(x, Decl(index.ts, 0, 44)) + +export {d}; +>d : Symbol(d, Decl(index.ts, 1, 8)) + diff --git a/tests/baselines/reference/importTypeAmdBundleRewrite.types b/tests/baselines/reference/importTypeAmdBundleRewrite.types new file mode 100644 index 0000000000000..e8871926cb5fa --- /dev/null +++ b/tests/baselines/reference/importTypeAmdBundleRewrite.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/types/import/a/b/c.ts === +export interface Foo { +>Foo : Foo + + x: 12; +>x : 12 +} +=== tests/cases/conformance/types/import/a/inner.ts === +const c: import("./b/c").Foo = {x: 12}; +>c : Foo +>Foo : Foo +>{x: 12} : { x: 12; } +>x : 12 +>12 : 12 + +export {c}; +>c : Foo + +=== tests/cases/conformance/types/import/index.ts === +const d: typeof import("./a/inner")["c"] = {x: 12}; +>d : Foo +>{x: 12} : { x: 12; } +>x : 12 +>12 : 12 + +export {d}; +>d : Foo + diff --git a/tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts b/tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts new file mode 100644 index 0000000000000..d143abc1939bc --- /dev/null +++ b/tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts @@ -0,0 +1,14 @@ +// @declaration: true +// @module: amd +// @outFile: bundle.js +// @filename: a/b/c.ts +export interface Foo { + x: 12; +} +// @filename: a/inner.ts +const c: import("./b/c").Foo = {x: 12}; +export {c}; + +// @filename: index.ts +const d: typeof import("./a/inner")["c"] = {x: 12}; +export {d};