Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Using typescript transpiler for only .ts and .tsx files. #42

Closed
sainthkh opened this issue Apr 23, 2020 · 0 comments
Closed

Using typescript transpiler for only .ts and .tsx files. #42

sainthkh opened this issue Apr 23, 2020 · 0 comments

Comments

@sainthkh
Copy link
Contributor

sainthkh commented Apr 23, 2020

EDIT: I learned that the case below can be solved by adding downlevelIteration option. So, close this.

  • Operating System: N/A
  • Cypress Version: 4.4.1
  • Browser Version: N/A

Is this a Feature or Bug?

Bug

Current behavior:

In cypress-io/cypress#7098, test failed because the code below generates wrong ES5 code:

[...Array(100).keys()].map(x => x + "");
Array(100).keys().slice().map(function (x) { return x + ""; });

slice() doesn't exist in iterator. It's a failure. It happened because Cypress 4.4.1 transpiled the code with typescript.

It was a famous bug in microsoft/TypeScript#8856, and fixed in TypeScript 3.6.x. Unfortunately, it's still not working in typescript 3.8.3 (current).

I was naive. I thought everything that works fine in babel would work fine in typescript. They're different programs. It's a nonsense.

Desired behavior:

Currently, when typescript exists in the user's project folder, Cypress uses it to transpile every test file.

To solve this problem, we need to use typescript for .ts and .tsx files and babel for .js, .jsx.

I was worrying about the breaking change. But we can avoid it by adding typescriptOnly option. If it's true, every file will be transpiled with typescript when typescript exists. If not, only ts, tsx files will be transpiled with typescript.

If you agree with this idea, I'll go implement this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant