@@ -631,6 +631,14 @@ describe('ParameterResolver', () => {
631631 . toEqual ( 'keyof:[raw:boolean]' ) ;
632632 } ) ;
633633
634+ it ( 'should hash typeof' , ( ) => {
635+ expect ( loader . hashParameterRangeUnresolved ( < any > {
636+ type : 'typeof' ,
637+ value : 'CLASS' ,
638+ } ) )
639+ . toEqual ( 'typeof:CLASS' ) ;
640+ } ) ;
641+
634642 it ( 'should hash hash' , ( ) => {
635643 expect ( loader . hashParameterRangeUnresolved ( {
636644 type : 'hash' ,
@@ -1301,6 +1309,62 @@ class MyInnerClass<AInner, BInner> {
13011309 } ) ;
13021310 } ) ;
13031311
1312+ it ( 'should handle a keyof range over a typeof over an enum' , async ( ) => {
1313+ resolutionContext . contentsOverrides = {
1314+ 'A.d.ts' : `export * from './MyEnum'` ,
1315+ 'MyEnum.d.ts' : `export enum MyEnum {
1316+ keya = 'valuea',
1317+ 'keyb' = 'valueb',
1318+ }` ,
1319+ } ;
1320+
1321+ expect ( await loader . resolveRange ( {
1322+ type : 'keyof' ,
1323+ value : {
1324+ type : 'typeof' ,
1325+ value : 'MyEnum' ,
1326+ origin : classReference ,
1327+ } ,
1328+ } , classReference , { } , true , new Set ( ) ) ) . toMatchObject ( {
1329+ type : 'union' ,
1330+ elements : [
1331+ { type : 'literal' , value : 'keya' } ,
1332+ { type : 'literal' , value : 'keyb' } ,
1333+ ] ,
1334+ } ) ;
1335+ } ) ;
1336+
1337+ it ( 'should throw on a keyof range over a typeof over a non-enum' , async ( ) => {
1338+ resolutionContext . contentsOverrides = {
1339+ 'A.d.ts' : `export * from './MyClass'` ,
1340+ 'MyClass.d.ts' : `export class MyClass {}` ,
1341+ } ;
1342+
1343+ await expect ( loader . resolveRange ( {
1344+ type : 'keyof' ,
1345+ value : {
1346+ type : 'typeof' ,
1347+ value : 'MyClass' ,
1348+ origin : classReference ,
1349+ } ,
1350+ } , classReference , { } , true , new Set ( ) ) ) . rejects
1351+ . toThrowError ( `Detected typeof of unsupported value MyClass in A` ) ;
1352+ } ) ;
1353+
1354+ it ( 'should throw on a typeof range' , async ( ) => {
1355+ resolutionContext . contentsOverrides = {
1356+ 'A.d.ts' : `export * from './MyClass'` ,
1357+ 'MyClass.d.ts' : `export class MyClass{}` ,
1358+ } ;
1359+
1360+ await expect ( loader . resolveRange ( {
1361+ type : 'typeof' ,
1362+ value : 'MyClass' ,
1363+ origin : classReference ,
1364+ } , classReference , { } , true , new Set ( ) ) ) . rejects
1365+ . toThrowError ( `Detected typeof of unsupported value MyClass in A` ) ;
1366+ } ) ;
1367+
13041368 it ( 'should handle an interface recursively pointing to itself' , async ( ) => {
13051369 resolutionContext . contentsOverrides = {
13061370 'A.d.ts' : `export interface MyInterface { field: MyInterface; }` ,
0 commit comments