Skip to content

Commit 11bb6c0

Browse files
committed
Merge branch 'master' into Fix9173-2
2 parents ce45ee7 + 0e6f8eb commit 11bb6c0

197 files changed

Lines changed: 1997 additions & 1235 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/compiler/checker.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ namespace ts {
562562
const declarationFile = getSourceFileOfNode(declaration);
563563
const useFile = getSourceFileOfNode(usage);
564564
if (declarationFile !== useFile) {
565-
if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) {
565+
if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
566+
(!compilerOptions.outFile && !compilerOptions.out)) {
566567
// nodes are in different files and order cannot be determines
567568
return true;
568569
}
@@ -11524,7 +11525,10 @@ namespace ts {
1152411525

1152511526
function checkAssertion(node: AssertionExpression) {
1152611527
const exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression));
11528+
11529+
checkSourceElement(node.type);
1152711530
const targetType = getTypeFromTypeNode(node.type);
11531+
1152811532
if (produceDiagnostics && targetType !== unknownType) {
1152911533
const widenedType = getWidenedType(exprType);
1153011534
if (!isTypeComparableTo(targetType, widenedType)) {
@@ -13559,9 +13563,6 @@ namespace ts {
1355913563
}
1356013564
}
1356113565

13562-
// when checking exported function declarations across modules check only duplicate implementations
13563-
// names and consistency of modifiers are verified when we check local symbol
13564-
const isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & SymbolFlags.Module;
1356513566
let duplicateFunctionDeclaration = false;
1356613567
let multipleConstructorImplementation = false;
1356713568
for (const current of declarations) {
@@ -13594,7 +13595,7 @@ namespace ts {
1359413595
duplicateFunctionDeclaration = true;
1359513596
}
1359613597
}
13597-
else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
13598+
else if (previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
1359813599
reportImplementationExpectedError(previousDeclaration);
1359913600
}
1360013601

@@ -13628,7 +13629,7 @@ namespace ts {
1362813629
}
1362913630

1363013631
// Abstract methods can't have an implementation -- in particular, they don't need one.
13631-
if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
13632+
if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
1363213633
!(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) && !lastSeenNonAmbientDeclaration.questionToken) {
1363313634
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
1363413635
}

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ namespace ts {
412412
},
413413
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
414414
},
415+
{
416+
name: "disableProjectSizeLimit",
417+
type: "boolean"
418+
},
415419
{
416420
name: "strictNullChecks",
417421
type: "boolean",
@@ -761,8 +765,10 @@ namespace ts {
761765
}
762766
}
763767

764-
filesSeen[fileName] = true;
765-
fileNames.push(fileName);
768+
if (!filesSeen[fileName]) {
769+
filesSeen[fileName] = true;
770+
fileNames.push(fileName);
771+
}
766772
}
767773
}
768774
}

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,10 +2921,6 @@
29212921
"category": "Error",
29222922
"code": 8012
29232923
},
2924-
"'property declarations' can only be used in a .ts file.": {
2925-
"category": "Error",
2926-
"code": 8014
2927-
},
29282924
"'enum declarations' can only be used in a .ts file.": {
29292925
"category": "Error",
29302926
"code": 8015

src/compiler/emitter.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20762076
function createPropertyAccessExpression(expression: Expression, name: Identifier): PropertyAccessExpression {
20772077
const result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
20782078
result.expression = parenthesizeForAccess(expression);
2079-
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
20802079
result.name = name;
20812080
return result;
20822081
}
@@ -2223,11 +2222,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22232222
// Returns 'true' if the code was actually indented, false otherwise.
22242223
// If the code is not indented, an optional valueToWriteWhenNotIndenting will be
22252224
// emitted instead.
2226-
function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node, valueToWriteWhenNotIndenting?: string): boolean {
2225+
function indentIfOnDifferentLines(parent: Node, node1: TextRange, node2: TextRange, valueToWriteWhenNotIndenting?: string): boolean {
22272226
const realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
22282227

22292228
// Always use a newline for synthesized code if the synthesizer desires it.
2230-
const synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2);
2229+
const synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2 as Node);
22312230

22322231
if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) {
22332232
increaseIndent();
@@ -2257,7 +2256,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22572256
}
22582257

22592258
emit(node.expression);
2260-
const indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken);
2259+
const dotRangeStart = nodeIsSynthesized(node.expression) ? -1 : node.expression.end;
2260+
const dotRangeEnd = nodeIsSynthesized(node.expression) ? -1 : skipTrivia(currentText, node.expression.end) + 1;
2261+
const dotToken = <TextRange>{ pos: dotRangeStart, end: dotRangeEnd };
2262+
const indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, dotToken);
22612263

22622264
// 1 .toString is a valid property access, emit a space after the literal
22632265
// Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal
@@ -2283,7 +2285,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22832285
write(".");
22842286
}
22852287

2286-
const indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name);
2288+
const indentedAfterDot = indentIfOnDifferentLines(node, dotToken, node.name);
22872289
emit(node.name);
22882290
decreaseIndentIf(indentedBeforeDot, indentedAfterDot);
22892291
}
@@ -2780,7 +2782,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27802782
const identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false);
27812783
synthesizedLHS.expression = identifier;
27822784

2783-
(<PropertyAccessExpression>synthesizedLHS).dotToken = leftHandSideExpression.dotToken;
27842785
(<PropertyAccessExpression>synthesizedLHS).name = leftHandSideExpression.name;
27852786
write(", ");
27862787
}
@@ -3758,7 +3759,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
37583759
getLineOfLocalPositionFromLineMap(currentLineMap, node2.end);
37593760
}
37603761

3761-
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
3762+
function nodeEndIsOnSameLineAsNodeStart(node1: TextRange, node2: TextRange) {
37623763
return getLineOfLocalPositionFromLineMap(currentLineMap, node1.end) ===
37633764
getLineOfLocalPositionFromLineMap(currentLineMap, skipTrivia(currentText, node2.pos));
37643765
}

src/compiler/parser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ namespace ts {
137137
return visitNodes(cbNodes, (<ObjectLiteralExpression>node).properties);
138138
case SyntaxKind.PropertyAccessExpression:
139139
return visitNode(cbNode, (<PropertyAccessExpression>node).expression) ||
140-
visitNode(cbNode, (<PropertyAccessExpression>node).dotToken) ||
141140
visitNode(cbNode, (<PropertyAccessExpression>node).name);
142141
case SyntaxKind.ElementAccessExpression:
143142
return visitNode(cbNode, (<ElementAccessExpression>node).expression) ||
@@ -3571,7 +3570,7 @@ namespace ts {
35713570
// If it wasn't then just try to parse out a '.' and report an error.
35723571
const node = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
35733572
node.expression = expression;
3574-
node.dotToken = parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
3573+
parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
35753574
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
35763575
return finishNode(node);
35773576
}
@@ -3807,7 +3806,6 @@ namespace ts {
38073806
if (dotToken) {
38083807
const propertyAccess = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
38093808
propertyAccess.expression = expression;
3810-
propertyAccess.dotToken = dotToken;
38113809
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
38123810
expression = finishNode(propertyAccess);
38133811
continue;

src/compiler/program.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,8 +1601,19 @@ namespace ts {
16011601
}
16021602
break;
16031603
case SyntaxKind.PropertyDeclaration:
1604-
diagnostics.push(createDiagnosticForNode(node, Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
1605-
return true;
1604+
const propertyDeclaration = <PropertyDeclaration>node;
1605+
if (propertyDeclaration.modifiers) {
1606+
for (const modifier of propertyDeclaration.modifiers) {
1607+
if (modifier.kind !== SyntaxKind.StaticKeyword) {
1608+
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics._0_can_only_be_used_in_a_ts_file, tokenToString(modifier.kind)));
1609+
return true;
1610+
}
1611+
}
1612+
}
1613+
if (checkTypeAnnotation((<PropertyDeclaration>node).type)) {
1614+
return true;
1615+
}
1616+
break;
16061617
case SyntaxKind.EnumDeclaration:
16071618
diagnostics.push(createDiagnosticForNode(node, Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
16081619
return true;

src/compiler/sys.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace ts {
1515
useCaseSensitiveFileNames: boolean;
1616
write(s: string): void;
1717
readFile(path: string, encoding?: string): string;
18+
getFileSize?(path: string): number;
1819
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
1920
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
2021
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
@@ -79,7 +80,7 @@ namespace ts {
7980
realpath(path: string): string;
8081
};
8182

82-
export var sys: System = (function () {
83+
export var sys: System = (function() {
8384

8485
function getWScriptSystem(): System {
8586

@@ -503,7 +504,7 @@ namespace ts {
503504
}
504505
);
505506
},
506-
resolvePath: function (path: string): string {
507+
resolvePath: function(path: string): string {
507508
return _path.resolve(path);
508509
},
509510
fileExists,
@@ -540,6 +541,16 @@ namespace ts {
540541
}
541542
return process.memoryUsage().heapUsed;
542543
},
544+
getFileSize(path) {
545+
try {
546+
const stat = _fs.statSync(path);
547+
if (stat.isFile()) {
548+
return stat.size;
549+
}
550+
}
551+
catch (e) { }
552+
return 0;
553+
},
543554
exit(exitCode?: number): void {
544555
process.exit(exitCode);
545556
},

src/compiler/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,6 @@ namespace ts {
980980
// @kind(SyntaxKind.PropertyAccessExpression)
981981
export interface PropertyAccessExpression extends MemberExpression, Declaration {
982982
expression: LeftHandSideExpression;
983-
dotToken: Node;
984983
name: Identifier;
985984
}
986985

@@ -2224,7 +2223,8 @@ namespace ts {
22242223

22252224
/* @internal */
22262225
Nullable = Undefined | Null,
2227-
Falsy = String | Number | Boolean | Void | Undefined | Null,
2226+
/* @internal */
2227+
Falsy = Void | Undefined | Null, // TODO: Add false, 0, and ""
22282228
/* @internal */
22292229
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null | Never,
22302230
/* @internal */
@@ -2561,6 +2561,7 @@ namespace ts {
25612561
/* @internal */ suppressOutputPathCheck?: boolean;
25622562
target?: ScriptTarget;
25632563
traceResolution?: boolean;
2564+
disableSizeLimit?: boolean;
25642565
types?: string[];
25652566
/** Paths used to used to compute primary types search locations */
25662567
typeRoots?: string[];

src/compiler/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,10 @@ namespace ts {
27142714
return forEach(supportedJavascriptExtensions, extension => fileExtensionIs(fileName, extension));
27152715
}
27162716

2717+
export function hasTypeScriptFileExtension(fileName: string) {
2718+
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
2719+
}
2720+
27172721
/**
27182722
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
27192723
* representing the UTF-8 encoding of the character, and return the expanded char code list.

0 commit comments

Comments
 (0)