Skip to content

Commit be1371d

Browse files
committed
Merge master
2 parents 5fc3099 + 8cdd59f commit be1371d

795 files changed

Lines changed: 22129 additions & 2788 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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,3 +715,9 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function
715715
});
716716
ex.run();
717717
}, { async: true });
718+
719+
desc("Updates the sublime plugin's tsserver");
720+
task("update-sublime", [serverFile], function() {
721+
jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/");
722+
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
723+
});

scripts/errorCheck.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
declare var require: any;
2+
let fs = require('fs');
3+
let async = require('async');
4+
let glob = require('glob');
5+
6+
fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => {
7+
if (err) {
8+
throw err;
9+
}
10+
11+
let messages = JSON.parse(data);
12+
let keys = Object.keys(messages);
13+
console.log('Loaded ' + keys.length + ' errors');
14+
15+
for (let k of keys) {
16+
messages[k]['seen'] = false;
17+
}
18+
19+
let errRegex = /\(\d+,\d+\): error TS([^:]+):/g;
20+
21+
let baseDir = 'tests/baselines/reference/';
22+
fs.readdir(baseDir, (err, files) => {
23+
files = files.filter(f => f.indexOf('.errors.txt') > 0);
24+
let tasks: Array<(callback: () => void) => void> = [];
25+
files.forEach(f => tasks.push(done => {
26+
fs.readFile(baseDir + f, 'utf-8', (err, baseline) => {
27+
if (err) throw err;
28+
29+
let g: string[];
30+
while (g = errRegex.exec(baseline)) {
31+
var errCode = +g[1];
32+
let msg = keys.filter(k => messages[k].code === errCode)[0];
33+
messages[msg]['seen'] = true;
34+
}
35+
36+
done();
37+
});
38+
}));
39+
40+
async.parallelLimit(tasks, 25, done => {
41+
console.log('== List of errors not present in baselines ==');
42+
let count = 0;
43+
for (let k of keys) {
44+
if (messages[k]['seen'] !== true) {
45+
console.log(k);
46+
count++;
47+
}
48+
}
49+
console.log(count + ' of ' + keys.length + ' errors are not in baselines');
50+
});
51+
});
52+
});
53+
54+
fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => {
55+
let errorRegexp = /\s(\w+): \{ code/g;
56+
let errorNames: string[] = [];
57+
let errMatch: string[];
58+
while (errMatch = errorRegexp.exec(data)) {
59+
errorNames.push(errMatch[1]);
60+
}
61+
62+
let allSrc: string = '';
63+
glob('./src/**/*.ts', {}, (err, files) => {
64+
console.log('Reading ' + files.length + ' source files');
65+
for (let file of files) {
66+
if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) {
67+
continue;
68+
}
69+
70+
let src = fs.readFileSync(file, 'utf-8');
71+
allSrc = allSrc + src;
72+
}
73+
74+
console.log('Consumed ' + allSrc.length + ' characters of source');
75+
76+
let count = 0;
77+
console.log('== List of errors not used in source ==')
78+
for (let errName of errorNames) {
79+
if (allSrc.indexOf(errName) < 0) {
80+
console.log(errName);
81+
count++;
82+
}
83+
}
84+
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
85+
});
86+
});
87+

src/compiler/binder.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ namespace ts {
173173
return node.name ? declarationNameToString(node.name) : getDeclarationName(node);
174174
}
175175

176+
/**
177+
* Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names.
178+
* @param symbolTable - The symbol table which node will be added to.
179+
* @param parent - node's parent declaration.
180+
* @param node - The declaration to be added to the symbol table
181+
* @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.)
182+
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
183+
*/
176184
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
177185
Debug.assert(!hasDynamicName(node));
178186

@@ -181,10 +189,11 @@ namespace ts {
181189

182190
let symbol: Symbol;
183191
if (name !== undefined) {
192+
184193
// Check and see if the symbol table already has a symbol with this name. If not,
185194
// create a new symbol with this name and add it to the table. Note that we don't
186195
// give the new symbol any flags *yet*. This ensures that it will not conflict
187-
// witht he 'excludes' flags we pass in.
196+
// with the 'excludes' flags we pass in.
188197
//
189198
// If we do get an existing symbol, see if it conflicts with the new symbol we're
190199
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within
@@ -314,6 +323,7 @@ namespace ts {
314323

315324
addToContainerChain(container);
316325
}
326+
317327
else if (containerFlags & ContainerFlags.IsBlockScopedContainer) {
318328
blockScopeContainer = node;
319329
blockScopeContainer.locals = undefined;
@@ -882,7 +892,8 @@ namespace ts {
882892
case SyntaxKind.FunctionExpression:
883893
case SyntaxKind.ArrowFunction:
884894
checkStrictModeFunctionName(<FunctionExpression>node);
885-
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function");
895+
let bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
896+
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
886897
case SyntaxKind.ClassExpression:
887898
case SyntaxKind.ClassDeclaration:
888899
return bindClassLikeDeclaration(<ClassLikeDeclaration>node);
@@ -954,7 +965,8 @@ namespace ts {
954965
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
955966
}
956967
else {
957-
bindAnonymousDeclaration(node, SymbolFlags.Class, "__class");
968+
let bindingName = node.name ? node.name.text : "__class";
969+
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
958970
}
959971

960972
let symbol = node.symbol;
@@ -1044,4 +1056,4 @@ namespace ts {
10441056
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
10451057
}
10461058
}
1047-
}
1059+
}

0 commit comments

Comments
 (0)