-
Playing around with ts-match, I get a type error in the Am I missing anything? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
TS-Pattern v5+ needs TypeScript v5 or higher and your project must be in strict mode. Can you confirm that your project has an expected config? |
Beta Was this translation helpful? Give feedback.
-
Yes, I can confirm that the project is using TypeScript version 5.3.3 and strict mode. I still get that type error. The official ts-match examples in codesandbox also get the same type error. |
Beta Was this translation helpful? Give feedback.
-
I'm pretty sure this is because codesandbox doesn't use TS v5+, const type parameters doesn't seem supported: See the syntax error here. All tests pass with TS v5.3.3 locally |
Beta Was this translation helpful? Give feedback.
-
Codesandbox uses TS 5.3.3. You can verify by inspecting the |
Beta Was this translation helpful? Give feedback.
-
I think the issue is the CodeSandbox TS integration, not TS itself. Everything runs fine. To corroborate what @gvergnaud said about These errors cause the declaration to fail, and |
Beta Was this translation helpful? Give feedback.
-
I switched the sandbox to a "devbox" and it seems like the editor is now using the version specified in the package.json and the issue is gone. @sgnix your editor is likely not using the latest typescript version, you should be able to fix that by clicking on "Select TypeScript Version" in VSCode's CMD+P menu. |
Beta Was this translation helpful? Give feedback.
-
All good now. It looks like my editor's LSP plugin had an outdated TS version. Thanks for your time! |
Beta Was this translation helpful? Give feedback.
I switched the sandbox to a "devbox" and it seems like the editor is now using the version specified in the package.json and the issue is gone.
@sgnix your editor is likely not using the latest typescript version, you should be able to fix that by clicking on "Select TypeScript Version" in VSCode's CMD+P menu.