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

Add TypeScript plugin #41569

Merged
merged 7 commits into from Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/next/lib/typescript/writeConfigurationDefaults.ts
Expand Up @@ -187,6 +187,27 @@ export async function writeConfigurationDefaults(
)
}

// Enable the Next.js typescript plugin.
if (isAppDirEnabled) {
if (userTsConfig.compilerOptions) {
if (!('plugins' in userTsConfig.compilerOptions)) {
userTsConfig.compilerOptions.plugins = []
}
if (
!userTsConfig.compilerOptions.plugins.some(
(plugin: { name: string }) => plugin.name === 'next'
)
) {
userTsConfig.compilerOptions.plugins.push({ name: 'next' })
suggestedActions.push(
chalk.cyan('plugins') +
' was updated to add ' +
chalk.bold(`{ name: 'next' }`)
)
}
}
}

if (!('exclude' in rawConfig)) {
userTsConfig.exclude = ['node_modules']
suggestedActions.push(
Expand Down
1 change: 1 addition & 0 deletions packages/next/lib/verifyTypeScriptSetup.ts
@@ -1,5 +1,6 @@
import chalk from 'next/dist/compiled/chalk'
import path from 'path'

import {
hasNecessaryDependencies,
NecessaryDependencies,
Expand Down