File tree Expand file tree Collapse file tree 4 files changed +34
-2
lines changed
Expand file tree Collapse file tree 4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 11# Unreleased
22
3+ ### Bug Fixes
4+
5+ - Constructed references to enum types will be properly linked with ` @interface ` , #2508 .
6+
37## v0.25.9 (2024-02-26)
48
59### Features
Original file line number Diff line number Diff line change @@ -724,8 +724,12 @@ const referenceConverter: TypeConverter<
724724 ) ;
725725 return type ;
726726 } ,
727- convertType ( context , type ) {
728- const symbol = type . aliasSymbol ?? type . getSymbol ( ) ;
727+ convertType ( context , type , node ) {
728+ // typeName.symbol handles the case where this is a union which happens to refer
729+ // to an enumeration. TS doesn't put the symbol on the type for some reason, but
730+ // does add it to the constructed type node.
731+ const symbol =
732+ type . aliasSymbol ?? type . getSymbol ( ) ?? node . typeName . symbol ;
729733 if ( ! symbol ) {
730734 // This happens when we get a reference to a type parameter
731735 // created within a mapped type, `K` in: `{ [K in T]: string }`
Original file line number Diff line number Diff line change 1+ export enum Color {
2+ BLUE = "Blue" ,
3+ RED = "Red" ,
4+ }
5+
6+ type TypeOf < T > = {
7+ [ K in keyof T ] : T [ K ] [ keyof T [ K ] ] ;
8+ } ;
9+
10+ type Foo = {
11+ color : typeof Color ;
12+ } ;
13+
14+ /** @interface */
15+ export type Bar = TypeOf < Foo > ;
16+ // ^?
Original file line number Diff line number Diff line change @@ -1412,4 +1412,12 @@ describe("Issue Tests", () => {
14121412 // }>(object: I): void
14131413 equal ( type ?. toString ( ) , "Value & Object" ) ;
14141414 } ) ;
1415+
1416+ it ( "Handles constructed references to enumeration types, #2508" , ( ) => {
1417+ const project = convert ( ) ;
1418+ const refl = query ( project , "Bar.color" ) ;
1419+ equal ( refl . type ?. type , "reference" ) ;
1420+ equal ( refl . type . toString ( ) , "Color" ) ;
1421+ equal ( refl . type . reflection ?. id , query ( project , "Color" ) . id ) ;
1422+ } ) ;
14151423} ) ;
You can’t perform that action at this time.
0 commit comments