MCPcopy
hub / github.com/vuejs/core / genRuntimeProps

Function genRuntimeProps

packages/compiler-sfc/src/script/defineProps.ts:141–177  ·  view source on GitHub ↗
(ctx: ScriptCompileContext)

Source from the content-addressed store, hash-verified

139}
140
141export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
142 let propsDecls: undefined | string
143
144 if (ctx.propsRuntimeDecl) {
145 propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim()
146 if (ctx.propsDestructureDecl) {
147 const defaults: string[] = []
148 for (const key in ctx.propsDestructuredBindings) {
149 const d = genDestructuredDefaultValue(ctx, key)
150 const finalKey = getEscapedPropName(key)
151 if (d)
152 defaults.push(
153 `${finalKey}: ${d.valueString}${
154 d.needSkipFactory ? `, __skip_${finalKey}: true` : ``
155 }`,
156 )
157 }
158 if (defaults.length) {
159 propsDecls = `/*@__PURE__*/${ctx.helper(
160 `mergeDefaults`,
161 )}(${propsDecls}, {\n ${defaults.join(',\n ')}\n})`
162 }
163 }
164 } else if (ctx.propsTypeDecl) {
165 propsDecls = extractRuntimeProps(ctx)
166 }
167
168 const modelsDecls = genModelProps(ctx)
169
170 if (propsDecls && modelsDecls) {
171 return `/*@__PURE__*/${ctx.helper(
172 'mergeModels',
173 )}(${propsDecls}, ${modelsDecls})`
174 } else {
175 return modelsDecls || propsDecls
176 }
177}
178
179export function extractRuntimeProps(
180 ctx: TypeResolveContext,

Callers 1

compileScriptFunction · 0.90

Calls 7

getEscapedPropNameFunction · 0.90
genModelPropsFunction · 0.90
extractRuntimePropsFunction · 0.85
getStringMethod · 0.80
pushMethod · 0.65
helperMethod · 0.65

Tested by

no test coverage detected