-
Notifications
You must be signed in to change notification settings - Fork 6
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
[Feature Request]: Check TypeScript types #63
Comments
I've seen there are a couple of interesting arguments such as There might be some probles in some Note: Removing the import might not be the solution because the import has to do with the UMD React error. More info at https://www.totaltypescript.com/react-refers-to-a-umd-global
In this case I think it's possible to resolve the problem by changing the {
"compilerOptions": {
"jsx": "react-jsx",
}
} Have you also considered to have I agree if a dep can be avoided the better. |
We could install the I'm wondering if we can solve the actual problem here. While we can implement a reusable-workflow I've following scenario: Filestest.scss foobarbaz [] test.ts import '../scss/test.scss';
class Foo {
constructor( private bar: string ) {}
}
new Foo( 1 ); "Linting"1. Running TSC $ tsc --noEmit --skipLibCheck resources/ts/*
resources/ts/test.ts:6:10 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
6 new Foo( 1 );
~
Found 1 error in resources/ts/test.ts:6 2. Running yarn build $ yarn build
// SNIP
Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: expected "{".
╷
1 │ foobarbaz []
│ ^
╵
resources\scss\test.scss 1:13 root stylesheet
// SNIP
./resources/ts/test.ts 6:9-10
[tsl] ERROR in {snip}\resources\ts\test.ts(6,10)
TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
2 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.88.2 compiled with 3 errors in 1684 ms CC @tyrann0us |
Yes, it doesn't make sense to check types in the project without Typescript. The issue is not about installing Typescript but about the command to check types.
Let's think about Typescript in the same ways as Psalm for PHP. |
We raised this upstream in WordPress/gutenberg#54305, which ideally will result in a new command for |
Just to give a short update. It seems like Gutenberg "eslintConfig": {
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
}
} I'm currently in discussion in WordPress/gutenberg#54305 , why they do |
I've rechecked the issue and tested WordPress/gutenberg#62925 alongside pure https://typescript-eslint.io/ locally and in the GitHub action environment. It doesn't fix the original problem of checking types during linting. The typescript-eslint/typescript-eslint#352 (comment) issue explains why. Moreover, the mentioned issue suggests to use TS compiler:
The same can be found in the documentation - https://typescript-eslint.io/rules/typedef/:
So in the end, using of Regarding additional compiler options I think the best if we would run the type check command with the same options as we have in |
Thank you for your investigation! As discussed, please investigate the feasibility/possibility of adding typechecking to Gutenberg or rather |
I've invested time in checking how type-checking happens inside Gutenberg. The Gutenberg repository has "Static Analysis (Linting, License, Type checks...)" workflow with "Type checking" part - https://github.com/WordPress/gutenberg/blob/2e967be9e1928809841761744b4ed8c768f0a417/.github/workflows/static-checks.yml#L48-L49. This step Therefore, if Note to say the way the Gutenberg project and Syde company use Typescript is very different. We use |
Is your feature request related to a problem?
Not really. But now if have a TypeScript-based project there is no possibility to verify the type system before asset compiling. This means we can't leverage TypeScript checks during PRs review.
Describe the desired solution
The simplest solution is to run such a command:
tsc --noEmit -project ./tsconfig.eslint.json --skipLibCheck
. Sure will be nice to inline errors in the files view. But my quick GithHub search there is no maintained and ready-to-use GitHub action.Maybe we could check https://github.com/Arhia/action-check-typescript but there are a lot of issues without a respond.
So IMO small dependency-less command is better.
Describe the alternatives that you have considered
Do nothing.
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: