File tree Expand file tree Collapse file tree
test/library-tests/TypeScript/RegressionTests/CyclicAlias Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -659,11 +659,16 @@ export class TypeTable {
659659 */
660660 public getSymbolId ( symbol : AugmentedSymbol ) : number {
661661 if ( symbol . flags & ts . SymbolFlags . Alias ) {
662- symbol = this . typeChecker . getAliasedSymbol ( symbol ) ;
662+ let aliasedSymbol : AugmentedSymbol = this . typeChecker . getAliasedSymbol ( symbol ) ;
663+ if ( aliasedSymbol . $id !== - 1 ) { // Check if aliased symbol is on-stack
664+ // Follow aliases eagerly, except in cases where this leads to cycles (for things like `import Foo = Foo.Bar`)
665+ symbol = aliasedSymbol ;
666+ }
663667 }
664668 // We cache the symbol ID to avoid rebuilding long symbol strings.
665669 let id = symbol . $id ;
666670 if ( id != null ) return id ;
671+ symbol . $id = - 1 ; // Mark as on-stack while we are computing the ID
667672 let content = this . getSymbolString ( symbol ) ;
668673 id = this . symbolIds . get ( content ) ;
669674 if ( id != null ) {
Original file line number Diff line number Diff line change 1+ ---
2+ category : fix
3+ ---
4+ * Fixed an extractor crash that would occur in rare cases when a TypeScript file contains a self-referential namespace alias.
Original file line number Diff line number Diff line change 1+ import Foo = Foo . Bar ;
2+
3+ declare namespace Foo {
4+ var Bar : { } ;
5+ }
Original file line number Diff line number Diff line change 1+ | Success |
Original file line number Diff line number Diff line change 1+ // Just check that extraction succeeds
2+ select "Success"
Original file line number Diff line number Diff line change 1+ {
2+ "include" : [" ." ]
3+ }
You can’t perform that action at this time.
0 commit comments