Skip to content

Commit 7215414

Browse files
committed
feat(compiler-sfc): expose resolve TS type
for babel plugin usage
1 parent 2ffe3d5 commit 7215414

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/compiler-sfc/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export {
3333

3434
// Internals for type resolution
3535
export { invalidateTypeCache, registerTS } from './script/resolveType'
36+
export { extractRuntimeProps } from './script/defineProps'
37+
export { extractRuntimeEmits } from './script/defineEmits'
3638

3739
// Types
3840
export type {

packages/compiler-sfc/src/script/defineEmits.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function genRuntimeEmits(ctx: ScriptCompileContext): string | undefined {
5757
return emitsDecl
5858
}
5959

60-
function extractRuntimeEmits(ctx: ScriptCompileContext): Set<string> {
60+
export function extractRuntimeEmits(ctx: ScriptCompileContext): Set<string> {
6161
const emits = new Set<string>()
6262
const node = ctx.emitsTypeDecl!
6363

packages/compiler-sfc/src/script/defineProps.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
150150
}
151151
}
152152
} else if (ctx.propsTypeDecl) {
153-
propsDecls = genRuntimePropsFromTypes(ctx)
153+
propsDecls = extractRuntimeProps(ctx)
154154
}
155155

156156
const modelsDecls = genModelProps(ctx)
@@ -162,7 +162,9 @@ export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
162162
}
163163
}
164164

165-
function genRuntimePropsFromTypes(ctx: ScriptCompileContext) {
165+
export function extractRuntimeProps(
166+
ctx: ScriptCompileContext
167+
): string | undefined {
166168
// this is only called if propsTypeDecl exists
167169
const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl!)
168170
if (!props.length) {

0 commit comments

Comments
 (0)