next.js
next.js copied to clipboard
Changes to `compilerOptions` in `tsconfig.json` don't get picked up by subsequent `yarn build` runs
Verify canary release
- [X] I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Wed Feb 19 06:37:35 UTC 2020
Binaries:
Node: 16.13.1
npm: 8.1.2
Yarn: 1.22.18
pnpm: 6.11.0
Relevant packages:
next: 12.1.7-canary.0
react: 18.1.0
react-dom: 18.1.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Changes to compilerOptions
in tsconfig.json
don't get picked up by subsequent runs of yarn build
, unless .next/cache/.tsbuildinfo
is deleted after the changes.
Expected Behavior
Changes to tsconfig.json
should be detected and subsequent yarn build
runs should use the updated config.
To Reproduce
-
Create new next.js app with typescript:
yarn create next-app --typescript
-
cd
into project directory and update version tonext@canary
:cd my-app yarn add next@canary
-
Use some typescript feature that needs enabling by a compiler option, eg. Update
pages/api/hello.ts
to use iterator spreading, which requiresdownlevelIteration
option:// Next.js API route support: https://nextjs.org/docs/api-routes/introduction import type { NextApiRequest, NextApiResponse } from "next"; type Data = { name: string; numbers: number[]; }; const numbers = new Set([1, 2, 3]); export default function handler( req: NextApiRequest, res: NextApiResponse<Data> ) { res.status(200).json({ name: "John Doe", numbers: [...numbers] }); }
-
Run
yarn build
. As expected this fails:$ yarn build yarn run v1.22.18 $ next build Failed to compile. ./pages/api/hello.ts:15:57 Type error: Type 'Set<number>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. 13 | res: NextApiResponse<Data> 14 | ) { > 15 | res.status(200).json({ name: "John Doe", numbers: [...numbers] }); | ^ 16 | } 17 | error Command failed with exit code 1.
-
Add
"downlevelIteration": true
tocompilerOptions
intsconfig.json
, and re-runyarn build
. This fails with the same error as above. -
Delete the
.tsbuildinfo
file:rm .next/cache/.tsbuildinfo
-
Re-run
yarn build
. This time it runs successfully.
@jaclarke can you try adding the following to your tsconfig?
"compilerOptions": {
"target": "es5",
"experimentalDecorators": true,
"downlevelIteration": true,
}
This worked well for me
Please verify that your issue can be recreated with next@canary
.
Why was this issue marked with the please verify canary
label?
We noticed the provided reproduction was using an older version of Next.js, instead of canary
.
The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. You can think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces by running npm install next@canary
and test it in your project, using your reproduction steps.
If the issue does not reproduce with the canary
version, then it has already been fixed and this issue can be closed.
How can I quickly verify if my issue has been fixed in canary
?
The safest way is to install next@canary
in your project and test it, but you can also search through closed Next.js issues for duplicates or check the Next.js releases. You can also use the GitHub template (preferred), or the CodeSandbox or StackBlitz templates to create a reproduction with canary
from scratch.
My issue has been open for a long time, why do I need to verify canary
now?
Next.js does not backport bug fixes to older versions of Next.js. Instead, we are trying to introduce only a minimal amount of breaking changes between major releases.
What happens if I don't verify against the canary version of Next.js?
An issue with the please verify canary
that receives no meaningful activity (e.g. new comments that acknowledge verification against canary
) will be automatically closed and locked after 30 days.
If your issue has not been resolved in that time and it has been closed/locked, please open a new issue, with the required reproduction, using next@canary
.
I did not open this issue, but it is relevant to me, what can I do to help?
Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please do not comment "I have the same issue" without repro steps). Then, we can sort issues by votes to prioritize.
I think my reproduction is good enough, why aren't you looking into it quicker?
We look into every Next.js issue and constantly monitor open issues for new comments.
However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.
Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.
Useful Resources
This issue has been automatically closed because it wasn't verified against next@canary. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.