question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Opinionated TS transpilation without overrides is problematic

See original GitHub issue

Current behavior:

Cypress recently added better native support for TypeScript, a great step forward, thanks!

However, part of this process added the following defaults for ts-node:

https://github.com/cypress-io/cypress/blob/bdcfe42f790a6f0e73e8f4ae2133c62df2de349d/packages/server/lib/util/ts-node-options.js#L13

Specifically, esModuleInterop is problematic. This is an opinionated transpilation, and cannot be overridden. Typically when working working with a JS / TS mix, you can either use imports such as

import * as Foo from 'foo';

or you can enable esModuleInterop and do

import Foo from 'foo';

In my case, I chose the former, to reduce the “magic” that is done by the TypeScript compiler; however, because Cypress enforces the latter, I get lots of errors along the lines of

TypeError: Foo is not a function

Desired behavior:

A test frameworks authors should not enforce an opinion about how I build my application; this esModuleInterop value should be possible to override. I tried manually changing it by editing the downloaded Cypress JS code in ~/.cache, and the tests ran as expected.

Test code to reproduce

Working on a minimal reproduction, please give me a bit of time 😄

Versions

Cypress: 4.7.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
bahmutovcommented, Jun 3, 2020

I did move it, but this option was already there https://github.com/cypress-io/cypress/pull/7197/files#diff-0f01b0186fbd767d98bd689a60ddd05aL193

I do wonder if we really need it or not, and if we should overwrite it from the user’s TS config

1reaction
sainthkhcommented, Jun 19, 2020

The only block for me is to decide if it’s a breaking change or a bug. If it’s a bug, it can be fixed immediately. If it’s a breaking change, we need to wait for 5.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting a storm of "error TS5055" messages on every ...
This problem occurred because the TypeScript compiler tries to transpile everything, including files that are already JavaScript, in which case it ...
Read more >
How setting up unit tests with TypeScript - Medium
This approach will help you to set up an opinionated unit testing ... ts-node: allow to run .ts file by transpiling them on...
Read more >
TailwindCSS: Adds complexity, does nothing.
Some of the problems Tailwind shares with inline styles: It's WET, not DRY. When you want to change your site styling in a...
Read more >
Compiling and bundling TypeScript libraries with Webpack
Since I started working on UI-Router React I've been enjoying writing TypeScript. There are both advantages and disadvantages working with a typed and ......
Read more >
You might not need to transpile your JavaScript - freeCodeCamp
The future without Transpilation · Configuring Webpack/Browserify is an unnecessary tax in many cases · Debugging using sourcemaps is always ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found