You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enables strict templates. When set to true, all checkUnknown* options will be enabled by default. These can be overridden individually by setting an explicit value for an option.
strictSlotChildren v3.0.0 (experimental)
Type: boolean
Default: if not explicitly set, this uses the strictTemplates option's value
Strict type constraints of slot children. Setting this option to true makes it possible to specify what type of children are allowed in a slot.
Warning
This feature is experimental, syntax may change. It is recommended not to apply the new defineSlots syntax on existing or new codebases while this feature is still experimental.
Follow or provide feedback in this discussion
strictVModel v3.0.0
Type: boolean
Default: if not explicitly set, this uses the strictTemplates option's value
Enables strict type constraints of v-model, requiring the variable passed to v-model to exactly match the type it expects to receive.
Example
ComponentWithModel.vue
<template>...</template>
<script setup lang="ts">
const model =defineModel<string|number>({ required: true,})
</script>
Home.vue
<template>
<ComponentWithModelv-model="testValue" />
<!-- ^ Type 'string | number' is not assignable to type 'string'. -->
</template>
<script setup lang="ts">
const testValue =ref("Hello, World")
</script>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
(WIP) Here are some suggestions to make the Wiki about
vueCompilerOptionsa bit more understandable.strictTemplates
boolean | objectfalseEnables strict templates. When set to
true, allcheckUnknown*options will be enabled by default. These can be overridden individually by setting an explicit value for an option.strictSlotChildren
v3.0.0(experimental)booleanstrictTemplatesoption's valueStrict type constraints of slot children. Setting this option to
truemakes it possible to specify what type of children are allowed in a slot.Warning
This feature is experimental, syntax may change. It is recommended not to apply the new
defineSlotssyntax on existing or new codebases while this feature is still experimental.Follow or provide feedback in this discussion
strictVModel
v3.0.0booleanstrictTemplatesoption's valueEnables strict type constraints of
v-model, requiring the variable passed tov-modelto exactly match the type it expects to receive.Example
ComponentWithModel.vueHome.vueThis can be prevented as follows:
ComponentWithModel.vuestrictCssModules
v3.0.0booleanfalseStrict type checking of CSS modules.
checkUnknownProps
v2.2.2booleanstrictTemplatesoption's valueCheck unknown props.
checkUnknownEvents
v2.2.2booleanstrictTemplatesoption's valueCheck unknown events.
checkUnknownDirectives
v2.2.2booleanstrictTemplatesoption's valueCheck unknown directives.
checkUnknownComponents
v2.2.2booleanstrictTemplatesoption's valueCheck unknown components.
inferComponentDollarEl
v2.2.4booleanfalseInfer
$eltype on the component instance.Details
When
false,$elis always typed asanyin the following scenarios:When
true,$elmay be typed as the root element of the component (e.g.HTMLDivElement) in simple cases:Caveats:
<component>inferComponentDollarRefs
v2.2.4booleanfalseInfer
$refstype on the component instance.inferTemplateDollarAttrs
v2.2.4booleanfalseInfer
$attrstype in the template and the return type ofuseAttrs.inferTemplateDollarEl
v2.2.4booleanfalseInfer
$eltype in the template.inferTemplateDollarRefs
v2.2.4booleanfalseInfer
$refstype in the template.inferTemplateDollarSlots
v2.2.4booleanfalseInfer
$slotstype in the template and the return type ofuseSlots.Beta Was this translation helpful? Give feedback.
All reactions