@@ -54,6 +54,11 @@ namespace ts {
54
54
const body = ( < ModuleDeclaration > node ) . body ;
55
55
return body ? getModuleInstanceState ( body ) : ModuleInstanceState . Instantiated ;
56
56
}
57
+ // Only jsdoc typedef definition can exist in jsdoc namespace, and it should
58
+ // be considered the same as type alias
59
+ else if ( node . kind === SyntaxKind . Identifier && ( < Identifier > node ) . isInJSDocNamespace ) {
60
+ return ModuleInstanceState . NonInstantiated ;
61
+ }
57
62
else {
58
63
return ModuleInstanceState . Instantiated ;
59
64
}
@@ -429,7 +434,11 @@ namespace ts {
429
434
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
430
435
// and this case is specially handled. Module augmentations should only be merged with original module definition
431
436
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
432
- if ( ! isAmbientModule ( node ) && ( hasExportModifier || container . flags & NodeFlags . ExportContext ) ) {
437
+ const isJSDocTypedefInJSDocNamespace = node . kind === SyntaxKind . JSDocTypedefTag &&
438
+ node . name &&
439
+ node . name . kind === SyntaxKind . Identifier &&
440
+ ( < Identifier > node . name ) . isInJSDocNamespace ;
441
+ if ( ( ! isAmbientModule ( node ) && ( hasExportModifier || container . flags & NodeFlags . ExportContext ) ) || isJSDocTypedefInJSDocNamespace ) {
433
442
const exportKind =
434
443
( symbolFlags & SymbolFlags . Value ? SymbolFlags . ExportValue : 0 ) |
435
444
( symbolFlags & SymbolFlags . Type ? SymbolFlags . ExportType : 0 ) |
@@ -1007,7 +1016,7 @@ namespace ts {
1007
1016
currentFlow = finishFlowLabel ( preFinallyLabel ) ;
1008
1017
bind ( node . finallyBlock ) ;
1009
1018
// if flow after finally is unreachable - keep it
1010
- // otherwise check if flows after try and after catch are unreachable
1019
+ // otherwise check if flows after try and after catch are unreachable
1011
1020
// if yes - convert current flow to unreachable
1012
1021
// i.e.
1013
1022
// try { return "1" } finally { console.log(1); }
@@ -1827,6 +1836,17 @@ namespace ts {
1827
1836
switch ( node . kind ) {
1828
1837
/* Strict mode checks */
1829
1838
case SyntaxKind . Identifier :
1839
+ // for typedef type names with namespaces, bind the new jsdoc type symbol here
1840
+ // because it requires all containing namespaces to be in effect, namely the
1841
+ // current "blockScopeContainer" needs to be set to its immediate namespace parent.
1842
+ if ( ( < Identifier > node ) . isInJSDocNamespace ) {
1843
+ let parentNode = node . parent ;
1844
+ while ( parentNode && parentNode . kind !== SyntaxKind . JSDocTypedefTag ) {
1845
+ parentNode = parentNode . parent ;
1846
+ }
1847
+ bindBlockScopedDeclaration ( < Declaration > parentNode , SymbolFlags . TypeAlias , SymbolFlags . TypeAliasExcludes ) ;
1848
+ break ;
1849
+ }
1830
1850
case SyntaxKind . ThisKeyword :
1831
1851
if ( currentFlow && ( isExpression ( node ) || parent . kind === SyntaxKind . ShorthandPropertyAssignment ) ) {
1832
1852
node . flowNode = currentFlow ;
@@ -1950,6 +1970,10 @@ namespace ts {
1950
1970
case SyntaxKind . InterfaceDeclaration :
1951
1971
return bindBlockScopedDeclaration ( < Declaration > node , SymbolFlags . Interface , SymbolFlags . InterfaceExcludes ) ;
1952
1972
case SyntaxKind . JSDocTypedefTag :
1973
+ if ( ! ( < JSDocTypedefTag > node ) . fullName || ( < JSDocTypedefTag > node ) . fullName . kind === SyntaxKind . Identifier ) {
1974
+ return bindBlockScopedDeclaration ( < Declaration > node , SymbolFlags . TypeAlias , SymbolFlags . TypeAliasExcludes ) ;
1975
+ }
1976
+ break ;
1953
1977
case SyntaxKind . TypeAliasDeclaration :
1954
1978
return bindBlockScopedDeclaration ( < Declaration > node , SymbolFlags . TypeAlias , SymbolFlags . TypeAliasExcludes ) ;
1955
1979
case SyntaxKind . EnumDeclaration :
@@ -2421,6 +2445,9 @@ namespace ts {
2421
2445
case SyntaxKind . HeritageClause :
2422
2446
return computeHeritageClause ( < HeritageClause > node , subtreeFlags ) ;
2423
2447
2448
+ case SyntaxKind . CatchClause :
2449
+ return computeCatchClause ( < CatchClause > node , subtreeFlags ) ;
2450
+
2424
2451
case SyntaxKind . ExpressionWithTypeArguments :
2425
2452
return computeExpressionWithTypeArguments ( < ExpressionWithTypeArguments > node , subtreeFlags ) ;
2426
2453
@@ -2650,6 +2677,17 @@ namespace ts {
2650
2677
return transformFlags & ~ TransformFlags . NodeExcludes ;
2651
2678
}
2652
2679
2680
+ function computeCatchClause ( node : CatchClause , subtreeFlags : TransformFlags ) {
2681
+ let transformFlags = subtreeFlags ;
2682
+
2683
+ if ( node . variableDeclaration && isBindingPattern ( node . variableDeclaration . name ) ) {
2684
+ transformFlags |= TransformFlags . AssertES2015 ;
2685
+ }
2686
+
2687
+ node . transformFlags = transformFlags | TransformFlags . HasComputedFlags ;
2688
+ return transformFlags & ~ TransformFlags . NodeExcludes ;
2689
+ }
2690
+
2653
2691
function computeExpressionWithTypeArguments ( node : ExpressionWithTypeArguments , subtreeFlags : TransformFlags ) {
2654
2692
// An ExpressionWithTypeArguments is ES6 syntax, as it is used in the
2655
2693
// extends clause of a class.
0 commit comments