Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No typescript checks on <template> expressions #3421

Closed
pikax opened this issue Jul 19, 2023 · 1 comment
Closed

No typescript checks on <template> expressions #3421

pikax opened this issue Jul 19, 2023 · 1 comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@pikax
Copy link
Member

pikax commented Jul 19, 2023

Any js expression on the template does not get checked.

<template>
  <input :key="thisPropertyDoesNotExists">
  <template v-for="test in []" :key="thisPropertyDoesNotExists"
        :random-invalid-attribute="aslokdjhaskd askdj aslkdj askjdh asodjklasd">
  </template>
</template>

playground

The above code get's converted to

const __sfc__ = {};
import { openBlock as _openBlock, createElementBlock as _createElementBlock, renderList as _renderList, Fragment as _Fragment } from "vue"
function render(_ctx, _cache) {
  return (_openBlock(), _createElementBlock(_Fragment, null, [
    (_openBlock(), _createElementBlock("input", { key: _ctx.thisPropertyDoesNotExists })),
    (_openBlock(), _createElementBlock(_Fragment, null, _renderList([], (test) => {
      return (_openBlock(), _createElementBlock(_Fragment, { key: _ctx.thisPropertyDoesNotExists }, [], 64 /* STABLE_FRAGMENT */))
    }), 64 /* STABLE_FRAGMENT */))
  ], 64 /* STABLE_FRAGMENT */))
}
__sfc__.render = render
__sfc__.__file = "src/App.vue"
export default __sfc__

The Fragment is rendered with key: _ctx.thisPropertyDoesNotExists, other properties are ignored (AFAIK).

@so1ve
Copy link
Member

so1ve commented Jul 19, 2023

#329, we need to add these bindings to a "usage list" so they can get checked.

This does not apply to template only:

<script setup lang="ts">
const asdfasdf = 1;
</script>

<template>
  <div :class="asdfasdf asfasf asdfasfas" :key="asdfasdf"></div>
</template>

It throws in vue playground, but volar works :(

@so1ve so1ve added bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

2 participants