Skip to content

Typescript compiler flags error in generated forgotPassword.test.ts file #188

@roshan-sama

Description

@roshan-sama

What is the problem?

In line 12 of \app\auth\mutations\forgotPassword.test.ts, ...jest.requireActual("blitz")!, causes tsc to throw this error: Spread types may only be created from object types.ts(2698)

Seems like the issue is that spread types are not supported on generics (and I'm assuming that the jest.requireActual("blitz") call is returning an object, but the signature denotes that it's "unkown", which is what is causing the issue?
function jest.requireActual<unknown>(moduleName: string): unknown

There's an open issue at microsoft/TypeScript#10727, so this might not be a blitz related issue, but it may make sense to implement a workaround in the meanwhile

Paste all your error logs here:

tsc
app/auth/mutations/forgotPassword.test.ts:12:3 - error TS2698: Spread types may only be created from object types.

12   ...jest.requireActual("blitz")!,
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error

Paste all relevant code snippets here:

jest.mock("blitz", () => ({
  ...jest.requireActual("blitz")!,      <--------- This line
  generateToken: () => generatedToken,
}))

What are detailed steps to reproduce this?

  1. Download latest blitz, create a new app and run the tsc command

Run blitz -v and paste the output here:

Windows 10 | win32-x64 | Node: v15.8.0

blitz: 0.31.1 (global)
blitz: 0.31.1 (local)

  Package manager: yarn
  System:
    OS: Windows 10 10.0.18363
    CPU: (16) x64 AMD Ryzen 7 2700 Eight-Core Processor
    Memory: 5.49 GB / 15.93 GB
  Binaries:
    Node: 15.8.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.6.0 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  npmPackages:
    @prisma/client: ~2.17 => 2.17.0
    blitz: 0.31.1 => 0.31.1
    prisma: ~2.17 => 2.17.0
    react: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
    react-dom: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
    typescript: ~4.1 => 4.1.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions