Closed ndrbrt closed 4 years ago
I'll have to look into it later, but it sounds like this might be related to TypeScript's downlevelIteration
, for which there's this issue: https://github.com/jaredpalmer/tsdx/issues/376 .
That should behave the same between tsc
and tsdx
though 🤔
Yes thank you, I did see #376, even though actually I solved my own issue by just using "option B".
I opened this one though, because, as you pointed out, I find it strange the inconsistency between tsc
and tsdx
I think it might be that the tsconfig
target
matters to TS for this transform; per the docs, it sounds like it only does something when targeting ES5
or below.
TSDX ignores your setting and forces target
to ESNext
and transpiles the rest down with @babel/preset-env
, so that's probably the difference unless you're not using target
?
Per https://github.com/jaredpalmer/tsdx/issues/376#issuecomment-566750042, it sounds like adding @babel/preset-env
with loose: false
to your babelrc
should make it transpile down
Also if you're transpiling to Node (and not browser), there's a relevant TSDX flag mentioned in that issue too -- tsdx build --target node
Current Behavior
Suppose we have this code:
If I run the code within a test with
yarn test
(i.e.tsdx test
), everything is fine and the output is:If I build the library and import it in node, though, I get something different:
Expected behavior
I'd expect the built library imported in node to behave as it does in the tests:
Additional context
tsc test.ts
and thennode test.js
)arr3 = [...arr1, ...arr2]
) and it worksYour environment