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

refactor: rename isAppDirEnabled to hasAppDir #62837

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/next/src/lib/typescript/writeAppTypeDeclarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export async function writeAppTypeDeclarations({
baseDir,
imageImportsEnabled,
hasPagesDir,
isAppDirEnabled,
hasAppDir,
}: {
baseDir: string
imageImportsEnabled: boolean
hasPagesDir: boolean
isAppDirEnabled: boolean
hasAppDir: boolean
}): Promise<void> {
// Reference `next` types
const appTypeDeclarations = path.join(baseDir, 'next-env.d.ts')
Expand Down Expand Up @@ -49,7 +49,7 @@ export async function writeAppTypeDeclarations({
directives.push('/// <reference types="next/image-types/global" />')
}

if (isAppDirEnabled && hasPagesDir) {
if (hasAppDir && hasPagesDir) {
directives.push(
'/// <reference types="next/navigation-types/compat/navigation" />'
)
Expand Down
12 changes: 6 additions & 6 deletions packages/next/src/lib/typescript/writeConfigurationDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function writeConfigurationDefaults(
ts: typeof import('typescript'),
tsConfigPath: string,
isFirstTimeSetup: boolean,
isAppDirEnabled: boolean,
hasAppDir: boolean,
distDir: string,
hasPagesDir: boolean
): Promise<void> {
Expand Down Expand Up @@ -184,27 +184,27 @@ export async function writeConfigurationDefaults(
const nextAppTypes = `${distDir}/types/**/*.ts`

if (!('include' in rawConfig)) {
userTsConfig.include = isAppDirEnabled
userTsConfig.include = hasAppDir
? ['next-env.d.ts', nextAppTypes, '**/*.ts', '**/*.tsx']
: ['next-env.d.ts', '**/*.ts', '**/*.tsx']
suggestedActions.push(
cyan('include') +
' was set to ' +
bold(
isAppDirEnabled
hasAppDir
? `['next-env.d.ts', '${nextAppTypes}', '**/*.ts', '**/*.tsx']`
: `['next-env.d.ts', '**/*.ts', '**/*.tsx']`
)
)
} else if (isAppDirEnabled && !rawConfig.include.includes(nextAppTypes)) {
} else if (hasAppDir && !rawConfig.include.includes(nextAppTypes)) {
userTsConfig.include.push(nextAppTypes)
suggestedActions.push(
cyan('include') + ' was updated to add ' + bold(`'${nextAppTypes}'`)
)
}

// Enable the Next.js typescript plugin.
if (isAppDirEnabled) {
if (hasAppDir) {
// Check if the config or the resolved config has the plugin already.
const plugins = [
...(Array.isArray(tsOptions.plugins) ? tsOptions.plugins : []),
Expand Down Expand Up @@ -248,7 +248,7 @@ export async function writeConfigurationDefaults(
// then set `strictNullChecks` to `true`.
if (
hasPagesDir &&
isAppDirEnabled &&
hasAppDir &&
userTsConfig.compilerOptions &&
!userTsConfig.compilerOptions.strict &&
!('strictNullChecks' in userTsConfig.compilerOptions)
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/lib/verify-typescript-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function verifyTypeScriptSetup({
baseDir: dir,
imageImportsEnabled: !disableStaticImages,
hasPagesDir,
isAppDirEnabled: hasAppDir,
hasAppDir,
})

let result
Expand Down
Loading