Skip to content

Commit

Permalink
fix(compiler-sfc): fix built-in type resolving in external files
Browse files Browse the repository at this point in the history
close #8244
  • Loading branch information
yyx990803 committed May 8, 2023
1 parent c2172f3 commit 6b194bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,23 @@ describe('resolveType', () => {
expect(deps && [...deps]).toStrictEqual(Object.keys(files))
})

// #8244
test('utility type in external file', () => {
const files = {
'/foo.ts': 'type A = { n?: number }; export type B = Required<A>'
}
const { props } = resolve(
`
import { B } from './foo'
defineProps<B>()
`,
files
)
expect(props).toStrictEqual({
n: ['Number']
})
})

test('relative vue', () => {
const files = {
'/foo.vue':
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/script/resolveType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ function resolveBuiltin(
name: GetSetType<typeof SupportedBuiltinsSet>,
scope: TypeScope
): ResolvedElements {
const t = resolveTypeElements(ctx, node.typeParameters!.params[0])
const t = resolveTypeElements(ctx, node.typeParameters!.params[0], scope)
switch (name) {
case 'Partial': {
const res: ResolvedElements = { props: {}, calls: t.calls }
Expand Down

0 comments on commit 6b194bc

Please sign in to comment.