@@ -332,10 +332,9 @@ module ts {
332
332
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
333
333
// from an actual type literal symbol you would have gotten had you used the long form.
334
334
335
- var symbolKind = node . kind === SyntaxKind . FunctionType ? SymbolFlags . CallSignature : SymbolFlags . ConstructSignature ;
336
- var symbol = createSymbol ( symbolKind , getDeclarationName ( node ) ) ;
337
- addDeclarationToSymbol ( symbol , node , symbolKind ) ;
338
- bindChildren ( node , symbolKind , /*isBlockScopeContainer:*/ false ) ;
335
+ var symbol = createSymbol ( SymbolFlags . Signature , getDeclarationName ( node ) ) ;
336
+ addDeclarationToSymbol ( symbol , node , SymbolFlags . Signature ) ;
337
+ bindChildren ( node , SymbolFlags . Signature , /*isBlockScopeContainer:*/ false ) ;
339
338
340
339
var typeLiteralSymbol = createSymbol ( SymbolFlags . TypeLiteral , "__type" ) ;
341
340
addDeclarationToSymbol ( typeLiteralSymbol , node , SymbolFlags . TypeLiteral ) ;
@@ -376,21 +375,33 @@ module ts {
376
375
}
377
376
declareSymbol ( blockScopeContainer . locals , undefined , node , SymbolFlags . BlockScopedVariable , SymbolFlags . BlockScopedVariableExcludes ) ;
378
377
}
379
-
380
378
bindChildren ( node , SymbolFlags . BlockScopedVariable , /*isBlockScopeContainer*/ false ) ;
381
379
}
382
380
381
+ function getDestructuringParameterName ( node : Declaration ) {
382
+ return "__" + indexOf ( ( < SignatureDeclaration > node . parent ) . parameters , node ) ;
383
+ }
384
+
383
385
function bind ( node : Node ) {
384
386
node . parent = parent ;
385
387
switch ( node . kind ) {
386
388
case SyntaxKind . TypeParameter :
387
389
bindDeclaration ( < Declaration > node , SymbolFlags . TypeParameter , SymbolFlags . TypeParameterExcludes , /*isBlockScopeContainer*/ false ) ;
388
390
break ;
389
391
case SyntaxKind . Parameter :
390
- bindDeclaration ( < Declaration > node , SymbolFlags . FunctionScopedVariable , SymbolFlags . ParameterExcludes , /*isBlockScopeContainer*/ false ) ;
392
+ if ( isBindingPattern ( ( < Declaration > node ) . name ) ) {
393
+ bindAnonymousDeclaration ( < Declaration > node , SymbolFlags . FunctionScopedVariable , getDestructuringParameterName ( < Declaration > node ) , /*isBlockScopeContainer*/ false ) ;
394
+ }
395
+ else {
396
+ bindDeclaration ( < Declaration > node , SymbolFlags . FunctionScopedVariable , SymbolFlags . ParameterExcludes , /*isBlockScopeContainer*/ false ) ;
397
+ }
391
398
break ;
392
399
case SyntaxKind . VariableDeclaration :
393
- if ( node . flags & NodeFlags . BlockScoped ) {
400
+ case SyntaxKind . BindingElement :
401
+ if ( isBindingPattern ( ( < Declaration > node ) . name ) ) {
402
+ bindChildren ( node , 0 , /*isBlockScopeContainer*/ false ) ;
403
+ }
404
+ else if ( node . flags & NodeFlags . BlockScoped ) {
394
405
bindBlockScopedVariableDeclaration ( < Declaration > node ) ;
395
406
}
396
407
else {
@@ -399,6 +410,8 @@ module ts {
399
410
break ;
400
411
case SyntaxKind . PropertyDeclaration :
401
412
case SyntaxKind . PropertySignature :
413
+ bindDeclaration ( < Declaration > node , SymbolFlags . Property | ( ( < PropertyDeclaration > node ) . questionToken ? SymbolFlags . Optional : 0 ) , SymbolFlags . PropertyExcludes , /*isBlockScopeContainer*/ false ) ;
414
+ break ;
402
415
case SyntaxKind . PropertyAssignment :
403
416
case SyntaxKind . ShorthandPropertyAssignment :
404
417
bindDeclaration ( < Declaration > node , SymbolFlags . Property , SymbolFlags . PropertyExcludes , /*isBlockScopeContainer*/ false ) ;
@@ -407,23 +420,19 @@ module ts {
407
420
bindDeclaration ( < Declaration > node , SymbolFlags . EnumMember , SymbolFlags . EnumMemberExcludes , /*isBlockScopeContainer*/ false ) ;
408
421
break ;
409
422
case SyntaxKind . CallSignature :
410
- bindDeclaration ( < Declaration > node , SymbolFlags . CallSignature , 0 , /*isBlockScopeContainer*/ false ) ;
411
- break ;
412
423
case SyntaxKind . ConstructSignature :
413
- bindDeclaration ( < Declaration > node , SymbolFlags . ConstructSignature , 0 , /*isBlockScopeContainer*/ true ) ;
424
+ case SyntaxKind . IndexSignature :
425
+ bindDeclaration ( < Declaration > node , SymbolFlags . Signature , 0 , /*isBlockScopeContainer*/ false ) ;
414
426
break ;
415
427
case SyntaxKind . MethodDeclaration :
416
428
case SyntaxKind . MethodSignature :
417
429
// If this is an ObjectLiteralExpression method, then it sits in the same space
418
430
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
419
431
// so that it will conflict with any other object literal members with the same
420
432
// name.
421
- bindDeclaration ( < Declaration > node , SymbolFlags . Method ,
433
+ bindDeclaration ( < Declaration > node , SymbolFlags . Method | ( ( < MethodDeclaration > node ) . questionToken ? SymbolFlags . Optional : 0 ) ,
422
434
isObjectLiteralMethod ( node ) ? SymbolFlags . PropertyExcludes : SymbolFlags . MethodExcludes , /*isBlockScopeContainer*/ true ) ;
423
435
break ;
424
- case SyntaxKind . IndexSignature :
425
- bindDeclaration ( < Declaration > node , SymbolFlags . IndexSignature , 0 , /*isBlockScopeContainer*/ false ) ;
426
- break ;
427
436
case SyntaxKind . FunctionDeclaration :
428
437
bindDeclaration ( < Declaration > node , SymbolFlags . Function , SymbolFlags . FunctionExcludes , /*isBlockScopeContainer*/ true ) ;
429
438
break ;
@@ -483,17 +492,15 @@ module ts {
483
492
bindAnonymousDeclaration ( < SourceFile > node , SymbolFlags . ValueModule , '"' + removeFileExtension ( ( < SourceFile > node ) . filename ) + '"' , /*isBlockScopeContainer*/ true ) ;
484
493
break ;
485
494
}
486
-
487
495
case SyntaxKind . Block :
488
496
case SyntaxKind . TryBlock :
489
497
case SyntaxKind . CatchClause :
490
498
case SyntaxKind . FinallyBlock :
491
499
case SyntaxKind . ForStatement :
492
500
case SyntaxKind . ForInStatement :
493
501
case SyntaxKind . SwitchStatement :
494
- bindChildren ( node , 0 , true ) ;
502
+ bindChildren ( node , 0 , /*isBlockScopeContainer*/ true ) ;
495
503
break ;
496
-
497
504
default :
498
505
var saveParent = parent ;
499
506
parent = node ;
0 commit comments