-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Untyped JS module is not assignable to type even though it satisfies it #57460
Comments
This is a private repo or something: https://github.com/bradzacher/bug-repros/tree/ts-js-issue-huh |
oops sorry made it public |
the repro doesn't contain a concrete TS version and a tsconfig.json :P |
Yeah I know. The latter one is intentional. As for the TS version - I doubt it matters? I was just using whatever is installed in the latest vscode version. In the issue I linked a bigger repro if you want some more stuff (https://github.com/printfn/tseslint-react-repro). I was just trying to be as isolated as possible. |
There is some difference between my default and your default setups then because I don't get this error but rather this at the import statement:
We have to use different module resolutions for some reason. |
sod it, sorry @Andarist - I forgot to push a fix. |
I still get a different error:
|
Or this one: Could not find a declaration file for module 'eslint-plugin-react/configs/recommended.js'. '/repros/bug-repros/node_modules/eslint-plugin-react/configs/recommended.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/eslint-plugin-react` if it exists or add a new declaration (.d.ts) file containing `declare module 'eslint-plugin-react/configs/recommended.js';`ts(7016) I'm not sure what makes VS Code change its mind about which error is supposed to be displayed π This might depend on EDIT:// I think it might depend on |
Maybe there's some vscode settings that impact this? I spent a while playing around with a Can you give this repro a go? https://github.com/printfn/tseslint-react-repro |
No luck either even after disabling extensions. I downloaded the insiders version of VS Code and I managed to repro it there |
This should fix this incorrectly reported error: #57467 . However, it still won't typecheck in your case because this property from the source isn't compatible with your target: https://github.com/jsx-eslint/eslint-plugin-react/blob/36e791de784e7fa1edd5b6d232fbcaf2dd7cf9bf/configs/all.js#L28 Its type gets computed as |
If I locally modify my Unless I'm misunderstanding and you're saying that after your fix the record is inferred as that wide type? |
When doing just that (without applying my patch in tsserver, just removing that single line with Could you try hovering over |
Note: filed jsx-eslint/eslint-plugin-react#3694 to add some minimal JSDoc annotations which will short-circuit the TS inference and fix things. |
It just shows |
still the error disappeared though so your patch definitely was applied. I think you're getting hit by automatic type acquisition and TS is automatically pulling in Essentially without The JSDoc annotations I added in jsx-eslint/eslint-plugin-react#3695 will short-circuit TS's inference here so that ATA won't change the signature |
Yeah, that's probably it. Thanks for looking into this.
IIUC ATA might impact |
|
ah cool, I somehow missed that π |
π Search Terms
Untyped JS module is not assignable to type even though it satisfies it, "Object literal may only specify known properties"
β― Playground Link
https://github.com/bradzacher/bug-repros/tree/ts-js-issue-huh
π» Code
π Actual behavior
There should be no errors because the type
{ plugins: { react: { deprecatedRules: any; rules: any; }; }; }
is assignable to
{ plugins: { react: { rules: any; }; }; }
π Expected behavior
Additional information about the issue
This issue is particularly weird because it only occurs in a JS file!
For more context this is the original bug report typescript-eslint/typescript-eslint#8522
And the original repro from the issue (the usecase we really want to fix): https://github.com/printfn/tseslint-react-repro
We have built support for ESLint flat configs via our
typescript-eslint
package and it exports a function to allow typechecking of the config array. So the repo looks like thisBest I can tell it looks like TS is treating the
eslintReact
variable the same way it would as an inline object expression - hence it's erroring saying "too many properties".The text was updated successfully, but these errors were encountered: