File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ title: Changelog
4
4
5
5
## Unreleased
6
6
7
+ ### Bug Fixes
8
+
9
+ - Add special handling for import types with type errors discarded with
10
+ ts-expect-error, #2792 .
11
+
7
12
## v0.27.2 (2024-11-29)
8
13
9
14
### Bug Fixes
Original file line number Diff line number Diff line change @@ -421,7 +421,13 @@ const importType: TypeConverter<ts.ImportTypeNode> = {
421
421
kind : [ ts . SyntaxKind . ImportType ] ,
422
422
convert ( context , node ) {
423
423
const name = node . qualifier ?. getText ( ) ?? "__module" ;
424
- const symbol = context . expectSymbolAtLocation ( node . qualifier || node ) ;
424
+ const symbol = context . getSymbolAtLocation ( node . qualifier || node ) ;
425
+ // #2792, we should always have a symbol here unless there is a compiler
426
+ // error ignored with ts-expect-error or ts-ignore.
427
+ if ( ! symbol ) {
428
+ return new IntrinsicType ( "any" ) ;
429
+ }
430
+
425
431
return ReferenceType . createSymbolReference (
426
432
context . resolveAliasedSymbol ( symbol ) ,
427
433
context ,
Original file line number Diff line number Diff line change
1
+ export type TypeNodeType = {
2
+ // @ts -expect-error
3
+ generated : import ( "@typedoc/dummy" ) . GeneratedType ;
4
+ } ;
5
+
6
+ // @ts -expect-error
7
+ export const typeType = null ! as import ( "@typedoc/dummy" ) . GeneratedType ;
Original file line number Diff line number Diff line change @@ -1933,4 +1933,13 @@ describe("Issue Tests", () => {
1933
1933
equal ( Foo . type ?. type , "reference" ) ;
1934
1934
equal ( Foo . type . reflection ?. getFullName ( ) , Bar . getFullName ( ) ) ;
1935
1935
} ) ;
1936
+
1937
+ it ( "#2792 handles @ts-expect-error on import types by converting to any" , ( ) => {
1938
+ const project = convert ( ) ;
1939
+ const node = query ( project , "TypeNodeType.generated" ) ;
1940
+ equal ( node . type ?. toString ( ) , "any" ) ;
1941
+
1942
+ const type = query ( project , "typeType" ) ;
1943
+ equal ( type . type ?. toString ( ) , "any" ) ;
1944
+ } ) ;
1936
1945
} ) ;
You can’t perform that action at this time.
0 commit comments