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.

Support Typescript 4

See original GitHub issue

Current Behavior

Creating a new project with the example code from the official release notes doesn’t work:

type Arr = readonly any[];

export function concat<T extends Arr, U extends Arr>(arr1: T, arr2: U): [...T, ...U] {
  return [...arr1, ...arr2];
}
$ yarn build
semantic error TS1256: A rest element must be last in a tuple type.
$ yarn lint
Parsing error: Cannot read property 'map' of undefined

Workaround

For the moment I managed to work around it by updating typescript and typescript-eslint and forcing the resolutions:

$ yarn add --dev typescript@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest
// package.json

"resolutions": {
  "**/typescript": "^4.0.5",
  "**/@typescript-eslint/eslint-plugin": "^4.6.1",
  "**/@typescript-eslint/parser": "^4.6.1"
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:25
  • Comments:14

github_iconTop GitHub Comments

28reactions
utkarshkukreticommented, Dec 29, 2020

For anyone interested, here’s the updated resolutions workaround I’m using for latest typescript and jest.

I’m using it in a new project and everything seems to be working fine; I’ll update if anything breaks.

  "resolutions": {
    "**/@typescript-eslint/eslint-plugin": "^4.11.1",
    "**/@typescript-eslint/parser": "^4.11.1",
    "**/jest": "^26.6.3",
    "**/ts-jest": "^26.4.4",
    "**/typescript": "^4.1.3"
  }
9reactions
stephenhcommented, Mar 9, 2021

We’re prototyping a new project on tsdx and after an ~hour of fighting “why does jsxImportSource” not work (for emotion setup), it turns out tsdx was using its own shadowed version of TypeScript. Pretty frustrating. Personally I’m close to moving off tsdx, but for now we can switch from npm to yarn and use the ^ resolutions.

All of the projects in our company are on TS 4.x and prettier 2.x, so kinda surprised to see tsdx behind on these.

Granted, it’s open source / it’s free / etc. 😃, so I’m looking forward to liking/using tsdx going forward, but just reporting back today’s frustrations from the field.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 4.4
Symbol and Template String Pattern Index Signatures. TypeScript lets us describe objects where every property has to have a certain type using index...
Read more >
Documentation - TypeScript 4.0
Variadic Tuple Types. Consider a function in JavaScript called concat that takes two array or tuple types and concatenates them together to make...
Read more >
Documentation - TypeScript 4.5
To ensure that TypeScript and JavaScript support works well out of the box, TypeScript bundles a series of declaration files ( .d.ts files)....
Read more >
Documentation - TypeScript 4.7
ECMAScript Module Support in Node.js. For the last few years, Node.js has been working to support ECMAScript modules (ESM). This has been a...
Read more >
Documentation - TypeScript 4.3
That's why TypeScript 4.3 allows you to specify types for reading and writing to ... In fact, we've added syntax to interfaces/object types...
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