8000 Merge branch 'master' into useTypeAnnotationInDeclarationsEmitter · siddharthverma/TypeScript@f44d0c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit f44d0c0

Browse files
committed
Merge branch 'master' into useTypeAnnotationInDeclarationsEmitter
2 parents 60f79da + d11660c commit f44d0c0

File tree

529 files changed

+42213
-40033
lines changed

Some content is hidden

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

529 files changed

+42213
-40033
lines changed

bin/lib.core.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ declare var Number: {
499499
POSITIVE_INFINITY: number;
500500
}
501501

502+
interface TemplateStringsArray extends Array<string> {
503+
raw: string[];
504+
}
505+
502506
interface Math {
503507
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
504508
E: number;

bin/lib.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ declare var Number: {
499499
POSITIVE_INFINITY: number;
500500
}
501501

502+
interface TemplateStringsArray extends Array<string> {
503+
raw: string[];
504+
}
505+
502506
interface Math {
503507
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
504508
E: number;

bin/tsc.js

Lines changed: 5338 additions & 4824 deletions
Large diffs are not rendered by default.

bin/typescriptServices.js

Lines changed: 17202 additions & 29112 deletions
Large diffs are not rendered by default.

src/compiler/binder.ts

Lines changed: 49 additions & 12 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,11 +120,14 @@ 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) => {
119-
file.semanticErrors.push(createDiagnosticForNode(declaration.name, message, getDisplayName(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 => {
128+
file.semanticDiagnostics.push(createDiagnosticForNode(declaration.name, message, getDisplayName(declaration)));
120129
});
121-
file.semanticErrors.push(createDiagnosticForNode(node.name, message, getDisplayName(node)));
130+
file.semanticDiagnostics.push(createDiagnosticForNode(node.name, message, getDisplayName(node)));
122131

123132
symbol = createSymbol(0, name);
124133
}
@@ -139,7 +148,7 @@ module ts {
139148
if (node.name) {
140149
node.name.parent = node;
141150
}
142-
file.semanticErrors.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
151+
file.semanticDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
143152
Diagnostics.Duplicate_identifier_0, prototypeSymbol.name));
144153
}
145154
symbol.exports[prototypeSymbol.name] = prototypeSymbol;
@@ -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);
@@ -350,6 +380,7 @@ module ts {
350380
break;
351381
case SyntaxKind.Property:
352382
case SyntaxKind.PropertyAssignment:
383+
case SyntaxKind.ShorthandPropertyAssignment:
353384
bindDeclaration(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
354385
break;
355386
case SyntaxKind.EnumMember:
@@ -358,12 +389,12 @@ module ts {
358389
case SyntaxKind.CallSignature:
359390
bindDeclaration(<Declaration>node, SymbolFlags.CallSignature, 0, /*isBlockScopeContainer*/ false);
360391
break;
361-
case SyntaxKind.Method:
362-
bindDeclaration(<Declaration>node, SymbolFlags.Method, SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
363-
break;
364392
case SyntaxKind.ConstructSignature:
365393
bindDeclaration(<Declaration>node, SymbolFlags.ConstructSignature, 0, /*isBlockScopeContainer*/ true);
366394
break;
395+
case SyntaxKind.Method:
396+
bindDeclaration(<Declaration>node, SymbolFlags.Method, SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
397+
break;
367398
case SyntaxKind.IndexSignature:
368399
bindDeclaration(<Declaration>node, SymbolFlags.IndexSignature, 0, /*isBlockScopeContainer*/ false);
369400
break;
@@ -379,6 +410,12 @@ module ts {
379410
case SyntaxKind.SetAccessor:
380411
bindDeclaration(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
381412
break;
413+
414+
case SyntaxKind.FunctionType:
415+
case SyntaxKind.ConstructorType:
416+
bindFunctionOrConstructorType(<SignatureDeclaration>node);
417+
break;
418+
382419
case SyntaxKind.TypeLiteral:
383420
bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type", /*isBlockScopeContainer*/ false);
384421
break;

0 commit comments

Comments
 (0)
0