lukeed / lukeed/tsm

Upgrade `esbuild` for const type parameters?

Open
#48 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Hey @lukeed 👋 hope you're well!

It seems that [`esbuild@0.17.14`](https://github.com/evanw/esbuild/releases/tag/v0.17.14) added support for [TS 5.0 `const` type parameters](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#const-type-parameters)

Currently, `tsm@2.3.0` [depends on `esbuild@^0.15.16`](https://github.com/lukeed/tsm/blob/13b1512cfeab184e5b7f0afc1d579fe407e304e7/package.json#L35-L37), and runs into errors like `Expected identifier but found "const"`:

```
✘ [ERROR] Expected identifier but found "const"

/Users/k/p/project/index.ts:29:40:
29 │ export async function getProjectFixture(
╵ ~~~~~

/Users/k/p/project/node_modules/tsm/node_modules/esbuild/lib/main.js:1575
let error = new Error(`${text}${summary}`);
^

Error: Transform failed with 1 error:
/Users/k/p/project/index.ts:29:40: ERROR: Expected identifier but found "const"
at failureErrorWithLog (/Users/k/p/project/node_modules/tsm/node_modules/esbuild/lib/main.js:1575:15)
at /Users/k/p/project/node_modules/tsm/node_modules/esbuild/lib/main.js:814:29
at responseCallbacks. (/Users/k/p/project/node_modules/tsm/node_modules/esbuild/lib/main.js:680:9)
at handleIncomingPacket (/Users/k/p/project/node_modules/tsm/node_modules/esbuild/lib/main.js:735:9)
at Socket.readFromStdout (/Users/k/p/project/node_modules/tsm/node_modules/esbuild/lib/main.js:656:7)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
```

## Proposed Solution

What do you think about upgrading to `esbuild@^0.18.6`?

Seems like forcing the upgrade to the transitive `esbuild` dependency via [Yarn Resolutions](https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/) works in our project and enables the `const` type parameters 👍

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the esbuild dependency entry in package.json and compare the current constraint with the proposed ^0.18.6 upgrade. Verify the reported TypeScript const type parameter example no longer produces the parsing error after the dependency change.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.