File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,15 @@ describe('resolveType', () => {
2020 foo: number // property
2121 bar(): void // method
2222 'baz': string // string literal key
23+ [\`qux\`]: boolean // template literal key
2324 (e: 'foo'): void // call signature
2425 (e: 'bar'): void
2526 }>()` )
2627 expect ( props ) . toStrictEqual ( {
2728 foo : [ 'Number' ] ,
2829 bar : [ 'Function' ] ,
2930 baz : [ 'String' ] ,
31+ qux : [ 'Boolean' ] ,
3032 } )
3133 expect ( calls ?. length ) . toBe ( 2 )
3234 } )
@@ -195,7 +197,7 @@ describe('resolveType', () => {
195197 type T = 'foo' | 'bar'
196198 type S = 'x' | 'y'
197199 defineProps<{
198- [\`_\${T}_\${S}_\`]: string
200+ [K in \`_\${T}_\${S}_\`]: string
199201 }>()
200202 ` ) . props ,
201203 ) . toStrictEqual ( {
Original file line number Diff line number Diff line change @@ -337,12 +337,8 @@ function typeElementsToMap(
337337 }
338338 ; ( e as MaybeWithScope ) . _ownerScope = scope
339339 const name = getId ( e . key )
340- if ( name && ! e . computed ) {
340+ if ( name !== null ) {
341341 res . props [ name ] = e as ResolvedElements [ 'props' ] [ string ]
342- } else if ( e . key . type === 'TemplateLiteral' ) {
343- for ( const key of resolveTemplateKeys ( ctx , e . key , scope ) ) {
344- res . props [ key ] = e as ResolvedElements [ 'props' ] [ string ]
345- }
346342 } else {
347343 ctx . error (
348344 `Unsupported computed key in type referenced by a macro` ,
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ export function getId(node: Expression) {
7676 ? node . name
7777 : node . type === 'StringLiteral'
7878 ? node . value
79- : null
79+ : node . type === 'TemplateLiteral' && ! node . expressions . length
80+ ? node . quasis . map ( q => q . value . cooked ) . join ( '' )
81+ : null
8082}
8183
8284const identity = ( str : string ) => str
You can’t perform that action at this time.
0 commit comments