Skip to content

Commit f9fe01a

Browse files
committed
Merge branch 'master' into object-spread
2 parents b6819dc + db0ee4f commit f9fe01a

File tree

361 files changed

+10156
-1322
lines changed

Some content is hidden

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

361 files changed

+10156
-1322
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ tests/cases/**/*.js.map
4141
scripts/debug.bat
4242
scripts/run.bat
4343
scripts/word2md.js
44+
scripts/buildProtocol.js
4445
scripts/ior.js
4546
scripts/buildProtocol.js
4647
scripts/*.js.map

CONTRIBUTING.md

-2
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,3 @@ jake baseline-accept
183183
```
184184

185185
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
186-
187-
**Note** that `baseline-accept` should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.

Jakefile.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ var compilerSources = [
7070
"visitor.ts",
7171
"transformers/destructuring.ts",
7272
"transformers/ts.ts",
73-
"transformers/module/es6.ts",
73+
"transformers/module/es2015.ts",
7474
"transformers/module/system.ts",
7575
"transformers/module/module.ts",
7676
"transformers/jsx.ts",
7777
"transformers/experimental.ts",
78-
"transformers/es7.ts",
78+
"transformers/es2017.ts",
79+
"transformers/es2016.ts",
80+
"transformers/es2015.ts",
7981
"transformers/generators.ts",
80-
"transformers/es6.ts",
82+
"transformers/es5.ts",
8183
"transformer.ts",
8284
"sourcemap.ts",
8385
"comments.ts",
@@ -105,14 +107,16 @@ var servicesSources = [
105107
"visitor.ts",
106108
"transformers/destructuring.ts",
107109
"transformers/ts.ts",
108-
"transformers/module/es6.ts",
110+
"transformers/module/es2015.ts",
109111
"transformers/module/system.ts",
110112
"transformers/module/module.ts",
111113
"transformers/jsx.ts",
112114
"transformers/experimental.ts",
113-
"transformers/es7.ts",
115+
"transformers/es2017.ts",
116+
"transformers/es2016.ts",
117+
"transformers/es2015.ts",
114118
"transformers/generators.ts",
115-
"transformers/es6.ts",
119+
"transformers/es5.ts",
116120
"transformer.ts",
117121
"sourcemap.ts",
118122
"comments.ts",
@@ -355,6 +359,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
355359
if (!fs.existsSync(sourceFiles[i])) {
356360
fail(sourceFiles[i] + " does not exist!");
357361
}
362+
fs.appendFileSync(temp, "\n\n");
358363
fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i]));
359364
}
360365
// Move the file to the final destination
@@ -445,6 +450,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
445450
options += " --stripInternal";
446451
}
447452

453+
options += " --target es5";
454+
448455
var cmd = host + " " + compilerPath + " " + options + " ";
449456
cmd = cmd + sources.join(" ");
450457
console.log(cmd + "\n");

issue_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->
33
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
44

5-
**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx)
5+
**TypeScript Version:** 2.0.3 / nightly (2.1.0-dev.201xxxxx)
66

77
**Code**
88

scripts/buildProtocol.ts

+53-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,27 @@ function endsWith(s: string, suffix: string) {
1010
class DeclarationsWalker {
1111
private visitedTypes: ts.Type[] = [];
1212
private text = "";
13+
private removedTypes: ts.Type[] = [];
14+
1315
private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) {
1416
}
1517

1618
static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string {
1719
let text = "declare namespace ts.server.protocol {\n";
1820
var walker = new DeclarationsWalker(typeChecker, protocolFile);
1921
walker.visitTypeNodes(protocolFile);
20-
return walker.text
22+
text = walker.text
2123
? `declare namespace ts.server.protocol {\n${walker.text}}`
2224
: "";
25+
if (walker.removedTypes) {
26+
text += "\ndeclare namespace ts {\n";
27+
text += " // these types are empty stubs for types from services and should not be used directly\n"
28+
for (const type of walker.removedTypes) {
29+
text += ` export type ${type.symbol.name} = never;\n`;
30+
}
31+
text += "}"
32+
}
33+
return text;
2334
}
2435

2536
private processType(type: ts.Type): void {
@@ -41,12 +52,18 @@ class DeclarationsWalker {
4152
if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") {
4253
return;
4354
}
44-
// splice declaration in final d.ts file
45-
const text = decl.getFullText();
46-
this.text += `${text}\n`;
55+
if (decl.kind === ts.SyntaxKind.EnumDeclaration) {
56+
this.removedTypes.push(type);
57+
return;
58+
}
59+
else {
60+
// splice declaration in final d.ts file
61+
let text = decl.getFullText();
62+
this.text += `${text}\n`;
63+
// recursively pull all dependencies into result dts file
4764

48-
// recursively pull all dependencies into result dts file
49-
this.visitTypeNodes(decl);
65+
this.visitTypeNodes(decl);
66+
}
5067
}
5168
}
5269
}
@@ -62,15 +79,37 @@ class DeclarationsWalker {
6279
case ts.SyntaxKind.Parameter:
6380
case ts.SyntaxKind.IndexSignature:
6481
if (((<ts.VariableDeclaration | ts.MethodDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.PropertySignature | ts.MethodSignature | ts.IndexSignatureDeclaration>node.parent).type) === node) {
65-
const type = this.typeChecker.getTypeAtLocation(node);
66-
if (type && !(type.flags & ts.TypeFlags.TypeParameter)) {
67-
this.processType(type);
68-
}
82+
this.processTypeOfNode(node);
6983
}
7084
break;
85+
case ts.SyntaxKind.InterfaceDeclaration:
86+
const heritageClauses = (<ts.InterfaceDeclaration>node.parent).heritageClauses;
87+
if (heritageClauses) {
88+
if (heritageClauses[0].token !== ts.SyntaxKind.ExtendsKeyword) {
89+
throw new Error(`Unexpected kind of heritage clause: ${ts.SyntaxKind[heritageClauses[0].kind]}`);
90+
}
91+
for (const type of heritageClauses[0].types) {
92+
this.processTypeOfNode(type);
93+
}
94+
}
95+
break;
7196
}
7297
}
7398
ts.forEachChild(node, n => this.visitTypeNodes(n));
99+
}
100+
101+
private processTypeOfNode(node: ts.Node): void {
102+
if (node.kind === ts.SyntaxKind.UnionType) {
103+
for (const t of (<ts.UnionTypeNode>node).types) {
104+
this.processTypeOfNode(t);
105+
}
106+
}
107+
else {
108+
const type = this.typeChecker.getTypeAtLocation(node);
109+
if (type && !(type.flags & (ts.TypeFlags.TypeParameter))) {
110+
this.processType(type);
111+
}
112+
}
74113
}
75114
}
76115

@@ -121,9 +160,12 @@ function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string)
121160
if (extraDeclarations) {
122161
protocolDts += extraDeclarations;
123162
}
163+
protocolDts += "\nimport protocol = ts.server.protocol;";
164+
protocolDts += "\nexport = protocol;";
165+
protocolDts += "\nexport as namespace protocol;";
124166
// do sanity check and try to compile generated text as standalone program
125167
const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false);
126-
const diagnostics = [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics(), ...program.getGlobalDiagnostics()];
168+
const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()];
127169
if (diagnostics.length) {
128170
const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n");
129171
throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);

0 commit comments

Comments
 (0)