Skip to content

Commit 56a7217

Browse files
author
Zhengbo Li
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into i6016
2 parents 631363f + 827fec6 commit 56a7217

140 files changed

Lines changed: 4907 additions & 1467 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.

Jakefile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,8 @@ function lintFileAsync(options, path, cb) {
924924
var lintTargets = compilerSources
925925
.concat(harnessCoreSources)
926926
.concat(serverCoreSources)
927-
.concat(scriptSources);
927+
.concat(scriptSources)
928+
.concat([path.join(servicesDirectory, "services.ts")]);
928929

929930
desc("Runs tslint on the compiler sources");
930931
task("lint", ["build-rules"], function() {

doc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This directory contains miscellaneous documentation such as the TypeScript language specification and logo.
2+
If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook).
3+
4+
# Spec Contributions
5+
6+
The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats.
7+
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests.

src/compiler/binder.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,10 +1499,7 @@ namespace ts {
14991499

15001500
// If this is a property-parameter, then also declare the property symbol into the
15011501
// containing class.
1502-
if (node.flags & NodeFlags.AccessibilityModifier &&
1503-
node.parent.kind === SyntaxKind.Constructor &&
1504-
isClassLike(node.parent.parent)) {
1505-
1502+
if (isParameterPropertyDeclaration(node)) {
15061503
const classDeclaration = <ClassLikeDeclaration>node.parent.parent;
15071504
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
15081505
}

src/compiler/checker.ts

Lines changed: 311 additions & 386 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -796,23 +796,6 @@ namespace ts {
796796
return path;
797797
}
798798

799-
const backslashOrDoubleQuote = /[\"\\]/g;
800-
const escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
801-
const escapedCharsMap: Map<string> = {
802-
"\0": "\\0",
803-
"\t": "\\t",
804-
"\v": "\\v",
805-
"\f": "\\f",
806-
"\b": "\\b",
807-
"\r": "\\r",
808-
"\n": "\\n",
809-
"\\": "\\\\",
810-
"\"": "\\\"",
811-
"\u2028": "\\u2028", // lineSeparator
812-
"\u2029": "\\u2029", // paragraphSeparator
813-
"\u0085": "\\u0085" // nextLine
814-
};
815-
816799
export interface ObjectAllocator {
817800
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
818801
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;

src/compiler/declarationEmitter.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,14 +1534,6 @@ namespace ts {
15341534
}
15351535

15361536
function emitBindingElement(bindingElement: BindingElement) {
1537-
function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
1538-
const diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
1539-
return diagnosticMessage !== undefined ? {
1540-
diagnosticMessage,
1541-
errorNode: bindingElement,
1542-
typeName: bindingElement.name
1543-
} : undefined;
1544-
}
15451537

15461538
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
15471539
// If bindingElement is an omittedExpression (i.e. containing elision),

src/compiler/diagnosticMessages.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@
795795
"category": "Error",
796796
"code": 1248
797797
},
798+
"A decorator can only decorate a method implementation, not an overload.": {
799+
"category": "Error",
800+
"code": 1249
801+
},
798802
"'with' statements are not allowed in an async function block.": {
799803
"category": "Error",
800804
"code": 1300
@@ -1691,7 +1695,7 @@
16911695
"category": "Error",
16921696
"code": 2528
16931697
},
1694-
"JSX element attributes type '{0}' must be an object type.": {
1698+
"JSX element attributes type '{0}' may not be a union type.": {
16951699
"category": "Error",
16961700
"code": 2600
16971701
},
@@ -1759,6 +1763,14 @@
17591763
"category": "Error",
17601764
"code": 2658
17611765
},
1766+
"'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.": {
1767+
"category": "Error",
1768+
"code": 2659
1769+
},
1770+
"'super' can only be referenced in members of derived classes or object literal expressions.": {
1771+
"category": "Error",
1772+
"code": 2660
1773+
},
17621774
"Import declaration '{0}' is using private name '{1}'.": {
17631775
"category": "Error",
17641776
"code": 4000

src/compiler/emitter.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -779,12 +779,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
779779
}
780780
}
781781

782-
function emitTrailingCommaIfPresent(nodeList: NodeArray<Node>): void {
783-
if (nodeList.hasTrailingComma) {
784-
write(",");
785-
}
786-
}
787-
788782
function emitLinePreservingList(parent: Node, nodes: NodeArray<Node>, allowTrailingComma: boolean, spacesBetweenBraces: boolean) {
789783
Debug.assert(nodes.length > 0);
790784

@@ -2451,7 +2445,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
24512445
}
24522446

24532447
function emitPrefixUnaryExpression(node: PrefixUnaryExpression) {
2454-
const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand);
2448+
const exportChanged = (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) &&
2449+
isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand);
24552450

24562451
if (exportChanged) {
24572452
// emit
@@ -3248,10 +3243,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
32483243
}
32493244
}
32503245

3251-
function emitDownLevelForOfStatement(node: ForOfStatement) {
3252-
emitLoop(node, emitDownLevelForOfStatementWorker);
3253-
}
3254-
32553246
function emitDownLevelForOfStatementWorker(node: ForOfStatement, loop: ConvertedLoop) {
32563247
// The following ES6 code:
32573248
//
@@ -4289,22 +4280,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
42894280

42904281
// TODO (yuisu) : we should not have special cases to condition emitting comments
42914282
// but have one place to fix check for these conditions.
4292-
if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature &&
4293-
node.parent && node.parent.kind !== SyntaxKind.PropertyAssignment &&
4294-
node.parent.kind !== SyntaxKind.CallExpression) {
4295-
// 1. Methods will emit the comments as part of emitting method declaration
4296-
4283+
const { kind, parent } = node;
4284+
if (kind !== SyntaxKind.MethodDeclaration &&
4285+
kind !== SyntaxKind.MethodSignature &&
4286+
parent &&
4287+
parent.kind !== SyntaxKind.PropertyAssignment &&
4288+
parent.kind !== SyntaxKind.CallExpression &&
4289+
parent.kind !== SyntaxKind.ArrayLiteralExpression) {
4290+
// 1. Methods will emit comments at their assignment declaration sites.
4291+
//
42974292
// 2. If the function is a property of object literal, emitting leading-comments
4298-
// is done by emitNodeWithoutSourceMap which then call this function.
4299-
// In particular, we would like to avoid emit comments twice in following case:
4300-
// For example:
4293+
// is done by emitNodeWithoutSourceMap which then call this function.
4294+
// In particular, we would like to avoid emit comments twice in following case:
4295+
//
43014296
// var obj = {
43024297
// id:
43034298
// /*comment*/ () => void
43044299
// }
4305-
4300+
//
43064301
// 3. If the function is an argument in call expression, emitting of comments will be
4307-
// taken care of in emit list of arguments inside of emitCallexpression
4302+
// taken care of in emit list of arguments inside of 'emitCallExpression'.
4303+
//
4304+
// 4. If the function is in an array literal, 'emitLinePreservingList' will take care
4305+
// of leading comments.
43084306
emitLeadingComments(node);
43094307
}
43104308

@@ -4331,12 +4329,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
43314329
}
43324330

43334331
emitSignatureAndBody(node);
4334-
if (modulekind !== ModuleKind.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
4332+
if (modulekind !== ModuleKind.ES6 && kind === SyntaxKind.FunctionDeclaration && parent === currentSourceFile && node.name) {
43354333
emitExportMemberAssignments((<FunctionDeclaration>node).name);
43364334
}
43374335

43384336
emitEnd(node);
4339-
if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) {
4337+
if (kind !== SyntaxKind.MethodDeclaration && kind !== SyntaxKind.MethodSignature) {
43404338
emitTrailingComments(node);
43414339
}
43424340
}

src/compiler/parser.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -771,10 +771,6 @@ namespace ts {
771771
return doInsideOfContext(ParserContextFlags.Yield, func);
772772
}
773773

774-
function doOutsideOfYieldContext<T>(func: () => T): T {
775-
return doOutsideOfContext(ParserContextFlags.Yield, func);
776-
}
777-
778774
function doInDecoratorContext<T>(func: () => T): T {
779775
return doInsideOfContext(ParserContextFlags.Decorator, func);
780776
}
@@ -791,10 +787,6 @@ namespace ts {
791787
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
792788
}
793789

794-
function doOutsideOfYieldAndAwaitContext<T>(func: () => T): T {
795-
return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
796-
}
797-
798790
function inContext(flags: ParserContextFlags) {
799791
return (contextFlags & flags) !== 0;
800792
}
@@ -851,10 +843,6 @@ namespace ts {
851843
return token = scanner.scan();
852844
}
853845

854-
function getTokenPos(pos: number): number {
855-
return skipTrivia(sourceText, pos);
856-
}
857-
858846
function reScanGreaterToken(): SyntaxKind {
859847
return token = scanner.reScanGreaterToken();
860848
}
@@ -2644,10 +2632,6 @@ namespace ts {
26442632
isStartOfExpression();
26452633
}
26462634

2647-
function allowInAndParseExpression(): Expression {
2648-
return allowInAnd(parseExpression);
2649-
}
2650-
26512635
function parseExpression(): Expression {
26522636
// Expression[in]:
26532637
// AssignmentExpression[in]
@@ -3962,7 +3946,6 @@ namespace ts {
39623946

39633947
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
39643948
const tokenIsIdentifier = isIdentifier();
3965-
const nameToken = token;
39663949
const propertyName = parsePropertyName();
39673950

39683951
// Disallowing of optional property assignments happens in the grammar checker.
@@ -5104,10 +5087,6 @@ namespace ts {
51045087
return undefined;
51055088
}
51065089

5107-
function parseHeritageClausesWorker() {
5108-
return parseList(ParsingContext.HeritageClauses, parseHeritageClause);
5109-
}
5110-
51115090
function parseHeritageClause() {
51125091
if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) {
51135092
const node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
@@ -5253,12 +5232,6 @@ namespace ts {
52535232
return nextToken() === SyntaxKind.SlashToken;
52545233
}
52555234

5256-
function nextTokenIsCommaOrFromKeyword() {
5257-
nextToken();
5258-
return token === SyntaxKind.CommaToken ||
5259-
token === SyntaxKind.FromKeyword;
5260-
}
5261-
52625235
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
52635236
parseExpected(SyntaxKind.ImportKeyword);
52645237
const afterImportPos = scanner.getStartPos();
@@ -5751,13 +5724,6 @@ namespace ts {
57515724
return finishNode(parameter);
57525725
}
57535726

5754-
function parseJSDocOptionalType(type: JSDocType): JSDocOptionalType {
5755-
const result = <JSDocOptionalType>createNode(SyntaxKind.JSDocOptionalType, type.pos);
5756-
nextToken();
5757-
result.type = type;
5758-
return finishNode(result);
5759-
}
5760-
57615727
function parseJSDocTypeReference(): JSDocTypeReference {
57625728
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
57635729
result.name = parseSimplePropertyName();

src/compiler/program.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,11 @@ namespace ts {
573573
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
574574
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
575575
// get any preEmit diagnostics, not just the ones
576-
if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) {
577-
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
576+
if (options.noEmitOnError) {
577+
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
578+
if (preEmitDiagnostics.length > 0) {
579+
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
580+
}
578581
}
579582

580583
// Create the emit resolver outside of the "emitTime" tracking code below. That way

0 commit comments

Comments
 (0)