Skip to content

Commit 4a47dfb

Browse files
author
Yui T
committed
Merge branch 'master' into fix5953_crashJSX
Conflicts: src/services/services.ts
2 parents 07c6fe6 + 22856de commit 4a47dfb

File tree

122 files changed

+4407
-1387
lines changed

Some content is hidden

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

122 files changed

+4407
-1387
lines changed

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: 278 additions & 330 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
@@ -794,23 +794,6 @@ namespace ts {
794794
return path;
795795
}
796796

797-
const backslashOrDoubleQuote = /[\"\\]/g;
798-
const escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
799-
const escapedCharsMap: Map<string> = {
800-
"\0": "\\0",
801-
"\t": "\\t",
802-
"\v": "\\v",
803-
"\f": "\\f",
804-
"\b": "\\b",
805-
"\r": "\\r",
806-
"\n": "\\n",
807-
"\\": "\\\\",
808-
"\"": "\\\"",
809-
"\u2028": "\\u2028", // lineSeparator
810-
"\u2029": "\\u2029", // paragraphSeparator
811-
"\u0085": "\\u0085" // nextLine
812-
};
813-
814797
export interface ObjectAllocator {
815798
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
816799
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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@
16911691
"category": "Error",
16921692
"code": 2528
16931693
},
1694-
"JSX element attributes type '{0}' must be an object type.": {
1694+
"JSX element attributes type '{0}' may not be a union type.": {
16951695
"category": "Error",
16961696
"code": 2600
16971697
},
@@ -1759,6 +1759,14 @@
17591759
"category": "Error",
17601760
"code": 2658
17611761
},
1762+
"'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.": {
1763+
"category": "Error",
1764+
"code": 2659
1765+
},
1766+
"'super' can only be referenced in members of derived classes or object literal expressions.": {
1767+
"category": "Error",
1768+
"code": 2660
1769+
},
17621770
"Import declaration '{0}' is using private name '{1}'.": {
17631771
"category": "Error",
17641772
"code": 4000

src/compiler/emitter.ts

Lines changed: 0 additions & 10 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

@@ -3248,10 +3242,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
32483242
}
32493243
}
32503244

3251-
function emitDownLevelForOfStatement(node: ForOfStatement) {
3252-
emitLoop(node, emitDownLevelForOfStatementWorker);
3253-
}
3254-
32553245
function emitDownLevelForOfStatementWorker(node: ForOfStatement, loop: ConvertedLoop) {
32563246
// The following ES6 code:
32573247
//

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/sourcemap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace ts {
1414
reset(): void;
1515
}
1616

17-
const nop = <(...args: any[]) => any>Function.prototype;
1817
let nullSourceMapWriter: SourceMapWriter;
1918

2019
export function getNullSourceMapWriter(): SourceMapWriter {

src/compiler/sys.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ namespace ts {
218218
const _fs = require("fs");
219219
const _path = require("path");
220220
const _os = require("os");
221-
const _tty = require("tty");
222221

223222
// average async stat takes about 30 microseconds
224223
// set chunk size to do 30 files in < 1 millisecond
@@ -313,10 +312,6 @@ namespace ts {
313312
// time dynamically to match the large reference set?
314313
const watchedFileSet = createWatchedFileSet();
315314

316-
function isNode4OrLater(): Boolean {
317-
return parseInt(process.version.charAt(1)) >= 4;
318-
}
319-
320315
const platform: string = _os.platform();
321316
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
322317
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,7 @@ namespace ts {
17231723

17241724
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
17251725
getSymbolAtLocation(node: Node): Symbol;
1726+
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
17261727
getShorthandAssignmentValueSymbol(location: Node): Symbol;
17271728
getTypeAtLocation(node: Node): Type;
17281729
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;

src/compiler/utilities.ts

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -775,43 +775,28 @@ namespace ts {
775775
}
776776
}
777777

778-
export function getSuperContainer(node: Node, includeFunctions: boolean): Node {
778+
/**
779+
* Given an super call\property node returns a closest node where either
780+
* - super call\property is legal in the node and not legal in the parent node the node.
781+
* i.e. super call is legal in constructor but not legal in the class body.
782+
* - node is arrow function (so caller might need to call getSuperContainer in case if he needs to climb higher)
783+
* - super call\property is definitely illegal in the node (but might be legal in some subnode)
784+
* i.e. super property access is illegal in function declaration but can be legal in the statement list
785+
*/
786+
export function getSuperContainer(node: Node, stopOnFunctions: boolean): Node {
779787
while (true) {
780788
node = node.parent;
781-
if (!node) return node;
789+
if (!node) {
790+
return node;
791+
}
782792
switch (node.kind) {
783793
case SyntaxKind.ComputedPropertyName:
784-
// If the grandparent node is an object literal (as opposed to a class),
785-
// then the computed property is not a 'super' container.
786-
// A computed property name in a class needs to be a super container
787-
// so that we can error on it.
788-
if (isClassLike(node.parent.parent)) {
789-
return node;
790-
}
791-
// If this is a computed property, then the parent should not
792-
// make it a super container. The parent might be a property
793-
// in an object literal, like a method or accessor. But in order for
794-
// such a parent to be a super container, the reference must be in
795-
// the *body* of the container.
796794
node = node.parent;
797795
break;
798-
case SyntaxKind.Decorator:
799-
// Decorators are always applied outside of the body of a class or method.
800-
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
801-
// If the decorator's parent is a Parameter, we resolve the this container from
802-
// the grandparent class declaration.
803-
node = node.parent.parent;
804-
}
805-
else if (isClassElement(node.parent)) {
806-
// If the decorator's parent is a class element, we resolve the 'this' container
807-
// from the parent class declaration.
808-
node = node.parent;
809-
}
810-
break;
811796
case SyntaxKind.FunctionDeclaration:
812797
case SyntaxKind.FunctionExpression:
813798
case SyntaxKind.ArrowFunction:
814-
if (!includeFunctions) {
799+
if (!stopOnFunctions) {
815800
continue;
816801
}
817802
case SyntaxKind.PropertyDeclaration:
@@ -822,6 +807,19 @@ namespace ts {
822807
case SyntaxKind.GetAccessor:
823808
case SyntaxKind.SetAccessor:
824809
return node;
810+
case SyntaxKind.Decorator:
811+
// Decorators are always applied outside of the body of a class or method.
812+
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
813+
// If the decorator's parent is a Parameter, we resolve the this container from
814+
// the grandparent class declaration.
815+
node = node.parent.parent;
816+
}
817+
else if (isClassElement(node.parent)) {
818+
// If the decorator's parent is a class element, we resolve the 'this' container
819+
// from the parent class declaration.
820+
node = node.parent;
821+
}
822+
break;
825823
}
826824
}
827825
}
@@ -2748,4 +2746,8 @@ namespace ts {
27482746
}
27492747
}
27502748
}
2749+
2750+
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
2751+
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
2752+
}
27512753
}

src/harness/compilerRunner.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ class CompilerBaselineRunner extends RunnerBase {
251251
const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
252252

253253
const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true);
254-
const pullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ false);
255254

256255
const fullResults: ts.Map<TypeWriterResult[]> = {};
257256
const pullResults: ts.Map<TypeWriterResult[]> = {};

src/harness/fourslash.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,6 @@ namespace FourSlash {
321321
PlaceOpenBraceOnNewLineForControlBlocks: false,
322322
};
323323

324-
this.testData.files.forEach(file => {
325-
const fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), "").substr(1);
326-
const fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf("."));
327-
});
328-
329324
// Open the first file by default
330325
this.openFile(0);
331326
}
@@ -762,10 +757,6 @@ namespace FourSlash {
762757
return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition);
763758
}
764759

765-
private assertionMessage(name: string, actualValue: any, expectedValue: any) {
766-
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
767-
}
768-
769760
public getSyntacticDiagnostics(expected: string) {
770761
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
771762
this.testDiagnostics(expected, diagnostics);
@@ -910,7 +901,6 @@ namespace FourSlash {
910901
}
911902

912903
public verifyCurrentParameterSpanIs(parameter: string) {
913-
const activeSignature = this.getActiveSignatureHelpItem();
914904
const activeParameter = this.getActiveParameter();
915905
assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter);
916906
}
@@ -2189,9 +2179,6 @@ namespace FourSlash {
21892179
}
21902180
}
21912181

2192-
// TOOD: should these just use the Harness's stdout/stderr?
2193-
const fsOutput = new Harness.Compiler.WriterAggregator();
2194-
const fsErrors = new Harness.Compiler.WriterAggregator();
21952182
export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) {
21962183
const content = Harness.IO.readFile(fileName);
21972184
runFourSlashTestContent(basePath, testType, content, fileName);
@@ -2782,6 +2769,10 @@ namespace FourSlashInterface {
27822769
this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative);
27832770
}
27842771

2772+
public assertHasRanges(ranges: FourSlash.Range[]) {
2773+
assert(ranges.length !== 0, "Array of ranges is expected to be non-empty");
2774+
}
2775+
27852776
public completionListIsEmpty() {
27862777
this.state.verifyCompletionListIsEmpty(this.negative);
27872778
}

0 commit comments

Comments
 (0)