@@ -54,6 +54,11 @@ namespace ts {
5454 const body = ( < ModuleDeclaration > node ) . body ;
5555 return body ? getModuleInstanceState ( body ) : ModuleInstanceState . Instantiated ;
5656 }
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+ }
5762 else {
5863 return ModuleInstanceState . Instantiated ;
5964 }
@@ -429,7 +434,11 @@ namespace ts {
429434 // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
430435 // and this case is specially handled. Module augmentations should only be merged with original module definition
431436 // 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 ) {
433442 const exportKind =
434443 ( symbolFlags & SymbolFlags . Value ? SymbolFlags . ExportValue : 0 ) |
435444 ( symbolFlags & SymbolFlags . Type ? SymbolFlags . ExportType : 0 ) |
@@ -1007,7 +1016,7 @@ namespace ts {
10071016 currentFlow = finishFlowLabel ( preFinallyLabel ) ;
10081017 bind ( node . finallyBlock ) ;
10091018 // 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
10111020 // if yes - convert current flow to unreachable
10121021 // i.e.
10131022 // try { return "1" } finally { console.log(1); }
@@ -1827,6 +1836,17 @@ namespace ts {
18271836 switch ( node . kind ) {
18281837 /* Strict mode checks */
18291838 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+ }
18301850 case SyntaxKind . ThisKeyword :
18311851 if ( currentFlow && ( isExpression ( node ) || parent . kind === SyntaxKind . ShorthandPropertyAssignment ) ) {
18321852 node . flowNode = currentFlow ;
@@ -1950,6 +1970,10 @@ namespace ts {
19501970 case SyntaxKind . InterfaceDeclaration :
19511971 return bindBlockScopedDeclaration ( < Declaration > node , SymbolFlags . Interface , SymbolFlags . InterfaceExcludes ) ;
19521972 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 ;
19531977 case SyntaxKind . TypeAliasDeclaration :
19541978 return bindBlockScopedDeclaration ( < Declaration > node , SymbolFlags . TypeAlias , SymbolFlags . TypeAliasExcludes ) ;
19551979 case SyntaxKind . EnumDeclaration :
@@ -2421,6 +2445,9 @@ namespace ts {
24212445 case SyntaxKind . HeritageClause :
24222446 return computeHeritageClause ( < HeritageClause > node , subtreeFlags ) ;
24232447
2448+ case SyntaxKind . CatchClause :
2449+ return computeCatchClause ( < CatchClause > node , subtreeFlags ) ;
2450+
24242451 case SyntaxKind . ExpressionWithTypeArguments :
24252452 return computeExpressionWithTypeArguments ( < ExpressionWithTypeArguments > node , subtreeFlags ) ;
24262453
@@ -2650,6 +2677,17 @@ namespace ts {
26502677 return transformFlags & ~ TransformFlags . NodeExcludes ;
26512678 }
26522679
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+
26532691 function computeExpressionWithTypeArguments ( node : ExpressionWithTypeArguments , subtreeFlags : TransformFlags ) {
26542692 // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the
26552693 // extends clause of a class.
0 commit comments