-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Vite] add a target for type checking #13954
Comments
Hi there @vicb ! Thanks for creating this feature request. I see you are happy to implement this feature. Do you want to give this a shot, and assign the PR to me for review? I can help you if you need! |
I could try to take a look at that but I will certainly need help. As I'm getting more familiar with Nx I think the steps would be:
Would that be a good start? |
How would you do this typechecking outside of Nx context, if you had a pure React+Vitejs app? I mean, if it's a script you set up, maybe there's no need to create a new executor. Maybe you can just create a new target that calls |
Using
Creating an executor could be helpful whenever An other option that I just found out would be to use vite-plugin-checker. It is less generic as it would only apply to vite projects but it might be simpler? WDYT? |
Yes, I think the vite-plugin-checker seems like a better option in this case. |
vite-plugin-checker after updating the plugins config as: // vite.config.ts
import { checker } from 'vite-plugin-checker';
// ...
plugins: [
checker({
typescript: {
root: `${process.cwd()}/path/to/app`,
tsconfigPath: 'tsconfig.app.json',
},
}),
viteTsConfigPaths({
root: '../../',
}),
], requires
edit: added |
A typecheck target could look like:
and maybe in that case you would not need that plugin? Or maybe I'm missing something. You can check out this PR which does something along these lines. |
Hey @mandarini do you want me to work on a PR along the lines of your last message? |
Hello @vicb ! Yes, sure, work on that PR! :) Thank you very much!!! |
We can probably use https://github.com/nrwl/nx/blob/master/packages/js/src/utils/typescript/run-type-check.ts I'll take a look at that next |
Any news regarding this https://github.com/nrwl/nx/blob/master/packages/js/src/utils/typescript/run-type-check.ts? |
According to the documentation https://nx.dev/nx-api/vite/executors/build#skiptypecheck it should just work. It has been added https://github.com/nrwl/nx/releases/tag/16.4.0-beta.3 |
I am closing this issue because indeed it should work, and we are shifting things around with targets, too, at the moment. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Description
It would be great to have a
typecheck
target when vite is used to check the types.Probably
build:production
should depend on this target.Motivation
If you create a vite app and set the content of main.ts to:
(Notice
"abc"
vs the expectednumber
type.)The
build
target will happily compiles this code.While it's great to skip type check in to have a better (=faster) dev experience there should be a way to check the types and it would be nice to do it when building the production configuration.
Suggested Implementation
Use
tsc --noEmit
to check types.The text was updated successfully, but these errors were encountered: