Skip to content

Commit 6fd5e1b

Browse files
committed
Merge branch 'master' into vue-hacks-WIP
2 parents 56d1835 + b5c59c6 commit 6fd5e1b

File tree

264 files changed

+2224
-1718
lines changed

Some content is hidden

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

264 files changed

+2224
-1718
lines changed

Jakefile.js

Lines changed: 31 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var path = require("path");
66
var child_process = require("child_process");
77
var fold = require("travis-fold");
88
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
9+
var ts = require("./lib/typescript");
10+
911

1012
// Variables
1113
var compilerDirectory = "src/compiler/";
@@ -34,6 +36,24 @@ if (process.env.path !== undefined) {
3436
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3537
}
3638

39+
function filesFromConfig(configPath) {
40+
var configText = fs.readFileSync(configPath).toString();
41+
var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true);
42+
if (config.error) {
43+
throw new Error(diagnosticsToString([config.error]));
44+
}
45+
const configFileContent = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));
46+
if (configFileContent.errors && configFileContent.errors.length) {
47+
throw new Error(diagnosticsToString(configFileContent.errors));
48+
}
49+
50+
return configFileContent.fileNames;
51+
52+
function diagnosticsToString(s) {
53+
return s.map(function(e) { return ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine); }).join(ts.sys.newLine);
54+
}
55+
}
56+
3757
function toNs(diff) {
3858
return diff[0] * 1e9 + diff[1];
3959
}
@@ -56,173 +76,12 @@ function measure(marker) {
5676
console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r");
5777
}
5878

59-
var compilerSources = [
60-
"core.ts",
61-
"performance.ts",
62-
"sys.ts",
63-
"types.ts",
64-
"scanner.ts",
65-
"parser.ts",
66-
"utilities.ts",
67-
"binder.ts",
68-
"checker.ts",
69-
"factory.ts",
70-
"visitor.ts",
71-
"transformers/destructuring.ts",
72-
"transformers/ts.ts",
73-
"transformers/jsx.ts",
74-
"transformers/esnext.ts",
75-
"transformers/es2017.ts",
76-
"transformers/es2016.ts",
77-
"transformers/es2015.ts",
78-
"transformers/generators.ts",
79-
"transformers/es5.ts",
80-
"transformers/module/es2015.ts",
81-
"transformers/module/system.ts",
82-
"transformers/module/module.ts",
83-
"transformer.ts",
84-
"sourcemap.ts",
85-
"comments.ts",
86-
"declarationEmitter.ts",
87-
"emitter.ts",
88-
"program.ts",
89-
"commandLineParser.ts",
90-
"tsc.ts",
91-
"diagnosticInformationMap.generated.ts"
92-
].map(function (f) {
93-
return path.join(compilerDirectory, f);
94-
});
95-
96-
var servicesSources = [
97-
"core.ts",
98-
"performance.ts",
99-
"sys.ts",
100-
"types.ts",
101-
"scanner.ts",
102-
"parser.ts",
103-
"utilities.ts",
104-
"binder.ts",
105-
"checker.ts",
106-
"factory.ts",
107-
"visitor.ts",
108-
"transformers/destructuring.ts",
109-
"transformers/ts.ts",
110-
"transformers/jsx.ts",
111-
"transformers/esnext.ts",
112-
"transformers/es2017.ts",
113-
"transformers/es2016.ts",
114-
"transformers/es2015.ts",
115-
"transformers/generators.ts",
116-
"transformers/es5.ts",
117-
"transformers/module/es2015.ts",
118-
"transformers/module/system.ts",
119-
"transformers/module/module.ts",
120-
"transformer.ts",
121-
"sourcemap.ts",
122-
"comments.ts",
123-
"declarationEmitter.ts",
124-
"emitter.ts",
125-
"program.ts",
126-
"commandLineParser.ts",
127-
"diagnosticInformationMap.generated.ts"
128-
].map(function (f) {
129-
return path.join(compilerDirectory, f);
130-
}).concat([
131-
"types.ts",
132-
"utilities.ts",
133-
"breakpoints.ts",
134-
"classifier.ts",
135-
"completions.ts",
136-
"documentHighlights.ts",
137-
"documentRegistry.ts",
138-
"findAllReferences.ts",
139-
"goToDefinition.ts",
140-
"goToImplementation.ts",
141-
"jsDoc.ts",
142-
"jsTyping.ts",
143-
"navigateTo.ts",
144-
"navigationBar.ts",
145-
"outliningElementsCollector.ts",
146-
"patternMatcher.ts",
147-
"preProcess.ts",
148-
"rename.ts",
149-
"services.ts",
150-
"shims.ts",
151-
"signatureHelp.ts",
152-
"symbolDisplay.ts",
153-
"transpile.ts",
154-
// Formatting
155-
"formatting/formatting.ts",
156-
"formatting/formattingContext.ts",
157-
"formatting/formattingRequestKind.ts",
158-
"formatting/formattingScanner.ts",
159-
"formatting/references.ts",
160-
"formatting/rule.ts",
161-
"formatting/ruleAction.ts",
162-
"formatting/ruleDescriptor.ts",
163-
"formatting/ruleFlag.ts",
164-
"formatting/ruleOperation.ts",
165-
"formatting/ruleOperationContext.ts",
166-
"formatting/rules.ts",
167-
"formatting/rulesMap.ts",
168-
"formatting/rulesProvider.ts",
169-
"formatting/smartIndenter.ts",
170-
"formatting/tokenRange.ts",
171-
// CodeFixes
172-
"codeFixProvider.ts",
173-
"codefixes/fixes.ts",
174-
"codefixes/fixExtendsInterfaceBecomesImplements.ts",
175-
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
176-
"codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
177-
"codefixes/fixClassSuperMustPrecedeThisAccess.ts",
178-
"codefixes/fixConstructorForDerivedNeedSuperCall.ts",
179-
"codefixes/helpers.ts",
180-
"codefixes/importFixes.ts",
181-
"codefixes/unusedIdentifierFixes.ts"
182-
].map(function (f) {
183-
return path.join(servicesDirectory, f);
184-
}));
185-
186-
var baseServerCoreSources = [
187-
"builder.ts",
188-
"editorServices.ts",
189-
"lsHost.ts",
190-
"project.ts",
191-
"protocol.ts",
192-
"scriptInfo.ts",
193-
"scriptVersionCache.ts",
194-
"session.ts",
195-
"shared.ts",
196-
"types.ts",
197-
"typingsCache.ts",
198-
"utilities.ts",
199-
].map(function (f) {
200-
return path.join(serverDirectory, f);
201-
});
202-
203-
var serverCoreSources = [
204-
"server.ts"
205-
].map(function (f) {
206-
return path.join(serverDirectory, f);
207-
}).concat(baseServerCoreSources);
208-
209-
var cancellationTokenSources = [
210-
"cancellationToken.ts"
211-
].map(function (f) {
212-
return path.join(cancellationTokenDirectory, f);
213-
});
214-
215-
var typingsInstallerSources = [
216-
"../types.ts",
217-
"../shared.ts",
218-
"typingsInstaller.ts",
219-
"nodeTypingsInstaller.ts"
220-
].map(function (f) {
221-
return path.join(typingsInstallerDirectory, f);
222-
});
223-
224-
var serverSources = serverCoreSources.concat(servicesSources);
225-
var languageServiceLibrarySources = baseServerCoreSources.concat(servicesSources);
79+
var compilerSources = filesFromConfig("./src/compiler/tsconfig.json");
80+
var servicesSources = filesFromConfig("./src/services/tsconfig.json");
81+
var cancellationTokenSources = filesFromConfig(path.join(serverDirectory, "cancellationToken/tsconfig.json"));
82+
var typingsInstallerSources = filesFromConfig(path.join(serverDirectory, "typingsInstaller/tsconfig.json"));
83+
var serverSources = filesFromConfig(path.join(serverDirectory, "tsconfig.json"))
84+
var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "tsconfig.library.json"));
22685

22786
var harnessCoreSources = [
22887
"harness.ts",
@@ -1230,13 +1089,16 @@ var lintTargets = compilerSources
12301089
.concat(harnessSources)
12311090
// Other harness sources
12321091
.concat(["instrumenter.ts"].map(function (f) { return path.join(harnessDirectory, f) }))
1233-
.concat(serverCoreSources)
1092+
.concat(serverSources)
12341093
.concat(tslintRulesFiles)
12351094
.concat(servicesSources)
12361095
.concat(typingsInstallerSources)
12371096
.concat(cancellationTokenSources)
12381097
.concat(["Gulpfile.ts"])
1239-
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);
1098+
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath])
1099+
.map(function (p) { return path.resolve(p) });
1100+
// keep only unique items
1101+
lintTargets = Array.from(new Set(lintTargets));
12401102

12411103
function sendNextFile(files, child, callback, failures) {
12421104
var file = files.pop();

src/compiler/checker.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ namespace ts {
326326
"object": TypeFacts.TypeofEQObject,
327327
"function": TypeFacts.TypeofEQFunction
328328
});
329-
330329
const typeofNEFacts = createMapFromTemplate({
331330
"string": TypeFacts.TypeofNEString,
332331
"number": TypeFacts.TypeofNENumber,
@@ -336,14 +335,14 @@ namespace ts {
336335
"object": TypeFacts.TypeofNEObject,
337336
"function": TypeFacts.TypeofNEFunction
338337
});
339-
340338
const typeofTypesByName = createMapFromTemplate<Type>({
341339
"string": stringType,
342340
"number": numberType,
343341
"boolean": booleanType,
344342
"symbol": esSymbolType,
345343
"undefined": undefinedType
346344
});
345+
const typeofType = createTypeofType();
347346

348347
let jsxElementType: Type;
349348
let _jsxNamespace: string;
@@ -1727,6 +1726,10 @@ namespace ts {
17271726
return type;
17281727
}
17291728

1729+
function createTypeofType() {
1730+
return getUnionType(convertToArray(typeofEQFacts.keys(), s => getLiteralTypeForText(TypeFlags.StringLiteral, s)));
1731+
}
1732+
17301733
// A reserved member name starts with two underscores, but the third character cannot be an underscore
17311734
// or the @ symbol. A third underscore indicates an escaped form of an identifer that started
17321735
// with at least two underscores. The @ character indicates that the name is denoted by a well known ES
@@ -14626,7 +14629,7 @@ namespace ts {
1462614629

1462714630
function checkTypeOfExpression(node: TypeOfExpression): Type {
1462814631
checkExpression(node.expression);
14629-
return stringType;
14632+
return typeofType;
1463014633
}
1463114634

1463214635
function checkVoidExpression(node: VoidExpression): Type {

src/compiler/core.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,14 @@ namespace ts {
895895
return result;
896896
}
897897

898+
export function convertToArray<T, U>(iterator: Iterator<T>, f: (value: T) => U) {
899+
const result: U[] = [];
900+
for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) {
901+
result.push(f(value));
902+
}
903+
return result;
904+
}
905+
898906
/**
899907
* Calls `callback` for each entry in the map, returning the first truthy result.
900908
* Use `map.forEach` instead for normal iteration.

src/compiler/sys.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,10 @@ namespace ts {
485485
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
486486
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
487487
let options: any;
488-
if (!directoryExists(directoryName)) {
488+
if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) {
489+
// do nothing if either
490+
// - target folder does not exist
491+
// - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874)
489492
return noOpFileWatcher;
490493
}
491494

@@ -509,6 +512,10 @@ namespace ts {
509512
};
510513
}
511514
);
515+
516+
function isUNCPath(s: string): boolean {
517+
return s.length > 2 && s.charCodeAt(0) === CharacterCodes.slash && s.charCodeAt(1) === CharacterCodes.slash;
518+
}
512519
},
513520
resolvePath: function(path: string): string {
514521
return _path.resolve(path);

0 commit comments

Comments
 (0)