Support Typescript 4
See original GitHub issueCurrent 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:
- Created 3 years ago
- Reactions:25
- Comments:14
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.