Skip to content

Commit 1b66ee6

Browse files
author
Yui T
committed
Merge branch 'master' into shorthandProperty
Conflicts: src/compiler/checker.ts
2 parents b3078f2 + d5cfceb commit 1b66ee6

File tree

291 files changed

+18457
-4178
lines changed

Some content is hidden

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

291 files changed

+18457
-4178
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ build.json
3232
tests/webhost/*.d.ts
3333
tests/webhost/webtsc.js
3434
tests/*.js
35+
tests/*.js.map
3536
tests/*.d.ts
3637
*.config
3738
scripts/debug.bat

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
language: node_js
22

33
node_js:
4-
- '0.10'
4+
- '0.10'
5+
6+
sudo: false
57

68
before_script: npm install -g codeclimate-test-reporter
79

810
after_script:
9-
- cat coverage/lcov.info | codeclimate
11+
- cat coverage/lcov.info | codeclimate
1012

1113
addons:
1214
code_climate:

Jakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ var harnessSources = [
8282
].map(function (f) {
8383
return path.join(harnessDirectory, f);
8484
}).concat([
85-
"services/colorization.ts",
86-
"services/documentRegistry.ts"
85+
"services/colorization.ts",
86+
"services/documentRegistry.ts",
87+
"services/preProcessFile.ts"
8788
].map(function (f) {
8889
return path.join(unittestsDirectory, f);
8990
}));

src/compiler/binder.ts

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,16 @@ module ts {
9393
return (<Identifier>node.name).text;
9494
}
9595
switch (node.kind) {
96-
case SyntaxKind.Constructor: return "__constructor";
97-
case SyntaxKind.CallSignature: return "__call";
98-
case SyntaxKind.ConstructSignature: return "__new";
99-
case SyntaxKind.IndexSignature: return "__index";
96+
case SyntaxKind.ConstructorType:
97+
case SyntaxKind.Constructor:
98+
return "__constructor";
99+
case SyntaxKind.FunctionType:
100+
case SyntaxKind.CallSignature:
101+
return "__call";
102+
case SyntaxKind.ConstructSignature:
103+
return "__new";
104+
case SyntaxKind.IndexSignature:
105+
return "__index";
100106
}
101107
}
102108

@@ -114,8 +120,11 @@ module ts {
114120
}
115121
// Report errors every position with duplicate declaration
116122
// Report errors on previous encountered declarations
117-
var message = symbol.flags & SymbolFlags.BlockScopedVariable ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
118-
forEach(symbol.declarations, (declaration) => {
123+
var message = symbol.flags & SymbolFlags.BlockScopedVariable
124+
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
125+
: Diagnostics.Duplicate_identifier_0;
126+
127+
forEach(symbol.declarations, declaration => {
119128
file.semanticErrors.push(createDiagnosticForNode(declaration.name, message, getDisplayName(declaration)));
120129
});
121130
file.semanticErrors.push(createDiagnosticForNode(node.name, message, getDisplayName(node)));
@@ -233,6 +242,8 @@ module ts {
233242
declareModuleMember(node, symbolKind, symbolExcludes);
234243
break;
235244
}
245+
case SyntaxKind.FunctionType:
246+
case SyntaxKind.ConstructorType:
236247
case SyntaxKind.CallSignature:
237248
case SyntaxKind.ConstructSignature:
238249
case SyntaxKind.IndexSignature:
@@ -294,6 +305,25 @@ module ts {
294305
}
295306
}
296307

308+
function bindFunctionOrConstructorType(node: SignatureDeclaration) {
309+
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
310+
// to the one we would get for: { <...>(...): T }
311+
//
312+
// We do that by making an anonymous type literal symbol, and then setting the function
313+
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
314+
// from an actual type literal symbol you would have gotten had you used the long form.
315+
316+
var symbolKind = node.kind === SyntaxKind.FunctionType ? SymbolFlags.CallSignature : SymbolFlags.ConstructSignature;
317+
var symbol = createSymbol(symbolKind, getDeclarationName(node));
318+
addDeclarationToSymbol(symbol, node, symbolKind);
319+
bindChildren(node, symbolKind, /*isBlockScopeContainer:*/ false);
320+
321+
var typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
322+
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
323+
typeLiteralSymbol.members = {};
324+
typeLiteralSymbol.members[node.kind === SyntaxKind.FunctionType ? "__call" : "__new"] = symbol
325+
}
326+
297327
function bindAnonymousDeclaration(node: Node, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) {
298328
var symbol = createSymbol(symbolKind, name);
299329
addDeclarationToSymbol(symbol, node, symbolKind);
@@ -359,12 +389,12 @@ module ts {
359389
case SyntaxKind.CallSignature:
360390
bindDeclaration(<Declaration>node, SymbolFlags.CallSignature, 0, /*isBlockScopeContainer*/ false);
361391
break;
362-
case SyntaxKind.Method:
363-
bindDeclaration(<Declaration>node, SymbolFlags.Method, SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
364-
break;
365392
case SyntaxKind.ConstructSignature:
366393
bindDeclaration(<Declaration>node, SymbolFlags.ConstructSignature, 0, /*isBlockScopeContainer*/ true);
367394
break;
395+
case SyntaxKind.Method:
396+
bindDeclaration(<Declaration>node, SymbolFlags.Method, SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
397+
break;
368398
case SyntaxKind.IndexSignature:
369399
bindDeclaration(<Declaration>node, SymbolFlags.IndexSignature, 0, /*isBlockScopeContainer*/ false);
370400
break;
@@ -380,6 +410,12 @@ module ts {
380410
case SyntaxKind.SetAccessor:
381411
bindDeclaration(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
382412
break;
413+
414+
case SyntaxKind.FunctionType:
415+
case SyntaxKind.ConstructorType:
416+
bindFunctionOrConstructorType(<SignatureDeclaration>node);
417+
break;
418+
383419
case SyntaxKind.TypeLiteral:
384420
bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type", /*isBlockScopeContainer*/ false);
385421
break;

0 commit comments

Comments
 (0)