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 1
1
# Unreleased
2
2
3
+ ### Bug Fixes
4
+
5
+ - Constructed references to enum types will be properly linked with ` @interface ` , #2508 .
6
+
3
7
## v0.25.9 (2024-02-26)
4
8
5
9
### Features
Original file line number Diff line number Diff line change @@ -724,8 +724,12 @@ const referenceConverter: TypeConverter<
724
724
) ;
725
725
return type ;
726
726
} ,
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 ;
729
733
if ( ! symbol ) {
730
734
// This happens when we get a reference to a type parameter
731
735
// 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", () => {
1412
1412
// }>(object: I): void
1413
1413
equal ( type ?. toString ( ) , "Value & Object" ) ;
1414
1414
} ) ;
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
+ } ) ;
1415
1423
} ) ;
You can’t perform that action at this time.
0 commit comments