-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
TypeScript 5 support: "allowImportingTsExtensions": true
causing Cypress configuration error
#26148
Comments
I have a hunch that Cypress may not be passing along all
|
I have forked the test repo showing my case: https://github.com/MattyBalaam/cypress-ts-import |
"allowImportingTsExtensions": true
causing Cypress configuration error"allowImportingTsExtensions": true
causing Cypress configuration error
I reproduced, slightly different error:
|
We grab the user's tsconfig compiler options: https://github.com/cypress-io/cypress/blob/98c855e462a47b778e56e033959e104dc78aeb5a/packages/server/lib/plugins/child/ts_node.js#LL37C34-L37C62 So this should "just work". I tried importing |
Error is throw here:
I will continue investigating. |
I have similar problem after updating to TS 5.0, for us it seems the new
I assume this is related, but please let me know if I should create a new issue for it instead! |
@lmiller1990 as you asked for in #24818: Here is the component code that fails on TypeScript 5.0
Error is:
|
Thanks! Seems TS 5 broke quite a few things, hopefully we can get it fixed in the next week or two. |
I ran into this too and I found a workaround, but it only works if you don't have any tests written in TypeScript: set the environment variable cypress/packages/server/lib/util/resolve.js Lines 12 to 14 in 74ada11
|
I am working on fixing this now. This option is not even documented in the tsconfig documentation website yet, so I'll share my findings here since other people will inevitably be solving similar problems, either here or other tooling. Here's a minimal reproduction I made. {
"compilerOptions": {
"allowImportingTsExtensions": true,
"module": "ES2015",
"noEmit": true
}
} // foo.ts
export const foo = 'FOO' import { foo } from './foo.ts'
console.log({ foo })
Removing
transpileOnly there:
allowImportingTsExtensions and transpileOnly yet. I will learn more, I think we need to file an issue against ts-node, but we can probably work around this in the meantime in Cypress.
|
I filed an issue on ts-node: TypeStrong/ts-node#1981 |
@lmiller1990 Thanks! That appears to be a different issue than what's causing the "error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later" error that @MattyBalaam reported, which is what I'm stuck on. Specifically, that appears to be happening because of this line:
Should I file a separate issue for that? |
As a follow up, seems ts-loader also may be incompatible with this new Maybe instead of using the default webpack-preprocessor we ship, a webpack config with @MasonM yep, I think your issue is separate, you can file a new issue. It's in the "TypeScript 5 problems" bucket, but we should track and tackle it separately. I suspect that problem is easier to fix, now that I learned a bit about ts-node, and it's unrelated to the ts-loader issue. |
I tried defaulting to In the meantime, I will try to get a PR up fixing this (and hopefully the issue @MasonM files) and write some docs on how to use |
@lmiller1990 Thanks for the quick reply! I entered #26308 for the |
So for this error, relating to One workaround would be to remove Finally, if we do remove I think the correct course of action is to be good OSS citizens and patch I'm also curious on the use case for |
Oh, it looks like this is a bug in TypeScript. Seems like someone already as a PR open to fix it: microsoft/TypeScript#53599 If this is the fix, then the fix should be just waiting for the latest TS release. Cypress (and ts-node, and ts-loader) won't work with 5.0.2, so users will just need to update. |
I tried using the Ref: https://www.npmjs.com/package/typescript/v/5.1.0-dev.20230402 |
Will this be fixed as well? |
@mla-v-office not sure - we can find out, but from the stack trace, it looks like that's also an upstream issue in Is the reproduction just to a create a project with Edit: this won't fix that error, but that is also a bug in |
I feel like this error has multiple causes, but for me it went away with Typescript 5.0.4 (possibly microsoft/TypeScript#53611) |
Yep, this if fixed in TypeScript 5.0.4. |
Today, this '"allowImportingTsExtensions": true' option from the TS config file. // .eslintrc.js
{
"parserOptions": {
"project": ["./tsconfig.json"],
...
}
} It an error returned What interesting. At first, a project started to "yarn" and everything works. When i did the re-setting/reconfiguration was removed all the anyone familiar with the error? How to get around it? i just created a copy 'tsconfig.base.json' and included into the |
Current behavior
TypeScript 5.0 has an option for
allowImportingTsExtensions
, which allows writing imports with a.ts
or.tsx
extension.Currently, this breaks Cypress (both
npx cypress run
andnpx cypress open
) with the following error:This is failing even though
noEmit
is set totrue
.Screenshot
Desired behavior
Ideally, this wouldn't break Cypress.
Test code to reproduce
I created a repo at https://github.com/michaelhays/cypress-ts-import which demonstrates the bug.
Cypress Version
12.8.1
Node version
18.12.1
Operating System
Linux Mint 21.3
Debug Logs
Expand
The text was updated successfully, but these errors were encountered: