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

TypeScript is not reporting errors from vueCompilerOptions.checkUnknownEvents #5291

Closed
johannes-lindgren opened this issue Mar 20, 2025 · 1 comment
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@johannes-lindgren
Copy link

Vue - Official extension or vue-tsc version

vue-tsc@2.2.8

VSCode version

Vue version

vue@3.5.13

TypeScript version

typescript@5.7.3

System Info

System:
    OS: macOS 15.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 86.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.9.0 - ~/.nvm/versions/node/v22.9.0/bin/node
    Yarn: 1.22.22 - ~/.asdf/shims/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.9.0/bin/npm
    pnpm: 9.14.4 - ~/.nvm/versions/node/v22.9.0/bin/pnpm
  Browsers:
    Brave Browser: 134.1.76.73
    Chrome: 134.0.6998.89
    Safari: 18.1

package.json dependencies

{
  "dependencies": {
    "vue": "^3.5.13"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^5.2.1",
    "@vue/tsconfig": "^0.7.0",
    "typescript": "~5.7.2",
    "vite": "^6.2.0",
    "vue-tsc": "^2.2.4"
  }
}

Steps to reproduce

  1. Initialize a new vite project with vue and TypeScript
pnpm create vite my-vue-app-2 --template vue-ts
  1. Add vueCompilerOptions.strictTemplates: true to tsconfig.app.json
{
  "vueCompilerOptions": {
    "strictTemplates": true,
  },
}
  1. Open src/App.vue
  2. In <HelloWorld />, add an unknown emit handler. For reference, also add an unknown prop.
<template>
  <HelloWorld 
      msg="Vite + Vue"
      thispropdoesnotexist="sfsdf"
      @thisemitdoesnotexist="() => {}"
  />
</template>

Run vue-tsc:

~/workspaces/tmp/vite-project
vue-tsc -b
src/App.vue:8:7 - error TS2353: Object literal may only specify known properties, and 'thispropdoesnotexist' does not exist in type '{ readonly msg: string; } & VNodeProps & AllowedComponentProps & ComponentCustomProps'.

8       thispropdoesnotexist="sfsdf"
        ~~~~~~~~~~~~~~~~~~~~


Found 1 error.

It finds the error for the unknown prop, but not the unknown event.

You can also try adding vueCompilerOptions.checkUnknownEvents: true

What is expected?

According to the docs, checkUnknownEvents and strictTemplates should:

Check unknown props.

I interpret this as it should check emits—the same way it checks props.

What is actually happening?

There is seemingly no type checking on unknown props

Link to minimal reproduction

No response

Any additional comments?

No response

@johannes-lindgren johannes-lindgren changed the title TypeScript is not reporting vueCompilerOptions.strictTemplates.checkUnknownEvents TypeScript is not reporting vueCompilerOptions.checkUnknownEvents Mar 20, 2025
@johannes-lindgren johannes-lindgren changed the title TypeScript is not reporting vueCompilerOptions.checkUnknownEvents TypeScript is not reporting errors from vueCompilerOptions.checkUnknownEvents Mar 20, 2025
@KazariEX
Copy link
Member

It has been fixed at v3.0.

Image

@KazariEX KazariEX added good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first and removed pending triage labels Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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