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

Bug: TypeError: tslib_1.__spreadArray is not a function #1478

Closed
MrDeerly opened this issue May 4, 2022 · 3 comments
Closed

Bug: TypeError: tslib_1.__spreadArray is not a function #1478

MrDeerly opened this issue May 4, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@MrDeerly
Copy link

MrDeerly commented May 4, 2022

Describe the bug
With the latest release (rc.21) test cases using the spread operator will fail because of TypeError: tslib_1.__spreadArray is not a function. The issue is most likely coming directly from tslib (see issue linked below) and was introduced with the latest update of tslib (8d27843).

To Reproduce
A reproduction can be a test case for a piece of code which uses a spread operator. Example:

 const funcToTest () => {
       const arr1 = [1, 2];
       const arr2 = [...arr1, 3];
       console.log(arr2)
}
...
 it('should do nothing' () => {
   ...
    console.log = jest.fn();
    const expectedOutput = [1, 2, 3]

    // invoke funcToTest in some nice way :) 

    expect(console.log).toHaveBeenCalledWith(expectedOutput);
   ...
}

TC will fail with TypeError: tslib_1.__spreadArray is not a function

Expected behavior
Test case should pass / using the spread operator shouldn't be an issue.

Related information:

  • @vue/test-utils version: 2.0.0-rc.21
  • Vue version: 3.2.33
  • node version: 18.1.0
  • npm (or yarn) version: 8.8.0

Additional context
It's probably upstreamed from microsoft/tslib#149

@MrDeerly MrDeerly added the bug Something isn't working label May 4, 2022
@cexbrayat
Copy link
Member

Hi @MrDeerly

I don't think this comes from VTU: rc.21 was still using tslib v2.3.1 (the commit you linked has not been released yet), and that shouldn't impact you anyway. Your project is probably using the faulty tslib version to compile the tests you wrote.
So I don't think we can do much here.

Try to check if your build/tooling is not relying on this version of tslib. You can probably force a resolution to use v2.3.1 until a fixed tslib is released.

If you really think this is caused by VTU, try to put together a small reproduction on github and we'll take a look.

@MrDeerly
Copy link
Author

MrDeerly commented May 4, 2022

Hey @cexbrayat,

understood, should've looked more closely on the timestamps... :) With that in mind the issue is definitely not coming from VTU.

Thanks alot for your time!

@MrDeerly
Copy link
Author

MrDeerly commented May 5, 2022

Just in case someone is experiencing the same issue, the broken tslib version is comming from @vue/cli-service:

├─┬ @vue/cli-service@5.0.4
│ └─┬ html-webpack-plugin@5.5.0
│   └─┬ html-minifier-terser@6.1.0
│     ├─┬ camel-case@4.1.2
│     │ ├─┬ pascal-case@3.1.2
│     │ │ ├─┬ no-case@3.0.4
│     │ │ │ ├─┬ lower-case@2.0.2
│     │ │ │ │ └── tslib@2.3.1 deduped
│     │ │ │ └── tslib@2.3.1 deduped
│     │ │ └── tslib@2.3.1 deduped
│     │ └── tslib@2.3.1
│     └─┬ param-case@3.0.4
│       ├─┬ dot-case@3.0.4
│       │ └── tslib@2.3.1 deduped
│       └── tslib@2.3.1 deduped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants