Skip to content

Commit 5b9bd82

Browse files
author
Andy Hanson
committed
Merge branch 'master' into resolve_entity_name
2 parents 7908257 + fa991b5 commit 5b9bd82

File tree

246 files changed

+6044
-28291
lines changed

Some content is hidden

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

246 files changed

+6044
-28291
lines changed

.travis.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,33 @@ node_js:
77

88
sudo: false
99

10-
os:
11-
- linux
12-
- osx
10+
env:
11+
- workerCount=3
1312

1413
matrix:
1514
fast_finish: true
16-
exclude:
15+
include:
1716
- os: osx
18-
node_js: '4'
17+
node_js: stable
18+
osx_image: xcode7.3
19+
env: workerCount=2
20+
allow_failures:
1921
- os: osx
20-
node_js: '0.10'
2122

2223
branches:
2324
only:
2425
- master
25-
- transforms
26+
- transforms
27+
28+
install:
29+
- npm uninstall typescript
30+
- npm uninstall tslint
31+
- npm install
32+
- npm update
33+
34+
cache:
35+
directories:
36+
- node_modules
37+
38+
git:
39+
depth: 1

Gulpfile.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
449449
});
450450

451451
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
452-
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
452+
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]);
453453
gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]);
454454

455455

@@ -503,7 +503,7 @@ gulp.task("VerifyLKG", false, [], () => {
503503
return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory));
504504
});
505505

506-
gulp.task("LKGInternal", false, ["lib", "local", "lssl"]);
506+
gulp.task("LKGInternal", false, ["lib", "local"]);
507507

508508
gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUseDebugMode"], () => {
509509
return runSequence("LKGInternal", "VerifyLKG");
@@ -956,6 +956,7 @@ const lintTargets = [
956956
"src/server/**/*.ts",
957957
"scripts/tslint/**/*.ts",
958958
"src/services/**/*.ts",
959+
"tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively
959960
];
960961

961962

Jakefile.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibr
551551
compileFile(
552552
tsserverLibraryFile,
553553
languageServiceLibrarySources,
554-
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
554+
[builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets),
555555
/*prefixes*/ [copyright],
556556
/*useBuiltCompiler*/ true,
557557
{ noOutFile: false, generateDeclarations: true });
@@ -562,7 +562,7 @@ task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]);
562562

563563
// Local target to build the compiler and services
564564
desc("Builds the full compiler and services");
565-
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
565+
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl"]);
566566

567567
// Local target to build only tsc.js
568568
desc("Builds only the compiler");
@@ -617,7 +617,7 @@ task("generate-spec", [specMd]);
617617

618618
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
619619
desc("Makes a new LKG out of the built js files");
620-
task("LKG", ["clean", "release", "local", "lssl"].concat(libraryTargets), function() {
620+
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
621621
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets);
622622
var missingFiles = expectedFiles.filter(function (f) {
623623
return !fs.existsSync(f);
@@ -1041,7 +1041,8 @@ var lintTargets = compilerSources
10411041
.concat(serverCoreSources)
10421042
.concat(tslintRulesFiles)
10431043
.concat(servicesSources)
1044-
.concat(["Gulpfile.ts"]);
1044+
.concat(["Gulpfile.ts"])
1045+
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);
10451046

10461047

10471048
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
},
7979
"scripts": {
8080
"pretest": "jake tests",
81-
"test": "jake runtests",
81+
"test": "jake runtests-parallel",
8282
"build": "npm run build:compiler && npm run build:tests",
8383
"build:compiler": "jake local",
8484
"build:tests": "jake tests",

src/compiler/checker.ts

Lines changed: 214 additions & 75 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,12 @@ namespace ts {
334334
return keys;
335335
}
336336

337-
export function getProperty<T>(map: Map<T>, key: string): T {
338-
return hasOwnProperty.call(map, key) ? map[key] : undefined;
337+
export function getProperty<T>(map: Map<T>, key: string): T | undefined {
338+
return hasProperty(map, key) ? map[key] : undefined;
339+
}
340+
341+
export function getOrUpdateProperty<T>(map: Map<T>, key: string, makeValue: () => T): T {
342+
return hasProperty(map, key) ? map[key] : map[key] = makeValue();
339343
}
340344

341345
export function isEmpty<T>(map: Map<T>) {

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,10 @@
19471947
"category": "Error",
19481948
"code": 2689
19491949
},
1950+
"A class must be declared after its base class.": {
1951+
"category": "Error",
1952+
"code": 2690
1953+
},
19501954
"Import declaration '{0}' is using private name '{1}'.": {
19511955
"category": "Error",
19521956
"code": 4000

src/compiler/emitter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25782578
operand = (<TypeAssertion | NonNullExpression>operand).expression;
25792579
}
25802580

2581-
// We have an expression of the form: (<Type>SubExpr)
2581+
// We have an expression of the form: (<Type>SubExpr) or (SubExpr as Type)
25822582
// Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is.
25832583
// Omitting the parentheses, however, could cause change in the semantics of the generated
25842584
// code if the casted expression has a lower precedence than the rest of the expression, e.g.:
@@ -2592,6 +2592,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25922592
operand.kind !== SyntaxKind.DeleteExpression &&
25932593
operand.kind !== SyntaxKind.PostfixUnaryExpression &&
25942594
operand.kind !== SyntaxKind.NewExpression &&
2595+
!(operand.kind === SyntaxKind.BinaryExpression && node.expression.kind === SyntaxKind.AsExpression) &&
25952596
!(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) &&
25962597
!(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression) &&
25972598
!(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression)) {
@@ -6841,7 +6842,7 @@ const _super = (function (geti, seti) {
68416842
// export { x, y }
68426843
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
68436844
const name = (specifier.propertyName || specifier.name).text;
6844-
(exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier);
6845+
getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier);
68456846
}
68466847
}
68476848
break;

src/compiler/program.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,19 +1055,15 @@ namespace ts {
10551055
return resolutions;
10561056
}
10571057

1058-
function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) {
1059-
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
1060-
}
1061-
10621058
/**
1063-
* Given a set of options and a set of root files, returns the set of type directive names
1059+
* Given a set of options, returns the set of type directive names
10641060
* that should be included for this program automatically.
10651061
* This list could either come from the config file,
10661062
* or from enumerating the types root + initial secondary types lookup location.
10671063
* More type directives might appear in the program later as a result of loading actual source files;
10681064
* this list is only the set of defaults that are implicitly included.
10691065
*/
1070-
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
1066+
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] {
10711067
// Use explicit type list from tsconfig.json
10721068
if (options.types) {
10731069
return options.types;
@@ -1080,7 +1076,10 @@ namespace ts {
10801076
if (typeRoots) {
10811077
for (const root of typeRoots) {
10821078
if (host.directoryExists(root)) {
1083-
result = result.concat(host.getDirectories(root));
1079+
for (const typeDirectivePath of host.getDirectories(root)) {
1080+
// Return just the type directive names
1081+
result = result.concat(getBaseFileName(normalizePath(typeDirectivePath)));
1082+
}
10841083
}
10851084
}
10861085
}
@@ -1155,11 +1154,11 @@ namespace ts {
11551154
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
11561155

11571156
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
1158-
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host);
1157+
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, host);
11591158

11601159
if (typeReferences) {
1161-
const inferredRoot = getInferredTypesRoot(options, rootNames, host);
1162-
const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts");
1160+
// This containingFilename needs to match with the one used in managed-side
1161+
const containingFilename = combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts");
11631162
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
11641163
for (let i = 0; i < typeReferences.length; i++) {
11651164
processTypeReferenceDirective(typeReferences[i], resolutions[i]);

src/compiler/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,16 @@ namespace ts {
16121612
antecedent: FlowNode;
16131613
}
16141614

1615+
export type FlowType = Type | IncompleteType;
1616+
1617+
// Incomplete types occur during control flow analysis of loops. An IncompleteType
1618+
// is distinguished from a regular type by a flags value of zero. Incomplete type
1619+
// objects are internal to the getFlowTypeOfRefecence function and never escape it.
1620+
export interface IncompleteType {
1621+
flags: TypeFlags; // No flags set
1622+
type: Type; // The type marked incomplete
1623+
}
1624+
16151625
export interface AmdDependency {
16161626
path: string;
16171627
name: string;
@@ -2156,6 +2166,8 @@ namespace ts {
21562166
mapper?: TypeMapper; // Type mapper for instantiation alias
21572167
referenced?: boolean; // True if alias symbol has been referenced as a value
21582168
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
2169+
hasCommonType?: boolean; // True if constituents of synthetic property all have same type
2170+
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
21592171
resolvedExports?: SymbolTable; // Resolved exports of module
21602172
exportsChecked?: boolean; // True if exports of external module have been checked
21612173
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
@@ -2906,6 +2918,7 @@ namespace ts {
29062918
directoryExists?(directoryName: string): boolean;
29072919
realpath?(path: string): string;
29082920
getCurrentDirectory?(): string;
2921+
getDirectories?(path: string): string[];
29092922
}
29102923

29112924
export interface ResolvedModule {

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,7 @@ namespace ts {
15691569
case SyntaxKind.MethodSignature:
15701570
case SyntaxKind.ModuleDeclaration:
15711571
case SyntaxKind.NamespaceImport:
1572+
case SyntaxKind.NamespaceExportDeclaration:
15721573
case SyntaxKind.Parameter:
15731574
case SyntaxKind.PropertyAssignment:
15741575
case SyntaxKind.PropertyDeclaration:

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ namespace Harness {
750750

751751
export function readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]) {
752752
const fs = new Utils.VirtualFileSystem(path, useCaseSensitiveFileNames());
753-
for (const file in listFiles(path)) {
753+
for (const file of listFiles(path)) {
754754
fs.addFile(file);
755755
}
756756
return ts.matchFiles(path, extension, exclude, include, useCaseSensitiveFileNames(), getCurrentDirectory(), path => {

src/harness/unittests/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace ts.server {
106106
describe("onMessage", () => {
107107
it("should not throw when commands are executed with invalid arguments", () => {
108108
let i = 0;
109-
for (name in CommandNames) {
109+
for (const name in CommandNames) {
110110
if (!Object.prototype.hasOwnProperty.call(CommandNames, name)) {
111111
continue;
112112
}

src/lib/es2015.core.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ interface NumberConstructor {
226226
/**
227227
* The value of the largest integer n such that n and n + 1 are both exactly representable as
228228
* a Number value.
229-
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1.
229+
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
230230
*/
231231
readonly MAX_SAFE_INTEGER: number;
232232

@@ -343,6 +343,30 @@ interface ObjectConstructor {
343343
defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any;
344344
}
345345

346+
interface ReadonlyArray<T> {
347+
/**
348+
* Returns the value of the first element in the array where predicate is true, and undefined
349+
* otherwise.
350+
* @param predicate find calls predicate once for each element of the array, in ascending
351+
* order, until it finds one where predicate returns true. If such an element is found, find
352+
* immediately returns that element value. Otherwise, find returns undefined.
353+
* @param thisArg If provided, it will be used as the this value for each invocation of
354+
* predicate. If it is not provided, undefined is used instead.
355+
*/
356+
find(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg?: any): T | undefined;
357+
358+
/**
359+
* Returns the index of the first element in the array where predicate is true, and undefined
360+
* otherwise.
361+
* @param predicate find calls predicate once for each element of the array, in ascending
362+
* order, until it finds one where predicate returns true. If such an element is found,
363+
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
364+
* @param thisArg If provided, it will be used as the this value for each invocation of
365+
* predicate. If it is not provided, undefined is used instead.
366+
*/
367+
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
368+
}
369+
346370
interface RegExp {
347371
/**
348372
* Returns a string indicating the flags of the regular expression in question. This field is read-only.

src/lib/es2015.iterable.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ interface ArrayConstructor {
6363
from<T>(iterable: Iterable<T>): Array<T>;
6464
}
6565

66+
interface ReadonlyArray<T> {
67+
/** Iterator */
68+
[Symbol.iterator](): IterableIterator<T>;
69+
70+
/**
71+
* Returns an array of key, value pairs for every entry in the array
72+
*/
73+
entries(): IterableIterator<[number, T]>;
74+
75+
/**
76+
* Returns an list of keys in the array
77+
*/
78+
keys(): IterableIterator<number>;
79+
80+
/**
81+
* Returns an list of values in the array
82+
*/
83+
values(): IterableIterator<T>;
84+
}
85+
6686
interface IArguments {
6787
/** Iterator */
6888
[Symbol.iterator](): IterableIterator<any>;

src/lib/es5.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,11 @@ interface Array<T> {
11081108
* Removes the last element from an array and returns it.
11091109
*/
11101110
pop(): T | undefined;
1111+
/**
1112+
* Combines two or more arrays.
1113+
* @param items Additional items to add to the end of array1.
1114+
*/
1115+
concat(...items: T[][]): T[];
11111116
/**
11121117
* Combines two or more arrays.
11131118
* @param items Additional items to add to the end of array1.

src/server/editorServices.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ namespace ts.server {
115115
readFile: fileName => this.host.readFile(fileName),
116116
directoryExists: directoryName => this.host.directoryExists(directoryName)
117117
};
118+
if (this.host.realpath) {
119+
this.moduleResolutionHost.realpath = path => this.host.realpath(path);
120+
}
118121
}
119122

120123
private resolveNamesWithLocalCache<T extends Timestamped & { failedLookupLocations: string[] }, R>(

src/server/tsconfig.library.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"types": []
1111
},
1212
"files": [
13+
"../services/shims.ts",
14+
"../services/utilities.ts",
1315
"editorServices.ts",
1416
"protocol.d.ts",
1517
"session.ts"

0 commit comments

Comments
 (0)