File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1525,6 +1525,26 @@ describe('resolveType', () => {
15251525 } )
15261526 } )
15271527
1528+ test ( 'declare global with indexed access type' , ( ) => {
1529+ const files = {
1530+ '/global.d.ts' : `
1531+ declare global {
1532+ type Options = {
1533+ code: {
1534+ selected: boolean
1535+ }
1536+ }
1537+ }` ,
1538+ }
1539+ const { props } = resolve ( `defineProps<Options["code"]>()` , files , {
1540+ globalTypeFiles : Object . keys ( files ) ,
1541+ } )
1542+
1543+ expect ( props ) . toStrictEqual ( {
1544+ selected : [ 'Boolean' ] ,
1545+ } )
1546+ } )
1547+
15281548 // #9871
15291549 test ( 'shared generics with different args' , ( ) => {
15301550 const files = {
Original file line number Diff line number Diff line change @@ -1399,6 +1399,18 @@ function recordType(
13991399 case 'TSInterfaceDeclaration' :
14001400 case 'TSEnumDeclaration' :
14011401 case 'TSModuleDeclaration' : {
1402+ // Handle `declare global { ... }` blocks by recursively processing their contents
1403+ if ( node . type === 'TSModuleDeclaration' && node . global ) {
1404+ const body = node . body as TSModuleBlock
1405+ for ( const s of body . body ) {
1406+ if ( s . type === 'ExportNamedDeclaration' && s . declaration ) {
1407+ recordType ( s . declaration , types , declares )
1408+ } else {
1409+ recordType ( s , types , declares )
1410+ }
1411+ }
1412+ break
1413+ }
14021414 const id = overwriteId || getId ( node . id )
14031415 let existing = types [ id ]
14041416 if ( existing ) {
You can’t perform that action at this time.
0 commit comments