Skip to content

Commit e5a8deb

Browse files
author
steveluc
committed
merge
2 parents f9fd365 + d6045e4 commit e5a8deb

File tree

824 files changed

+15788
-10069
lines changed

Some content is hidden

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

824 files changed

+15788
-10069
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
root = true
3+
4+
[{src,scripts}/**.{ts,json,js}]
5+
end_of_line = crlf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
indent_style = space
10+
indent_size = 4

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript)
22
[![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/pr)](http://issuestats.com/github/microsoft/typescript)
33
[![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/issue)](http://issuestats.com/github/microsoft/typescript)
4+
[![npm version](https://badge.fury.io/js/typescript.svg)](http://badge.fury.io/js/typescript)
5+
[![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript)
46

57
# TypeScript
68

scripts/VSDevMode.ps1

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,38 @@ if(!(Test-Path $tsRegKey)){
3737
}
3838

3939
if($tsScript -ne ""){
40-
if(!(Test-Path $tsScript)){
41-
Throw "Could not locate the TypeScript language service script at ${tsScript}"
40+
$tsScriptServices = "${tsScript}\typescriptServices.js"
41+
$tsScriptlib = "${tsScript}\lib.d.ts"
42+
$tsES6Scriptlib = "${tsScript}\lib.es6.d.ts"
43+
44+
if(!(Test-Path $tsScriptServices)){
45+
Throw "Could not locate the TypeScript language service script at ${tsScriptServices}"
46+
}
47+
else {
48+
$path = resolve-path ${tsScriptServices}
49+
Set-ItemProperty -path $tsRegKey -name CustomTypeScriptServicesFileLocation -value "${path}"
50+
Write-Host "Enabled custom TypeScript language service at ${path} for Dev${vsVersion}"
51+
}
52+
53+
if(!(Test-Path $tsScriptlib)){
54+
Throw "Could not locate the TypeScript default library at ${tsScriptlib}"
55+
}
56+
else {
57+
$path = resolve-path ${tsScriptlib}
58+
Set-ItemProperty -path $tsRegKey -name CustomDefaultLibraryLocation -value "${path}"
59+
Write-Host "Enabled custom TypeScript default library at ${path} for Dev${vsVersion}"
60+
}
61+
62+
if(!(Test-Path $tsES6Scriptlib)){
63+
Throw "Could not locate the TypeScript default ES6 library at ${tsES6Scriptlib}"
64+
}
65+
else {
66+
$path = resolve-path ${tsES6Scriptlib}
67+
Set-ItemProperty -path $tsRegKey -name CustomDefaultES6LibraryLocation -value "${path}"
68+
Write-Host "Enabled custom TypeScript default ES6 library at ${path} for Dev${vsVersion}"
4269
}
43-
Set-ItemProperty -path $tsRegKey -name CustomTypeScriptServicesFileLocation -value "${tsScript}"
44-
Write-Host "Enabled custom TypeScript language service at ${tsScript} for Dev${vsVersion}"
4570
}
71+
4672
if($enableDevMode){
4773
Set-ItemProperty -path $tsRegKey -name EnableDevMode -value 1
4874
Write-Host "Enabled developer mode for Dev${vsVersion}"

src/compiler/binder.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ module ts {
6767

6868
if (!file.locals) {
6969
file.locals = {};
70-
container = blockScopeContainer = file;
70+
container = file;
71+
setBlockScopeContainer(file, /*cleanLocals*/ false);
7172
bind(file);
7273
file.symbolCount = symbolCount;
7374
}
@@ -77,6 +78,13 @@ module ts {
7778
return new Symbol(flags, name);
7879
}
7980

81+
function setBlockScopeContainer(node: Node, cleanLocals: boolean) {
82+
blockScopeContainer = node;
83+
if (cleanLocals) {
84+
blockScopeContainer.locals = undefined;
85+
}
86+
}
87+
8088
function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolKind: SymbolFlags) {
8189
symbol.flags |= symbolKind;
8290
if (!symbol.declarations) symbol.declarations = [];
@@ -236,7 +244,13 @@ module ts {
236244
}
237245

238246
if (isBlockScopeContainer) {
239-
blockScopeContainer = node;
247+
// in incremental scenarios we might reuse nodes that already have locals being allocated
248+
// during the bind step these locals should be dropped to prevent using stale data.
249+
// locals should always be dropped unless they were previously initialized by the binder
250+
// these cases are:
251+
// - node has locals (symbolKind & HasLocals) !== 0
252+
// - node is a source file
253+
setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile);
240254
}
241255

242256
forEachChild(node, bind);
@@ -342,14 +356,7 @@ module ts {
342356
}
343357

344358
function bindCatchVariableDeclaration(node: CatchClause) {
345-
var symbol = createSymbol(SymbolFlags.FunctionScopedVariable, node.name.text || "__missing");
346-
addDeclarationToSymbol(symbol, node, SymbolFlags.FunctionScopedVariable);
347-
var saveParent = parent;
348-
var savedBlockScopeContainer = blockScopeContainer;
349-
parent = blockScopeContainer = node;
350-
forEachChild(node, bind);
351-
parent = saveParent;
352-
blockScopeContainer = savedBlockScopeContainer;
359+
bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true);
353360
}
354361

355362
function bindBlockScopedVariableDeclaration(node: Declaration) {
@@ -377,6 +384,7 @@ module ts {
377384

378385
function bind(node: Node) {
379386
node.parent = parent;
387+
380388
switch (node.kind) {
381389
case SyntaxKind.TypeParameter:
382390
bindDeclaration(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false);
@@ -389,7 +397,7 @@ module ts {
389397
if (isBindingPattern((<Declaration>node).name)) {
390398
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
391399
}
392-
else if (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) {
400+
else if (isBlockOrCatchScoped(<Declaration>node)) {
393401
bindBlockScopedVariableDeclaration(<Declaration>node);
394402
}
395403
else {

0 commit comments

Comments
 (0)