Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript 4.9 syntax satisfies doesn't appear to work #1133

Closed
blixt opened this issue Nov 24, 2022 · 4 comments · Fixed by #1122
Closed

TypeScript 4.9 syntax satisfies doesn't appear to work #1133

blixt opened this issue Nov 24, 2022 · 4 comments · Fixed by #1122
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked cat: typings 👮 Typescript types related issues needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@blixt
Copy link

blixt commented Nov 24, 2022

Environment

  • Linaria version: @linaria/core v4.2.2 @linaria/esbuild v4.2.2
  • Bundler (+ version): esbuild 0.15.15
  • Node.js version: v19.1.0
  • OS: macOS 13.0.1

Description

The Linaria plugin fails with the following error on a line of code with the syntax const something = { … } satisfies MyType:

 ✘ [ERROR] [plugin linaria] Transform failed with 1 error:
 …/src/app/fresco/src/components/Theme.styles.ts:13:85: error: Expected ";" but found "satisfies"

     ../fresco/src/components/FrescoSettings.tsx:2:7:
       2 │ import "../components/Theme.styles";
         ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   This error came from the "onLoad" callback registered here:

     ../../../node_modules/@linaria/esbuild/dist/index.js:71:12:
       71 │       build.onLoad({ filter: /\.(js|jsx|ts|tsx)$/ }, async (args) ...
          ╵             ~~~~~~

     at setup (…/node_modules/@linaria/esbuild/dist/index.js:71:13)
     at handlePlugins (…/node_modules/esbuild/lib/main.js:1251:21)
     at buildOrServeImpl (…/node_modules/esbuild/lib/main.js:942:5)
     at Object.buildOrServe (…/node_modules/esbuild/lib/main.js:750:5)
     at …/node_modules/esbuild/lib/main.js:2087:17
     at new Promise (<anonymous>)
     at Object.build (…/node_modules/esbuild/lib/main.js:2086:14)
     at build (…/node_modules/esbuild/lib/main.js:1933:51)
     at buildApp (…/src/app/vekter/esbuild/vekter.esbuild.js:165:12)

Reproducible Demo

import { css } from "@linaria/core"

interface ColorTokenMap {
    primary: string
    secondary: string
}

const lightTokens = {
    primary: "#111",
    secondary: "#09f",
} satisfies ColorTokenMap

export const text = css`
    color: ${lightTokens.primary};
`
@blixt blixt added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Nov 24, 2022
@github-actions github-actions bot added cat: typings 👮 Typescript types related issues and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Nov 24, 2022
@Anber Anber closed this as completed in 5edde64 Nov 27, 2022
@Anber
Copy link
Collaborator

Anber commented Nov 27, 2022

Hi @blixt!

The used babel version was a bit outdated. I've upgraded it to the latest one which doesn't have problems with TS4.9.

@blixt
Copy link
Author

blixt commented Nov 28, 2022

Thank you! I noticed now upgrading to everything latest that I still get this issue. Did you close it before releasing the fix?

@blixt
Copy link
Author

blixt commented Nov 28, 2022

Okay so I forced @babel/core to be the latest version in my repo and this error still happens, so I don't think that was enough.

I think this is due to #1139 actually, and it's forcefully holding back esbuild to an old version, when it should use the one of the caller. I tried forcing a resolution to the latest esbuild and the error does indeed go away. So I think the solution is to make that plugin not bundle its own esbuild which will also speed up installation of the package, and reduce maintenance of this repo!

@Anber
Copy link
Collaborator

Anber commented Nov 29, 2022

Did you close it before releasing the fix?

Yeah… GitHub automatically closes all issues that are mentioned in PR as fixed.
I've added a test that checks compatibility with the new TS. I believe the fix will work for you when it is released (which will happen in the next day or two).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked cat: typings 👮 Typescript types related issues needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants