diff --git a/bin/tsc.js b/bin/tsc.js index c55b3be37ba..16408e9c208 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -24740,7 +24740,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -24848,7 +24848,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } diff --git a/bin/tsserver.js b/bin/tsserver.js index 71ff883dbce..9c655a0b0c1 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -25131,7 +25131,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -25239,7 +25239,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } diff --git a/bin/typescript.js b/bin/typescript.js index 3dd6dd919be..138a38642c9 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -29466,7 +29466,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -29576,7 +29576,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 3dd6dd919be..138a38642c9 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -29466,7 +29466,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } @@ -29576,7 +29576,7 @@ var ts; emitDeclarationName(node); write("\", "); emitDeclarationName(node); - write(")"); + write(");"); } emitExportMemberAssignments(node.name); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4cebc167d59..a18f2921a9a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -365,21 +365,38 @@ namespace ts { case SyntaxKind.SourceFile: if (!isExternalModule(location)) break; case SyntaxKind.ModuleDeclaration: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.ModuleMember)) { - if (result.flags & meaning || !(result.flags & SymbolFlags.Alias && getDeclarationOfAliasSymbol(result).kind === SyntaxKind.ExportSpecifier)) { - break loop; - } - result = undefined; - } - else if (location.kind === SyntaxKind.SourceFile || + let moduleExports = getSymbolOfNode(location).exports; + if (location.kind === SyntaxKind.SourceFile || (location.kind === SyntaxKind.ModuleDeclaration && (location).name.kind === SyntaxKind.StringLiteral)) { - result = getSymbolOfNode(location).exports["default"]; + + // It's an external module. Because of module/namespace merging, a module's exports are in scope, + // yet we never want to treat an export specifier as putting a member in scope. Therefore, + // if the name we find is purely an export specifier, it is not actually considered in scope. + // Two things to note about this: + // 1. We have to check this without calling getSymbol. The problem with calling getSymbol + // on an export specifier is that it might find the export specifier itself, and try to + // resolve it as an alias. This will cause the checker to consider the export specifier + // a circular alias reference when it might not be. + // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* + // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, + // which is not the desired behavior. + if (hasProperty(moduleExports, name) && + moduleExports[name].flags === SymbolFlags.Alias && + getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { + break; + } + + result = moduleExports["default"]; let localSymbol = getLocalSymbolForExportDefault(result); if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } + + if (result = getSymbol(moduleExports, name, meaning & SymbolFlags.ModuleMember)) { + break loop; + } break; case SyntaxKind.EnumDeclaration: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 469b13294ad..3fbe640254f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5347,7 +5347,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(/*newLine*/ true) + emitTempDeclarations(/*newLine*/ true); } function emitSetters(exportStarFunction: string) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a507125d4bb..79ed76545cf 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3988,7 +3988,7 @@ namespace ts { parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: - if (decorators) { + if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. let node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); @@ -4390,7 +4390,7 @@ namespace ts { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } - if (decorators) { + if (decorators || modifiers) { // treat this as a property declaration with a missing name. let name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); diff --git a/src/services/services.ts b/src/services/services.ts index 70022cfe0bf..83e7a05dd84 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1792,6 +1792,11 @@ namespace ts { sourceFile.moduleName = moduleName; } + // Store syntactic diagnostics + if (diagnostics && sourceFile.parseDiagnostics) { + diagnostics.push(...sourceFile.parseDiagnostics); + } + let newLine = getNewLineCharacter(options); // Output diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt new file mode 100644 index 00000000000..4bbc2d8167d --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,11): error TS1146: Declaration expected. +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: '=' expected. + + +==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (2 errors) ==== + class C { + public {}; + +!!! error TS1146: Declaration expected. + ~ +!!! error TS1005: '=' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.js b/tests/baselines/reference/classMemberWithMissingIdentifier.js new file mode 100644 index 00000000000..cd1825d0da0 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.js @@ -0,0 +1,12 @@ +//// [classMemberWithMissingIdentifier.ts] +class C { + public {}; +} + +//// [classMemberWithMissingIdentifier.js] +var C = (function () { + function C() { + this. = {}; + } + return C; +})(); diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt new file mode 100644 index 00000000000..b21e062e3b0 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,11): error TS1146: Declaration expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,14): error TS2304: Cannot find name 'name'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ']' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,19): error TS2304: Cannot find name 'string'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,25): error TS1005: ',' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1136: Property assignment expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: Cannot find name 'VariableDeclaration'. + + +==== tests/cases/compiler/classMemberWithMissingIdentifier2.ts (8 errors) ==== + class C { + public {[name:string]:VariableDeclaration}; + +!!! error TS1146: Declaration expected. + ~ +!!! error TS1005: '=' expected. + ~~~~ +!!! error TS2304: Cannot find name 'name'. + ~ +!!! error TS1005: ']' expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'string'. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1136: Property assignment expected. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'VariableDeclaration'. + } \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.js b/tests/baselines/reference/classMemberWithMissingIdentifier2.js new file mode 100644 index 00000000000..e8494755b22 --- /dev/null +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.js @@ -0,0 +1,13 @@ +//// [classMemberWithMissingIdentifier2.ts] +class C { + public {[name:string]:VariableDeclaration}; +} + +//// [classMemberWithMissingIdentifier2.js] +var C = (function () { + function C() { + this. = (_a = {}, _a[name] = string, _a.VariableDeclaration = VariableDeclaration, _a); + var _a; + } + return C; +})(); diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js new file mode 100644 index 00000000000..3fc40121011 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.js @@ -0,0 +1,15 @@ +//// [exportSpecifierAndExportedMemberDeclaration.ts] +declare module "m2" { + export module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} + +//// [exportSpecifierAndExportedMemberDeclaration.js] diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols new file mode 100644 index 00000000000..7e2de735c47 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts === +declare module "m2" { + export module X { +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) + + interface I { } +>I : Symbol(I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) + } + function Y(); +>Y : Symbol(Y, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 3, 5)) + + export { Y as X }; +>Y : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) + + function Z(): X.I; +>Z : Symbol(Z, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 22)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>I : Symbol(X.I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) +} + +declare module "m2" { + function Z2(): X.I; +>Z2 : Symbol(Z2, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 9, 21)) +>X : Symbol(X, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 0, 21), Decl(exportSpecifierAndExportedMemberDeclaration.ts, 5, 12)) +>I : Symbol(X.I, Decl(exportSpecifierAndExportedMemberDeclaration.ts, 1, 21)) +} diff --git a/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types new file mode 100644 index 00000000000..931552819c7 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndExportedMemberDeclaration.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts === +declare module "m2" { + export module X { +>X : () => any + + interface I { } +>I : I + } + function Y(); +>Y : () => any + + export { Y as X }; +>Y : () => any +>X : () => any + + function Z(): X.I; +>Z : () => X.I +>X : any +>I : X.I +} + +declare module "m2" { + function Z2(): X.I; +>Z2 : () => X.I +>X : any +>I : X.I +} diff --git a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt new file mode 100644 index 00000000000..eb444919f2c --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts(11,20): error TS2503: Cannot find namespace 'X'. + + +==== tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts (1 errors) ==== + declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; + } + + declare module "m2" { + function Z2(): X.I; + ~ +!!! error TS2503: Cannot find namespace 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js new file mode 100644 index 00000000000..d99ff3627ed --- /dev/null +++ b/tests/baselines/reference/exportSpecifierAndLocalMemberDeclaration.js @@ -0,0 +1,15 @@ +//// [exportSpecifierAndLocalMemberDeclaration.ts] +declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} + +//// [exportSpecifierAndLocalMemberDeclaration.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js new file mode 100644 index 00000000000..003956e2822 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.js @@ -0,0 +1,8 @@ +//// [exportSpecifierReferencingOuterDeclaration1.ts] +declare module X { export interface bar { } } +declare module "m" { + export { X }; + export function foo(): X.bar; +} + +//// [exportSpecifierReferencingOuterDeclaration1.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols new file mode 100644 index 00000000000..16abde86d32 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === +declare module X { export interface bar { } } +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) +>bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) + +declare module "m" { + export { X }; +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 12)) + + export function foo(): X.bar; +>foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 17)) +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) +>bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) +} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types new file mode 100644 index 00000000000..be03554a1b0 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === +declare module X { export interface bar { } } +>X : any +>bar : bar + +declare module "m" { + export { X }; +>X : any + + export function foo(): X.bar; +>foo : () => X.bar +>X : any +>bar : X.bar +} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js new file mode 100644 index 00000000000..e8e96784083 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts] //// + +//// [exportSpecifierReferencingOuterDeclaration2_A.ts] +declare module X { export interface bar { } } + +//// [exportSpecifierReferencingOuterDeclaration2_B.ts] +export { X }; +export declare function foo(): X.bar; + +//// [exportSpecifierReferencingOuterDeclaration2_A.js] +//// [exportSpecifierReferencingOuterDeclaration2_B.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols new file mode 100644 index 00000000000..9a57645b1cb --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === +declare module X { export interface bar { } } +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) +>bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) + +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === +export { X }; +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 8)) + +export declare function foo(): X.bar; +>foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 13)) +>X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) +>bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) + diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types new file mode 100644 index 00000000000..fa59948c116 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === +declare module X { export interface bar { } } +>X : any +>bar : bar + +=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === +export { X }; +>X : any + +export declare function foo(): X.bar; +>foo : () => X.bar +>X : any +>bar : X.bar + diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt new file mode 100644 index 00000000000..e144c48bea4 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts(6,30): error TS2305: Module 'X' has no exported member 'bar'. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts (1 errors) ==== + declare module X { export interface bar { } } + declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error + ~~~ +!!! error TS2305: Module 'X' has no exported member 'bar'. + } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js new file mode 100644 index 00000000000..0f6fff977da --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.js @@ -0,0 +1,10 @@ +//// [exportSpecifierReferencingOuterDeclaration3.ts] +declare module X { export interface bar { } } +declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error +} + +//// [exportSpecifierReferencingOuterDeclaration3.js] diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt new file mode 100644 index 00000000000..6ac67c70d17 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts(4,34): error TS2305: Module 'X' has no exported member 'bar'. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts (0 errors) ==== + declare module X { export interface bar { } } + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts (1 errors) ==== + declare module X { export interface foo { } } + export { X }; + export declare function foo(): X.foo; + export declare function bar(): X.bar; // error + ~~~ +!!! error TS2305: Module 'X' has no exported member 'bar'. \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js new file mode 100644 index 00000000000..4edb5f711a6 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts] //// + +//// [exportSpecifierReferencingOuterDeclaration2_A.ts] +declare module X { export interface bar { } } + +//// [exportSpecifierReferencingOuterDeclaration2_B.ts] +declare module X { export interface foo { } } +export { X }; +export declare function foo(): X.foo; +export declare function bar(): X.bar; // error + +//// [exportSpecifierReferencingOuterDeclaration2_A.js] +//// [exportSpecifierReferencingOuterDeclaration2_B.js] diff --git a/tests/baselines/reference/systemModule13.js b/tests/baselines/reference/systemModule13.js new file mode 100644 index 00000000000..c66e123c738 --- /dev/null +++ b/tests/baselines/reference/systemModule13.js @@ -0,0 +1,21 @@ +//// [systemModule13.ts] + +export let [x,y,z] = [1, 2, 3]; +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +for ([x] of [[1]]) {} + +//// [systemModule13.js] +System.register([], function(exports_1) { + var x, y, z, z0, z1; + return { + setters:[], + execute: function() { + _a = [1, 2, 3], exports_1("x", x = _a[0]), exports_1("y", y = _a[1]), exports_1("z", z = _a[2]); + _b = { a: true, b: { c: "123" } }, exports_1("z0", z0 = _b.a), exports_1("z1", z1 = _b.b.c); + for (var _i = 0, _c = [[1]]; _i < _c.length; _i++) { + exports_1("x", x = _c[_i][0]); + } + } + } + var _a, _b; +}); diff --git a/tests/baselines/reference/systemModule13.symbols b/tests/baselines/reference/systemModule13.symbols new file mode 100644 index 00000000000..d9e64335c2b --- /dev/null +++ b/tests/baselines/reference/systemModule13.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/systemModule13.ts === + +export let [x,y,z] = [1, 2, 3]; +>x : Symbol(x, Decl(systemModule13.ts, 1, 12)) +>y : Symbol(y, Decl(systemModule13.ts, 1, 14)) +>z : Symbol(z, Decl(systemModule13.ts, 1, 16)) + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>z0 : Symbol(z0, Decl(systemModule13.ts, 2, 14)) +>z1 : Symbol(z1, Decl(systemModule13.ts, 2, 25)) +>a : Symbol(a, Decl(systemModule13.ts, 2, 36)) +>b : Symbol(b, Decl(systemModule13.ts, 2, 44)) +>c : Symbol(c, Decl(systemModule13.ts, 2, 49)) + +for ([x] of [[1]]) {} +>x : Symbol(x, Decl(systemModule13.ts, 1, 12)) + diff --git a/tests/baselines/reference/systemModule13.types b/tests/baselines/reference/systemModule13.types new file mode 100644 index 00000000000..35f22be98b8 --- /dev/null +++ b/tests/baselines/reference/systemModule13.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/systemModule13.ts === + +export let [x,y,z] = [1, 2, 3]; +>x : number +>y : number +>z : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +>a : any +>z0 : boolean +>b : any +>c : any +>z1 : string +>{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; } +>a : boolean +>true : boolean +>b : { c: string; } +>{c: "123"} : { c: string; } +>c : string +>"123" : string + +for ([x] of [[1]]) {} +>[x] : number[] +>x : number +>[[1]] : number[][] +>[1] : number[] +>1 : number + diff --git a/tests/cases/compiler/classMemberWithMissingIdentifier.ts b/tests/cases/compiler/classMemberWithMissingIdentifier.ts new file mode 100644 index 00000000000..01ba223f4c4 --- /dev/null +++ b/tests/cases/compiler/classMemberWithMissingIdentifier.ts @@ -0,0 +1,3 @@ +class C { + public {}; +} \ No newline at end of file diff --git a/tests/cases/compiler/classMemberWithMissingIdentifier2.ts b/tests/cases/compiler/classMemberWithMissingIdentifier2.ts new file mode 100644 index 00000000000..e1618659797 --- /dev/null +++ b/tests/cases/compiler/classMemberWithMissingIdentifier2.ts @@ -0,0 +1,3 @@ +class C { + public {[name:string]:VariableDeclaration}; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts b/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts new file mode 100644 index 00000000000..1c20ffb0437 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierAndExportedMemberDeclaration.ts @@ -0,0 +1,12 @@ +declare module "m2" { + export module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts b/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts new file mode 100644 index 00000000000..5f942a75a74 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts @@ -0,0 +1,12 @@ +declare module "m2" { + module X { + interface I { } + } + function Y(); + export { Y as X }; + function Z(): X.I; +} + +declare module "m2" { + function Z2(): X.I; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts new file mode 100644 index 00000000000..e3d0a9000ab --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts @@ -0,0 +1,5 @@ +declare module X { export interface bar { } } +declare module "m" { + export { X }; + export function foo(): X.bar; +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts new file mode 100644 index 00000000000..683358a0e3b --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2.ts @@ -0,0 +1,7 @@ +// @module: commonjs +// @Filename: exportSpecifierReferencingOuterDeclaration2_A.ts +declare module X { export interface bar { } } + +// @Filename: exportSpecifierReferencingOuterDeclaration2_B.ts +export { X }; +export declare function foo(): X.bar; \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts new file mode 100644 index 00000000000..d4ddf3cc4a6 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts @@ -0,0 +1,7 @@ +declare module X { export interface bar { } } +declare module "m" { + module X { export interface foo { } } + export { X }; + export function foo(): X.foo; + export function bar(): X.bar; // error +} \ No newline at end of file diff --git a/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts new file mode 100644 index 00000000000..5beaf1de126 --- /dev/null +++ b/tests/cases/compiler/exportSpecifierReferencingOuterDeclaration4.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @Filename: exportSpecifierReferencingOuterDeclaration2_A.ts +declare module X { export interface bar { } } + +// @Filename: exportSpecifierReferencingOuterDeclaration2_B.ts +declare module X { export interface foo { } } +export { X }; +export declare function foo(): X.foo; +export declare function bar(): X.bar; // error \ No newline at end of file diff --git a/tests/cases/compiler/systemModule13.ts b/tests/cases/compiler/systemModule13.ts new file mode 100644 index 00000000000..2f92d99ab21 --- /dev/null +++ b/tests/cases/compiler/systemModule13.ts @@ -0,0 +1,5 @@ +// @module: system + +export let [x,y,z] = [1, 2, 3]; +export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; +for ([x] of [[1]]) {} \ No newline at end of file diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 06754a5bbc0..fcce034b227 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -68,6 +68,7 @@ var x = 0;`, `});\n`; runTest("var x = 1;", { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, /*fileName*/ undefined, "NamedModule", output) }); + it("No extra errors for file without extension", () => { runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, "file", /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/[]); });