Skip to content

Commit

Permalink
feat(compiler-sfc): expose resolve TS type
Browse files Browse the repository at this point in the history
for babel plugin usage
  • Loading branch information
sxzz committed Jul 30, 2023
1 parent 3be4e3c commit bd84031
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/compiler-sfc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export {

// Internals for type resolution
export { invalidateTypeCache, registerTS } from './script/resolveType'
export { extractRuntimeProps } from './script/defineProps'
export { extractRuntimeEmits } from './script/defineEmits'

// Types
export type {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/script/defineEmits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function genRuntimeEmits(ctx: ScriptCompileContext): string | undefined {
return emitsDecl
}

function extractRuntimeEmits(ctx: ScriptCompileContext): Set<string> {
export function extractRuntimeEmits(ctx: ScriptCompileContext): Set<string> {
const emits = new Set<string>()
const node = ctx.emitsTypeDecl!

Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-sfc/src/script/defineProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
}
}
} else if (ctx.propsTypeDecl) {
propsDecls = genRuntimePropsFromTypes(ctx)
propsDecls = extractRuntimeProps(ctx)
}

const modelsDecls = genModelProps(ctx)
Expand All @@ -162,7 +162,7 @@ export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
}
}

function genRuntimePropsFromTypes(ctx: ScriptCompileContext) {
export function extractRuntimeProps(ctx: ScriptCompileContext) {
// this is only called if propsTypeDecl exists
const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl!)
if (!props.length) {
Expand Down

0 comments on commit bd84031

Please sign in to comment.