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

Npm script type-check is not working #267

Closed
miroljub1995 opened this issue May 8, 2023 · 6 comments · Fixed by #274 or #275
Closed

Npm script type-check is not working #267

miroljub1995 opened this issue May 8, 2023 · 6 comments · Fixed by #274 or #275

Comments

@miroljub1995
Copy link

Steps to reproduce:

  • Create empty directory and navigate to it
  • Run npm init
  • Install create-vue@latest, currently it is 3.6.3
  • Run: npx create-vue --ts --router --pinia --eslint-with-prettier source and switch to source directory
  • Make some errors in files
  • Run npm run type-check

There are no errors reported by command.

@miroljub1995 miroljub1995 changed the title Npm script type-check not working Npm script type-check is not working May 8, 2023
@filipbekic01
Copy link

Confirmed

@skirtles-code
Copy link

This seems to be a regression in 3.6.2. It works fine with npm init vue@3.6.1, but not 3.6.2 or 3.6.3.

@xenolithviktor
Copy link

A temporary workaround (from poking around in #181), in package.json scripts:

"type-check": "run-p type-check:*",
"type-check:app": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"type-check:node": "vue-tsc --noEmit -p tsconfig.node.json --composite false"

@Xujie990604
Copy link

I always thought my changes were causing the problem until I created a new project. Only to find out that brand new projects also have this problem

@filipbekic01
Copy link

Any progress? This is stopping us from using latest version.

sodatea added a commit that referenced this issue May 12, 2023
Fixes #267

Thanks @segevfiner for noticing this new feature!

Currently there's still a small annoyance that `vue-tsc` would output
an extra error message when there're type errors in `.vue` files
vuejs/language-tools#2622 But it works well
if there's no error.

I've already submitted a PR to address it vuejs/language-tools#3176
@sodatea
Copy link
Member

sodatea commented May 12, 2023

Sorry that somehow I missed the notification a few days ago.

It's because I moved the compilerOptions from tsconfig.json to tsconfig.app.json in the 2023-05-05 (v3.6.2) release, but forgot to change the type-check script.

There are a few ways to fix it:

  • To restore the previous behavior, i.e. only check the src directory, please change the type-check script in package.json to vue-tsc --noEmit -p tsconfig.app.json --composite false
  • A more comprehensive approach is to use vue-tsc --build for type-check now that noEmit is supported in composite projects in TypeScript 5. I've opened a PR: fix: use --build for type-checking to be exhaustive and less-fragile #274 to update the templates. To adopt this approach in an existing project, you can:
    1. add *.tsbuildinfo to the end of .gitignore
    2. add "noEmit": true to the compilerOptions in tsconfig.app.json and tsconfig.node.json
    3. change the type-check script in package.json to vue-tsc --build --force
      Note that there's a small annoyance that an additional error message (Error: Debug Failure. False expression: Paths must either both be absolute or both be relative) would be output if there's a type error in a .vue file. It's just a misplaced error message, it doesn't mean any additional errors, nor will it throw when there's no error. I'm trying to fix that soon.

sodatea added a commit that referenced this issue May 12, 2023
Fixes #267

It's because I moved the `compilerOptions` from `tsconfig.json` to
`tsconfig.app.json` in the 2023-05-05 (v3.6.2) release, but forgot to
change the `type-check` script.

This isn't comprehensive because it doesn't check all the sub-projects,
but at least it's the same scope as previous versions.

Ideally I hope #274 can work reliably. But now I'm not sure. So let's
first fix this bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants