core icon indicating copy to clipboard operation
core copied to clipboard

types: `true-value`/`false-value` on <input> and `xmlns:xlink`/`xlink:href` on <svg> rejected as unknown attributes in templates

Open zahidzorbaz opened this issue 3 weeks ago • 1 comments

Versions

  • vue 3.5.44 (@vue/runtime-dom JSX types)
  • vue-tsc 3.3.13 + typescript 6.0.3 with strictTemplates: true; same with @vue/content-mapper 4.0.0-alpha.3 + typescript 7.1.0-beta, where unknown attributes are always checked

Reproduction

<script setup lang="ts">
import { ref } from 'vue'
const checked = ref<'yes' | 'no'>('no')
</script>

<template>
  <input v-model="checked" type="checkbox" true-value="yes" false-value="no" />
  <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 10 10">
    <use xlink:href="#a" />
  </svg>
</template>

Actual

error TS2353: Object literal may only specify known properties, and ''true-value'' does not exist in type 'InputHTMLAttributes & ReservedProps'.
error TS2353: Object literal may only specify known properties, and ''xmlns:xlink'' does not exist in type 'SVGAttributes & ReservedProps'.
error TS2353: Object literal may only specify known properties, and ''xlink:href'' does not exist in type 'SVGAttributes & ReservedProps'.

Expected

No errors:

  • true-value / false-value are Vue's own checkbox v-model attributes (vModelCheckbox reads them), so InputHTMLAttributes could declare them (typed any, like value).
  • xmlns:xlink and xlink:href are valid SVG attributes. SVGAttributes declares them only in camelCase (xmlnsXlink, xlinkHref), but a template writes the namespaced spelling, and a name with : is not camelized, so it never matches.

#9299 reported the xmlns:xlink case and is closed as completed (presumably via xmlnsXlink), but the template spelling is still rejected in 3.5.44. Declaring the namespaced keys too ('xmlns:xlink'?, 'xlink:href'?...) would cover it; if the template-side mapping should handle this instead, feel free to move it to language-tools.

This matters more now that the content mapper (language-tools v4) always reports unknown attributes; with vue-tsc 3 only strictTemplates/checkUnknownProps users saw it.

zahidzorbaz avatar Nov 12 '26 10:11 zahidzorbaz

Traced it to packages/runtime-dom/src/jsx.ts. InputHTMLAttributes has no true-value/false-value even though vModel reads them at runtime for checkboxes, and SVGAttributes only has the camelCase xlinkHref/xmlnsXlink while templates write the namespaced spelling, which never gets camelized.

Opened #16247 with the fix plus dts tests. Checked with tsc, the repro errors before and passes after.

bunnysayzz avatar Nov 12 '26 10:11 bunnysayzz