lukeed / tsm

TypeScript Module Loader
MIT License
1.19k stars 19 forks source link

Support TypeScript 4.9 `satisfies` operator #42

Closed karlhorky closed 1 year ago

karlhorky commented 1 year ago

Hi @lukeed 👋 Hope you are well.

It would be great to be able to use the TypeScript 4.9 satisfies operator!

However, currently, tsm throws an error when using satisfies:

import {AType} from '../a';

const a = 'abc' satisfies AType; // 💥 Expected ";" but found "satisfies"

Full error:

Error: R] Expected ";" but found "satisfies"

    /home/runner/work/courses/courses/packages/database/scripts/databaseFixtures/courseModules.ts:879:11:
      879 │ ] as const satisfies readonly CourseModule[];
          │            ~~~~~~~~~
          ╵            ;

/home/runner/work/courses/courses/node_modules/tsm/node_modules/esbuild/lib/main.js:1605
  let error = new Error(`${text}${summary}`);
              ^

This is supported in esbuild@^0.15.13


Workaround

Use Yarn/pnpm Resolutions (or npm Overrides) to force the version in package.json:

{
  "resolutions": {
    "**/tsm/esbuild": "0.15.14"
  }
}
karlhorky commented 1 year ago

Upgrading to a new esbuild version may also resolve #31

karlhorky commented 1 year ago

Thanks for 2d406efd5c1adceb4cc4894937ce61e3897c6165 @lukeed ! Will this be released in tsm@2.2.3?

lukeed commented 1 year ago

2.3.0 by eod

karlhorky commented 1 year ago

Nice, tsm@2.3.0 is working, thanks! 🙌