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

Transform fails with Unexpected "..." #10501

Closed
7 tasks done
IMax153 opened this issue Oct 17, 2022 · 3 comments · Fixed by #11908
Closed
7 tasks done

Transform fails with Unexpected "..." #10501

IMax153 opened this issue Oct 17, 2022 · 3 comments · Fixed by #11908
Labels
bug: upstream Bug in a dependency of Vite p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@IMax153
Copy link

IMax153 commented Oct 17, 2022

Describe the bug

When running vitest, annotating the following re-exported function with it's type:

/**
 * Constructs a tuple of results from a tuple of `SafeEval`s.
 *
 * @since 1.0.0
 * @category constructors
 */
export const tuple: <EN extends ReadonlyArray<SafeEval<any>>>(
  ...[e1, e2, ...es]: EN & {
    readonly 0: SafeEval<any>
    readonly 1: SafeEval<any>
  }
) => SafeEval<Readonly<{ [K in keyof EN]: [EN[K]] extends [SafeEval<infer A>] ? A : never }>> =
  SE.tuple

causes vitest to fail with the following error:

❯ failureErrorWithLog node_modules/.pnpm/esbuild@0.15.11/node_modules/esbuild/lib/main.js:1566:15
Error: Transform failed with 1 error:
/workspace/data/src/SafeEval.ts:86:2: ERROR: Unexpected "..."
❯ node_modules/.pnpm/esbuild@0.15.11/node_modules/esbuild/lib/main.js:805:29
❯ responseCallbacks.<computed> node_modules/.pnpm/esbuild@0.15.11/node_modules/esbuild/lib/main.js:671:9
❯ handleIncomingPacket node_modules/.pnpm/esbuild@0.15.11/node_modules/esbuild/lib/main.js:726:9
❯ Socket.readFromStdout node_modules/.pnpm/esbuild@0.15.11/node_modules/esbuild/lib/main.js:647:7
❯ Socket.emit node:events:513:28

The error references an Unexpected "..." in the type annotation (preceding the tuple parameter) even though this is perfectly valid typescript.

Removing the type annotation causes tests to pass successfully:

/**
 * Constructs a tuple of results from a tuple of `SafeEval`s.
 *
 * @since 1.0.0
 * @category constructors
 */
export const tuple = SE.tuple

Downstream issue for reference: vitest-dev/vitest#2157

Reproduction

https://gitpod.io/#https://github.com/fp-ts/data

Steps to reproduce

Navigate to the following GitPod url:

https://gitpod.io/#https://github.com/fp-ts/data

Add the type annotation to tuple in the SafeEval module here.

Run pnpm install followed by pnpm test.

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (16) x64 AMD EPYC 7B13
    Memory: 41.06 GB / 62.80 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm
  npmPackages:
    vite: ^2.9.13 => 2.9.15 
    vitest: 0.24.3 => 0.24.3

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red
Copy link
Member

Because this happens only with esbuild, this is an upstream issue. Please create an issue to esbuild.

reproduction
ts playground

@sapphi-red sapphi-red added bug: upstream Bug in a dependency of Vite p3-minor-bug An edge case that only affects very specific usage (priority) labels Oct 17, 2022
@evanw
Copy link

evanw commented Feb 20, 2023

The fix for this has been published by the way. Thanks for reporting it in the esbuild repo.

@bluwy bluwy linked a pull request Feb 20, 2023 that will close this issue
9 tasks
@sapphi-red
Copy link
Member

Thanks for the fix 💚

@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants