( ctx: TypeResolveContext, )
| 177 | } |
| 178 | |
| 179 | export function extractRuntimeProps( |
| 180 | ctx: TypeResolveContext, |
| 181 | ): string | undefined { |
| 182 | // this is only called if propsTypeDecl exists |
| 183 | const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl!) |
| 184 | if (!props.length) { |
| 185 | return |
| 186 | } |
| 187 | |
| 188 | const propStrings: string[] = [] |
| 189 | const hasStaticDefaults = hasStaticWithDefaults(ctx) |
| 190 | |
| 191 | for (const prop of props) { |
| 192 | propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults)) |
| 193 | // register bindings |
| 194 | if ('bindingMetadata' in ctx && !(prop.key in ctx.bindingMetadata)) { |
| 195 | ctx.bindingMetadata[prop.key] = BindingTypes.PROPS |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | let propsDecls = `{ |
| 200 | ${propStrings.join(',\n ')}\n }` |
| 201 | |
| 202 | if (ctx.propsRuntimeDefaults && !hasStaticDefaults) { |
| 203 | propsDecls = `/*@__PURE__*/${ctx.helper( |
| 204 | 'mergeDefaults', |
| 205 | )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})` |
| 206 | } |
| 207 | |
| 208 | return propsDecls |
| 209 | } |
| 210 | |
| 211 | function resolveRuntimePropsFromType( |
| 212 | ctx: TypeResolveContext, |
no test coverage detected