inferRuntimeType() — vue Function Reference
Architecture documentation for the inferRuntimeType() function in compileScript.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD f5615e57_27e2_c277_36a9_ca880b809a96["inferRuntimeType()"] b9f12a63_b611_1b00_0717_3ff21d7ce156["compileScript.ts"] f5615e57_27e2_c277_36a9_ca880b809a96 -->|defined in| b9f12a63_b611_1b00_0717_3ff21d7ce156 b5bc0258_b738_f4bd_b2f8_86ad13c9824d["recordType()"] b5bc0258_b738_f4bd_b2f8_86ad13c9824d -->|calls| f5615e57_27e2_c277_36a9_ca880b809a96 055d772e_d763_3b26_fcda_751e2ef7f1ef["extractRuntimeProps()"] 055d772e_d763_3b26_fcda_751e2ef7f1ef -->|calls| f5615e57_27e2_c277_36a9_ca880b809a96 style f5615e57_27e2_c277_36a9_ca880b809a96 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/compiler-sfc/src/compileScript.ts lines 1469–1554
function inferRuntimeType(
node: TSType,
declaredTypes: Record<string, string[]>
): string[] {
switch (node.type) {
case 'TSStringKeyword':
return ['String']
case 'TSNumberKeyword':
return ['Number']
case 'TSBooleanKeyword':
return ['Boolean']
case 'TSObjectKeyword':
return ['Object']
case 'TSTypeLiteral':
// TODO (nice to have) generate runtime property validation
return ['Object']
case 'TSFunctionType':
return ['Function']
case 'TSArrayType':
case 'TSTupleType':
// TODO (nice to have) generate runtime element type/length checks
return ['Array']
case 'TSLiteralType':
switch (node.literal.type) {
case 'StringLiteral':
return ['String']
case 'BooleanLiteral':
return ['Boolean']
case 'NumericLiteral':
case 'BigIntLiteral':
return ['Number']
default:
return [`null`]
}
case 'TSTypeReference':
if (node.typeName.type === 'Identifier') {
if (declaredTypes[node.typeName.name]) {
return declaredTypes[node.typeName.name]
}
switch (node.typeName.name) {
case 'Array':
case 'Function':
case 'Object':
case 'Set':
case 'Map':
case 'WeakSet':
case 'WeakMap':
case 'Date':
case 'Promise':
return [node.typeName.name]
case 'Record':
case 'Partial':
case 'Readonly':
case 'Pick':
case 'Omit':
case 'Exclude':
case 'Extract':
case 'Required':
case 'InstanceType':
return ['Object']
}
}
return [`null`]
case 'TSParenthesizedType':
return inferRuntimeType(node.typeAnnotation, declaredTypes)
case 'TSUnionType':
return [
...new Set(
[].concat(
...(node.types.map(t => inferRuntimeType(t, declaredTypes)) as any)
)
)
]
case 'TSIntersectionType':
return ['Object']
case 'TSSymbolKeyword':
return ['Symbol']
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does inferRuntimeType() do?
inferRuntimeType() is a function in the vue codebase, defined in packages/compiler-sfc/src/compileScript.ts.
Where is inferRuntimeType() defined?
inferRuntimeType() is defined in packages/compiler-sfc/src/compileScript.ts at line 1469.
What calls inferRuntimeType()?
inferRuntimeType() is called by 2 function(s): extractRuntimeProps, recordType.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free