From 7bbd239fe7e6d72ef467484619b978c11f5fbb70 Mon Sep 17 00:00:00 2001 From: Parbez Date: Mon, 13 Feb 2023 07:04:32 +0530 Subject: [PATCH] fix: proper check for plugin in tsconfig (#45831) `plugin` is a key of `tsconfig.compilerOptions` ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) --------- --- .../next/src/lib/typescript/writeConfigurationDefaults.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/next/src/lib/typescript/writeConfigurationDefaults.ts b/packages/next/src/lib/typescript/writeConfigurationDefaults.ts index a22ccf02da..92ff58591d 100644 --- a/packages/next/src/lib/typescript/writeConfigurationDefaults.ts +++ b/packages/next/src/lib/typescript/writeConfigurationDefaults.ts @@ -198,7 +198,10 @@ export async function writeConfigurationDefaults( // If the TS config extends on another config, we can't add the `plugin` field // because that will override the parent config's plugins. // Instead we have to show a message to the user to add the plugin manually. - if ('extends' in userTsConfig && !('plugins' in userTsConfig)) { + if ( + 'extends' in userTsConfig && + !('plugins' in userTsConfig.compilerOptions) + ) { console.log( `\nYour ${chalk.cyan( 'tsconfig.json'