Skip to content

Commit 111fdcb

Browse files
committed
Merge branch 'release-1.5'
Conflicts: src/compiler/emitter.ts src/compiler/parser.ts src/compiler/program.ts src/services/services.ts tests/cases/unittests/transpile.ts
2 parents 3cb44fb + fce1423 commit 111fdcb

File tree

40 files changed

+468
-19
lines changed

40 files changed

+468
-19
lines changed

bin/tsc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24740,7 +24740,7 @@ var ts;
2474024740
emitDeclarationName(node);
2474124741
write("\", ");
2474224742
emitDeclarationName(node);
24743-
write(")");
24743+
write(");");
2474424744
}
2474524745
emitExportMemberAssignments(node.name);
2474624746
}
@@ -24848,7 +24848,7 @@ var ts;
2484824848
emitDeclarationName(node);
2484924849
write("\", ");
2485024850
emitDeclarationName(node);
24851-
write(")");
24851+
write(");");
2485224852
}
2485324853
emitExportMemberAssignments(node.name);
2485424854
}

bin/tsserver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25131,7 +25131,7 @@ var ts;
2513125131
emitDeclarationName(node);
2513225132
write("\", ");
2513325133
emitDeclarationName(node);
25134-
write(")");
25134+
write(");");
2513525135
}
2513625136
emitExportMemberAssignments(node.name);
2513725137
}
@@ -25239,7 +25239,7 @@ var ts;
2523925239
emitDeclarationName(node);
2524025240
write("\", ");
2524125241
emitDeclarationName(node);
25242-
write(")");
25242+
write(");");
2524325243
}
2524425244
emitExportMemberAssignments(node.name);
2524525245
}

bin/typescript.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29466,7 +29466,7 @@ var ts;
2946629466
emitDeclarationName(node);
2946729467
write("\", ");
2946829468
emitDeclarationName(node);
29469-
write(")");
29469+
write(");");
2947029470
}
2947129471
emitExportMemberAssignments(node.name);
2947229472
}
@@ -29576,7 +29576,7 @@ var ts;
2957629576
emitDeclarationName(node);
2957729577
write("\", ");
2957829578
emitDeclarationName(node);
29579-
write(")");
29579+
write(");");
2958029580
}
2958129581
emitExportMemberAssignments(node.name);
2958229582
}

bin/typescriptServices.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29466,7 +29466,7 @@ var ts;
2946629466
emitDeclarationName(node);
2946729467
write("\", ");
2946829468
emitDeclarationName(node);
29469-
write(")");
29469+
write(");");
2947029470
}
2947129471
emitExportMemberAssignments(node.name);
2947229472
}
@@ -29576,7 +29576,7 @@ var ts;
2957629576
emitDeclarationName(node);
2957729577
write("\", ");
2957829578
emitDeclarationName(node);
29579-
write(")");
29579+
write(");");
2958029580
}
2958129581
emitExportMemberAssignments(node.name);
2958229582
}

src/compiler/checker.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,21 +365,38 @@ namespace ts {
365365
case SyntaxKind.SourceFile:
366366
if (!isExternalModule(<SourceFile>location)) break;
367367
case SyntaxKind.ModuleDeclaration:
368-
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.ModuleMember)) {
369-
if (result.flags & meaning || !(result.flags & SymbolFlags.Alias && getDeclarationOfAliasSymbol(result).kind === SyntaxKind.ExportSpecifier)) {
370-
break loop;
371-
}
372-
result = undefined;
373-
}
374-
else if (location.kind === SyntaxKind.SourceFile ||
368+
let moduleExports = getSymbolOfNode(location).exports;
369+
if (location.kind === SyntaxKind.SourceFile ||
375370
(location.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>location).name.kind === SyntaxKind.StringLiteral)) {
376-
result = getSymbolOfNode(location).exports["default"];
371+
372+
// It's an external module. Because of module/namespace merging, a module's exports are in scope,
373+
// yet we never want to treat an export specifier as putting a member in scope. Therefore,
374+
// if the name we find is purely an export specifier, it is not actually considered in scope.
375+
// Two things to note about this:
376+
// 1. We have to check this without calling getSymbol. The problem with calling getSymbol
377+
// on an export specifier is that it might find the export specifier itself, and try to
378+
// resolve it as an alias. This will cause the checker to consider the export specifier
379+
// a circular alias reference when it might not be.
380+
// 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely*
381+
// an alias. If we used &, we'd be throwing out symbols that have non alias aspects,
382+
// which is not the desired behavior.
383+
if (hasProperty(moduleExports, name) &&
384+
moduleExports[name].flags === SymbolFlags.Alias &&
385+
getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) {
386+
break;
387+
}
388+
389+
result = moduleExports["default"];
377390
let localSymbol = getLocalSymbolForExportDefault(result);
378391
if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) {
379392
break loop;
380393
}
381394
result = undefined;
382395
}
396+
397+
if (result = getSymbol(moduleExports, name, meaning & SymbolFlags.ModuleMember)) {
398+
break loop;
399+
}
383400
break;
384401
case SyntaxKind.EnumDeclaration:
385402
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) {

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5347,7 +5347,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
53475347
decreaseIndent();
53485348
writeLine();
53495349
write("}"); // return
5350-
emitTempDeclarations(/*newLine*/ true)
5350+
emitTempDeclarations(/*newLine*/ true);
53515351
}
53525352

53535353
function emitSetters(exportStarFunction: string) {

src/compiler/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,7 +3988,7 @@ namespace ts {
39883988
parseExportAssignment(fullStart, decorators, modifiers) :
39893989
parseExportDeclaration(fullStart, decorators, modifiers);
39903990
default:
3991-
if (decorators) {
3991+
if (decorators || modifiers) {
39923992
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
39933993
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
39943994
let node = <Statement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
@@ -4390,7 +4390,7 @@ namespace ts {
43904390
return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers);
43914391
}
43924392

4393-
if (decorators) {
4393+
if (decorators || modifiers) {
43944394
// treat this as a property declaration with a missing name.
43954395
let name = <Identifier>createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
43964396
return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined);

src/services/services.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,11 @@ namespace ts {
17921792
sourceFile.moduleName = moduleName;
17931793
}
17941794

1795+
// Store syntactic diagnostics
1796+
if (diagnostics && sourceFile.parseDiagnostics) {
1797+
diagnostics.push(...sourceFile.parseDiagnostics);
1798+
}
1799+
17951800
let newLine = getNewLineCharacter(options);
17961801

17971802
// Output
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,11): error TS1146: Declaration expected.
2+
tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: '=' expected.
3+
4+
5+
==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (2 errors) ====
6+
class C {
7+
public {};
8+
9+
!!! error TS1146: Declaration expected.
10+
~
11+
!!! error TS1005: '=' expected.
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [classMemberWithMissingIdentifier.ts]
2+
class C {
3+
public {};
4+
}
5+
6+
//// [classMemberWithMissingIdentifier.js]
7+
var C = (function () {
8+
function C() {
9+
this. = {};
10+
}
11+
return C;
12+
})();

0 commit comments

Comments
 (0)