Skip to content

Commit

Permalink
chore: make eslint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Dec 22, 2022
1 parent 1fd6978 commit 27b3126
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions packages/next/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,45 @@ function setFontLoaderDefaults(config: NextConfigComplete) {
} catch {}
}

function warnOptionHasBeenMovedOutOfExperimental(
config: NextConfig,
key: keyof NextConfigComplete['compiler'],
configFileName: string,
isCompilerFeature: true
): NextConfig
function warnOptionHasBeenMovedOutOfExperimental(
config: NextConfig,
key: keyof NextConfigComplete,
configFileName: string,
isCompilerFeature: false
): NextConfig
function warnOptionHasBeenMovedOutOfExperimental(
config: NextConfig,
key: keyof NextConfigComplete['compiler'] | keyof NextConfigComplete,
configFileName: string,
isCompilerFeature: boolean
): NextConfig {
if (config.experimental && key in config.experimental) {
Log.warn(
`\`${key}\` has been moved out of \`experimental\`${
isCompilerFeature ? ' and into `compiler`' : ''
}. Please update your ${configFileName} file accordingly.`
)
if (isCompilerFeature) {
config.compiler = config.compiler || {}
// TODO: remove "as" once TypeScript supports type narrowing in overloaded functions
// https://github.com/microsoft/TypeScript/issues/22609
config.compiler[key as keyof NextConfigComplete['compiler']] = (
config.experimental as any
)[key]
} else {
config[key] = (config.experimental as any)[key]
}
}

return config
}

function assignDefaults(dir: string, userConfig: { [key: string]: any }) {
const configFileName = userConfig.configFileName
if (typeof userConfig.exportTrailingSlash !== 'undefined') {
Expand Down Expand Up @@ -935,42 +974,3 @@ export default async function loadConfig(
setFontLoaderDefaults(completeConfig)
return completeConfig
}

function warnOptionHasBeenMovedOutOfExperimental(
config: NextConfig,
key: keyof NextConfigComplete['compiler'],
configFileName: string,
isCompilerFeature: true
): NextConfig
function warnOptionHasBeenMovedOutOfExperimental(
config: NextConfig,
key: keyof NextConfigComplete,
configFileName: string,
isCompilerFeature: false
): NextConfig
function warnOptionHasBeenMovedOutOfExperimental(
config: NextConfig,
key: keyof NextConfigComplete['compiler'] | keyof NextConfigComplete,
configFileName: string,
isCompilerFeature: boolean
): NextConfig {
if (config.experimental && key in config.experimental) {
Log.warn(
`\`${key}\` has been moved out of \`experimental\`${
isCompilerFeature ? ' and into `compiler`' : ''
}. Please update your ${configFileName} file accordingly.`
)
if (isCompilerFeature) {
config.compiler = config.compiler || {}
// TODO: remove "as" once TypeScript supports type narrowing in overloaded functions
// https://github.com/microsoft/TypeScript/issues/22609
config.compiler[key as keyof NextConfigComplete['compiler']] = (
config.experimental as any
)[key]
} else {
config[key] = (config.experimental as any)[key]
}
}

return config
}

0 comments on commit 27b3126

Please sign in to comment.