Skip to content

Commit f16f9d1

Browse files
author
Yui T
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into completionListWithLocalName
2 parents d0d1ee9 + f72b001 commit f16f9d1

File tree

107 files changed

+2310
-1513
lines changed

Some content is hidden

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

107 files changed

+2310
-1513
lines changed

Jakefile.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
361361
/*keepComments*/ true,
362362
/*noResolve*/ false,
363363
/*stripInternal*/ true,
364-
/*callback*/ function () {
364+
/*callback*/ function () {
365365
jake.cpR(servicesFile, nodePackageFile, {silent: true});
366366

367367
prependFile(copyright, standaloneDefinitionsFile);
@@ -379,12 +379,12 @@ compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(se
379379

380380
var lsslFile = path.join(builtLocalDirectory, "tslssl.js");
381381
compileFile(
382-
lsslFile,
383-
languageServiceLibrarySources,
382+
lsslFile,
383+
languageServiceLibrarySources,
384384
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
385-
/*prefixes*/ [copyright],
386-
/*useBuiltCompiler*/ true,
387-
/*noOutFile*/ false,
385+
/*prefixes*/ [copyright],
386+
/*useBuiltCompiler*/ true,
387+
/*noOutFile*/ false,
388388
/*generateDeclarations*/ true);
389389

390390
// Local target to build the language service server library
@@ -488,7 +488,7 @@ var refTest262Baseline = path.join(internalTests, "baselines/test262/reference")
488488
desc("Builds the test infrastructure using the built compiler");
489489
task("tests", ["local", run].concat(libraryTargets));
490490

491-
function exec(cmd, completeHandler) {
491+
function exec(cmd, completeHandler, errorHandler) {
492492
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true});
493493
// Add listeners for output and error
494494
ex.addListener("stdout", function(output) {
@@ -504,8 +504,12 @@ function exec(cmd, completeHandler) {
504504
complete();
505505
});
506506
ex.addListener("error", function(e, status) {
507-
fail("Process exited with code " + status);
508-
})
507+
if(errorHandler) {
508+
errorHandler(e, status);
509+
} else {
510+
fail("Process exited with code " + status);
511+
}
512+
});
509513

510514
ex.run();
511515
}
@@ -721,3 +725,17 @@ task("update-sublime", [serverFile], function() {
721725
jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/");
722726
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
723727
});
728+
729+
// if the codebase were free of linter errors we could make jake runtests
730+
// run this task automatically
731+
desc("Runs tslint on the compiler sources");
732+
task("lint", [], function() {
733+
for(var i in compilerSources) {
734+
var f = compilerSources[i];
735+
var cmd = 'tslint -f ' + f;
736+
exec(cmd,
737+
function() { console.log('SUCCESS: No linter errors'); },
738+
function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n');
739+
});
740+
}
741+
}, { async: true });

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"mocha": "latest",
3434
"chai": "latest",
3535
"browserify": "latest",
36-
"istanbul": "latest"
36+
"istanbul": "latest",
37+
"tslint": "latest"
3738
},
3839
"scripts": {
3940
"test": "jake runtests"

scripts/errorCheck.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err,
7474
console.log('Consumed ' + allSrc.length + ' characters of source');
7575

7676
let count = 0;
77-
console.log('== List of errors not used in source ==')
77+
console.log('== List of errors not used in source ==');
7878
for (let errName of errorNames) {
7979
if (allSrc.indexOf(errName) < 0) {
8080
console.log(errName);
@@ -84,4 +84,3 @@ fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err,
8484
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
8585
});
8686
});
87-

src/compiler/binder.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ts {
1111
}
1212

1313
export function getModuleInstanceState(node: Node): ModuleInstanceState {
14-
// A module is uninstantiated if it contains only
14+
// A module is uninstantiated if it contains only
1515
// 1. interface declarations, type alias declarations
1616
if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) {
1717
return ModuleInstanceState.NonInstantiated;
@@ -53,7 +53,7 @@ namespace ts {
5353
}
5454

5555
const enum ContainerFlags {
56-
// The current node is not a container, and no container manipulation should happen before
56+
// The current node is not a container, and no container manipulation should happen before
5757
// recursing into it.
5858
None = 0,
5959

@@ -90,13 +90,13 @@ namespace ts {
9090
let lastContainer: Node;
9191

9292
// If this file is an external module, then it is automatically in strict-mode according to
93-
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
93+
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
9494
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
9595
let inStrictMode = !!file.externalModuleIndicator;
9696

9797
let symbolCount = 0;
9898
let Symbol = objectAllocator.getSymbolConstructor();
99-
let classifiableNames: Map<string> = {};
99+
let classifiableNames: Map<string> = {};
100100

101101
if (!file.locals) {
102102
bind(file);
@@ -179,7 +179,7 @@ namespace ts {
179179
* @param parent - node's parent declaration.
180180
* @param node - The declaration to be added to the symbol table
181181
* @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.
182+
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
183183
*/
184184
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
185185
Debug.assert(!hasDynamicName(node));
@@ -192,13 +192,13 @@ namespace ts {
192192

193193
// Check and see if the symbol table already has a symbol with this name. If not,
194194
// create a new symbol with this name and add it to the table. Note that we don't
195-
// give the new symbol any flags *yet*. This ensures that it will not conflict
195+
// give the new symbol any flags *yet*. This ensures that it will not conflict
196196
// with the 'excludes' flags we pass in.
197197
//
198198
// If we do get an existing symbol, see if it conflicts with the new symbol we're
199199
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within
200-
// the same symbol table. If we have a conflict, report the issue on each
201-
// declaration we have for this symbol, and then create a new symbol for this
200+
// the same symbol table. If we have a conflict, report the issue on each
201+
// declaration we have for this symbol, and then create a new symbol for this
202202
// declaration.
203203
//
204204
// If we created a new symbol, either because we didn't have a symbol with this name
@@ -259,7 +259,7 @@ namespace ts {
259259
// ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set
260260
// on it. There are 2 main reasons:
261261
//
262-
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
262+
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
263263
// That means the binder will issue a Duplicate Identifier error if you mix locals and exports
264264
// with the same name in the same container.
265265
// TODO: Make this a more specific error and decouple it from the exclusion logic.
@@ -282,11 +282,11 @@ namespace ts {
282282
}
283283
}
284284

285-
// All container nodes are kept on a linked list in declaration order. This list is used by
286-
// the getLocalNameOfContainer function in the type checker to validate that the local name
285+
// All container nodes are kept on a linked list in declaration order. This list is used by
286+
// the getLocalNameOfContainer function in the type checker to validate that the local name
287287
// used for a container is unique.
288288
function bindChildren(node: Node) {
289-
// Before we recurse into a node's chilren, we first save the existing parent, container
289+
// Before we recurse into a node's chilren, we first save the existing parent, container
290290
// and block-container. Then after we pop out of processing the children, we restore
291291
// these saved values.
292292
let saveParent = parent;
@@ -295,16 +295,16 @@ namespace ts {
295295

296296
// This node will now be set as the parent of all of its children as we recurse into them.
297297
parent = node;
298-
298+
299299
// Depending on what kind of node this is, we may have to adjust the current container
300300
// and block-container. If the current node is a container, then it is automatically
301301
// considered the current block-container as well. Also, for containers that we know
302302
// may contain locals, we proactively initialize the .locals field. We do this because
303303
// it's highly likely that the .locals will be needed to place some child in (for example,
304304
// a parameter, or variable declaration).
305-
//
305+
//
306306
// However, we do not proactively create the .locals for block-containers because it's
307-
// totally normal and common for block-containers to never actually have a block-scoped
307+
// totally normal and common for block-containers to never actually have a block-scoped
308308
// variable in them. We don't want to end up allocating an object for every 'block' we
309309
// run into when most of them won't be necessary.
310310
//
@@ -345,7 +345,7 @@ namespace ts {
345345
case SyntaxKind.TypeLiteral:
346346
case SyntaxKind.ObjectLiteralExpression:
347347
return ContainerFlags.IsContainer;
348-
348+
349349
case SyntaxKind.CallSignature:
350350
case SyntaxKind.ConstructSignature:
351351
case SyntaxKind.IndexSignature:
@@ -373,7 +373,7 @@ namespace ts {
373373

374374
case SyntaxKind.Block:
375375
// do not treat blocks directly inside a function as a block-scoped-container.
376-
// Locals that reside in this block should go to the function locals. Othewise 'x'
376+
// Locals that reside in this block should go to the function locals. Othewise 'x'
377377
// would not appear to be a redeclaration of a block scoped local in the following
378378
// example:
379379
//
@@ -386,7 +386,7 @@ namespace ts {
386386
// the block, then there would be no collision.
387387
//
388388
// By not creating a new block-scoped-container here, we ensure that both 'var x'
389-
// and 'let x' go into the Function-container's locals, and we do get a collision
389+
// and 'let x' go into the Function-container's locals, and we do get a collision
390390
// conflict.
391391
return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer;
392392
}
@@ -484,7 +484,7 @@ namespace ts {
484484
}
485485

486486
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
487-
var body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
487+
let body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
488488
if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) {
489489
for (let stat of (<Block>body).statements) {
490490
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
@@ -536,8 +536,8 @@ namespace ts {
536536
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
537537
// to the one we would get for: { <...>(...): T }
538538
//
539-
// We do that by making an anonymous type literal symbol, and then setting the function
540-
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
539+
// We do that by making an anonymous type literal symbol, and then setting the function
540+
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
541541
// from an actual type literal symbol you would have gotten had you used the long form.
542542
let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
543543
addDeclarationToSymbol(symbol, node, SymbolFlags.Signature);
@@ -638,7 +638,7 @@ namespace ts {
638638
}
639639

640640
function getStrictModeIdentifierMessage(node: Node) {
641-
// Provide specialized messages to help the user understand why we think they're in
641+
// Provide specialized messages to help the user understand why we think they're in
642642
// strict mode.
643643
if (getContainingClass(node)) {
644644
return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
@@ -696,7 +696,7 @@ namespace ts {
696696
}
697697

698698
function getStrictModeEvalOrArgumentsMessage(node: Node) {
699-
// Provide specialized messages to help the user understand why we think they're in
699+
// Provide specialized messages to help the user understand why we think they're in
700700
// strict mode.
701701
if (getContainingClass(node)) {
702702
return Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
@@ -760,24 +760,24 @@ namespace ts {
760760
function bind(node: Node) {
761761
node.parent = parent;
762762

763-
var savedInStrictMode = inStrictMode;
763+
let savedInStrictMode = inStrictMode;
764764
if (!savedInStrictMode) {
765765
updateStrictMode(node);
766766
}
767767

768768
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
769-
// and then potentially add the symbol to an appropriate symbol table. Possible
769+
// and then potentially add the symbol to an appropriate symbol table. Possible
770770
// destination symbol tables are:
771-
//
771+
//
772772
// 1) The 'exports' table of the current container's symbol.
773773
// 2) The 'members' table of the current container's symbol.
774774
// 3) The 'locals' table of the current container.
775775
//
776-
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols
776+
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols
777777
// (like TypeLiterals for example) will not be put in any table.
778778
bindWorker(node);
779779

780-
// Then we recurse into the children of the node to bind them as well. For certain
780+
// Then we recurse into the children of the node to bind them as well. For certain
781781
// symbols we do specialized work when we recurse. For example, we'll keep track of
782782
// the current 'container' node when it changes. This helps us know which symbol table
783783
// a local should go into for example.
@@ -817,7 +817,7 @@ namespace ts {
817817
}
818818
}
819819
}
820-
820+
821821
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
822822
function isUseStrictPrologueDirective(node: ExpressionStatement): boolean {
823823
let nodeText = getTextOfNodeFromSourceText(file.text, node.expression);
@@ -972,9 +972,9 @@ namespace ts {
972972
let symbol = node.symbol;
973973

974974
// TypeScript 1.0 spec (April 2014): 8.4
975-
// Every class automatically contains a static property member named 'prototype', the
975+
// Every class automatically contains a static property member named 'prototype', the
976976
// type of which is an instantiation of the class type with type Any supplied as a type
977-
// argument for each type parameter. It is an error to explicitly declare a static
977+
// argument for each type parameter. It is an error to explicitly declare a static
978978
// property member with the name 'prototype'.
979979
//
980980
// Note: we check for this here because this class may be merging into a module. The
@@ -1000,7 +1000,7 @@ namespace ts {
10001000

10011001
function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) {
10021002
if (inStrictMode) {
1003-
checkStrictModeEvalOrArguments(node, node.name)
1003+
checkStrictModeEvalOrArguments(node, node.name);
10041004
}
10051005

10061006
if (!isBindingPattern(node.name)) {
@@ -1039,7 +1039,7 @@ namespace ts {
10391039
declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes);
10401040
}
10411041

1042-
// If this is a property-parameter, then also declare the property symbol into the
1042+
// If this is a property-parameter, then also declare the property symbol into the
10431043
// containing class.
10441044
if (node.flags & NodeFlags.AccessibilityModifier &&
10451045
node.parent.kind === SyntaxKind.Constructor &&
@@ -1056,4 +1056,4 @@ namespace ts {
10561056
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
10571057
}
10581058
}
1059-
}
1059+
}

0 commit comments

Comments
 (0)