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 compilerOptions not reflected #7188
Comments
Checking types slows down the transpilation. That's why Cypress ignores type checks and delegate that to other tools like It's an intended feature, not a bug. |
I understand that Cypress wants to be fast. But it in this case it does not make a sense. 1. Type checks are the reason why use TypeScript. Consider this as a bug, not as a feature, because embedded TypeScript whithout type checks I defined in tsconfig.json is not usable. It has no sense and I still have to setup webpack preprocessor, so finally compile it twice... |
1. I agree type checks are the reason why we use TypeScript. But tsc can do the job. Cypress doesn't have to do it again. |
As I read about the API in the link above, it allows you to read external tsconfig file... or I think it is also possible to just parse compiler options and provide it to TS API, if Cypress wants to manage the rest of configuration. For me and I am sure not just for me it would be awesome to not need any other webpack preprocessor. So what exactly is the problem in allowing this? |
If type check is built in by default, you always need to wait for 6-10 seconds to run a test suite after each change in files. I don't think it's not a good default option. Right? |
It is the same time I would wait with webpack-preprocessor plugin - so it is not a problem. |
You say built in by default ... I think this could be just optional/configurable feature. So apart of this. Is there any other problem? |
For some people, that time difference is huge. Without type checking, Cypress is already running after file changes. But with type checking, I need to wait for a few seconds each time to see Cypress working. It's that difference. The goal of Cypress is to help developers do e2e tests, not checking types real time. And that real time thing is done by editors. And you want Cypress to find type errors, but it cannot find the type errors across the entire project even if we sacrifice the response time and add type checking. It can just find type errors in the test file you're running and type errors in the file you imported to that test file. Unfortunately, Cypress TypeScript parser cannot do the job you want. EDIT: And you're saying making it configurable. That's the job of those preprocessors I mentioned above. |
For me it would be enough to have type check for current test file and all its dependencies. This is also exactly what the webpack preprocessor does. VS code doesn't show you possible problems in dependcies if you don't open it. As I said... it could by just optional. Then it would be on preference of each developer - speed vs type safety. I see embedded TypeScript as awesome feature and as a big step forward. But without such possiblity it has no added value for me. It would cause hidden problems and postpone tsc check to CI is not solution, it is too late. |
Just a question: preprocessors can do everything you said. But why do you want an official Cypress option for the job? |
Because of the simplicity. You have one, widely used, opinionated solution. The standard way. With webpack preprocessor you have to maintain also You have to do this accross all projects, plugins etc. I was enthusiastic when I was removing these things from my projects and dissapointed when I noticed I have to return them back... |
Now I get it. One of the reason I added out-of-the-box typescript support is to remove that tediousness. Maybe I forgot how frustrating it was. But adding global option to the project isn't the thing I can't decide alone as a collaborator. I need to discuss with other members first. |
Thank you very much. I wait for the result with big hope. |
After reading through this issue, I'm a bit confused about whether Cypress uses a user-supplied The updated Typescript docs mention configuring a Is that correct? If so, the docs should perhaps make this a bit clearer. The reason I'm interested is that my existing config for resolve: {
...
modules: [
path.resolve(__dirname, "support"),
...
]
} This allows test files in // cypress/support/utils.ts
export function foo() { ... };
// cypress/integration/test.ts
import { foo } from "utils"; // <- webpack resolves this to cypress/support/utils.ts With built-in Typescript support, I was hoping to remove webpack-preprocessor and achieve the same with this in my {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": [
"support/*"
]
}, Unfortunately with webpack-preprocessor removed, when Cypress runs my specs, I get errors like:
After reading this issue, I'm starting to think that the problem is the |
It doesn't, unfortunately. I hope it will be added in next version. |
Hi all, any update or plans on this issue? |
My current focus is #7716. Maybe I'll try to start the discussion after that. But don't get your hope high yet. Things can change. |
@scottohara Since nothing really changed here but I think more people will have this issue: Was there any way around this?
|
Hey @DarkMikey, in my case the only compiler options I needed Cypress to read from my // cypress/integration/test.ts
import { foo } from "utils"; // <- I want this to resolve to cypress/support/utils.ts The workaround for me (while awaiting Cypress support) was to simply switch to a relative import path specifier, e.g. // cypress/integration/test.ts
import { foo } from "../support/utils"; If, like the OP, you need Cypress to recognise other compiler options such as Hope this helps. |
Thank you very much. You're the first one I've found that has the exact same problem. Have you already opened an own issue (since this could be differently to the OPs problem)? The thing is, if I import Apparently this took me way too long to debug. Like @scottohara already suggested please mention something in the docs! In my desperation I've also opened a SO question yesterday. |
There are 2 different issues here:
|
@chrisbreiding it seems like even in v5.1 Cypress is still not properly loading the user's And that's still reproducible using the original repro, Cypress |
@DarkMikey Do you have a fix? Am I missing something obvious here? |
@nicholaschiang Path aliases were fixed for spec files, which are bundled for the browser, but still don't work for the plugins file, which is run in Node. I opened a new issue for this: #8555 |
In regards to the original issue, Cypress now supports most compiler options for spec files, but will continue to only transpile files by default and not type check them for performance reasons, so setting We do not plan to add a global option to configure this, as it can be accomplished through the preprocessor API. |
I still don't understand where is the problem in allowing it. |
Cypress TypeScript compilator probably do not reflects some of
compilerOptions
. In my case it looks like e.g.strict
is ignored.I am sure that my
tsconfig.json
is the one which is used because e.g. I have forgotten"noEmitHelpers": true
and it raised errors so I needed to remove it.It was working with webpack compiler.
Current behavior:
tsconfig.json:
test:
VS Code reflects
tsconfig.json
and shows error:Cypress run doesn't reflects
tsconfig.json
and successfully compiles script.Desired behavior:
Cypress also reflects
tsconfig.json
and shows error:Versions
4.5.0
The text was updated successfully, but these errors were encountered: