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
44
55## Unreleased
66
7+ ### Bug Fixes
8+
9+ - Add special handling for import types with type errors discarded with
10+ ts-expect-error, #2792 .
11+
712## v0.27.2 (2024-11-29)
813
914### Bug Fixes
Original file line number Diff line number Diff line change @@ -421,7 +421,13 @@ const importType: TypeConverter<ts.ImportTypeNode> = {
421421 kind : [ ts . SyntaxKind . ImportType ] ,
422422 convert ( context , node ) {
423423 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+
425431 return ReferenceType . createSymbolReference (
426432 context . resolveAliasedSymbol ( symbol ) ,
427433 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", () => {
19331933 equal ( Foo . type ?. type , "reference" ) ;
19341934 equal ( Foo . type . reflection ?. getFullName ( ) , Bar . getFullName ( ) ) ;
19351935 } ) ;
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+ } ) ;
19361945} ) ;
You can’t perform that action at this time.
0 commit comments