You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'spec.cy.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
#23062
Closed
bryanltobing opened this issue
Aug 2, 2022
· 1 comment
@bryantobing12 to work around this, you could exclude all of the cypress files from your tsconfig.json, and then run separate npx tsc -p cypress/tsconfig.json --noEmit process to typecheck your Cypress files.
Unfortunately, there is nothing we can do to get rid of this error as cypress tests are not structured in such a way that makes the isolatedModules flag happy.
Current behavior
The error happened when I configured cypress with typescript and ran type check using
npx tsc --noEmit --incremental false
Desired behavior
There's no error
Test code to reproduce
I use nextjs.
and based on this example https://github.com/vercel/next.js/tree/canary/examples/with-cypress they solved it by adding
export {}
to every cypress.ts file which I think is ugly and can be easily forgotten.
https://github.com/vercel/next.js/blob/cd3e054f14ce38f4ff57c727a997da2a6e1d05dd/examples/with-cypress/cypress/e2e/app.cy.ts#L22-L23
My project can be tested here https://github.com/bryantobing12/next-boilerplate/tree/feat/cypress
pnpm install
pnpm type:check
The error will appear
Cypress Version
10.3.1
Other
What I have tried:
tsconfig.json
file as recommended here https://docs.cypress.io/guides/tooling/typescript-support#Configure-tsconfig-json.isolatedModules: false
to cypress/tsconfig.json. but the error won't disappear.The text was updated successfully, but these errors were encountered: