Unverified Commit 1b105f44 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Make NextConfigComplete typing more accurate (#96700)

These properties were previously typed as always set in
`NextConfigComplete`. But in reality, they can be optional.
```
    | 'expireTime'
    | 'output'
    | 'modularizeImports'
    | 'allowedDevOrigins'
    | 'adapterPath'
```
I couldn't find a better way to fix this than listing them out
explicitly
parent 6324fdba
...@@ -304,7 +304,7 @@ export function getDefineEnv({ ...@@ -304,7 +304,7 @@ export function getDefineEnv({
...getImageConfig(config, dev), ...getImageConfig(config, dev),
'process.env.__NEXT_ROUTER_BASEPATH': config.basePath, 'process.env.__NEXT_ROUTER_BASEPATH': config.basePath,
'process.env.__NEXT_HAS_REWRITES': hasRewrites, 'process.env.__NEXT_HAS_REWRITES': hasRewrites,
'process.env.__NEXT_CONFIG_OUTPUT': config.output, 'process.env.__NEXT_CONFIG_OUTPUT': config.output || '',
'process.env.__NEXT_I18N_SUPPORT': !!config.i18n, 'process.env.__NEXT_I18N_SUPPORT': !!config.i18n,
'process.env.__NEXT_I18N_DOMAINS': config.i18n?.domains ?? false, 'process.env.__NEXT_I18N_DOMAINS': config.i18n?.domains ?? false,
'process.env.__NEXT_I18N_CONFIG': config.i18n || '', 'process.env.__NEXT_I18N_CONFIG': config.i18n || '',
......
...@@ -38,36 +38,55 @@ export type PrefetchInliningConfig = ...@@ -38,36 +38,55 @@ export type PrefetchInliningConfig =
| { maxSize: number; maxBundleSize: number } | { maxSize: number; maxBundleSize: number }
export type NextConfigComplete = Required< export type NextConfigComplete = Required<
Omit<NextConfig, 'configFile' | 'cacheLife'> Omit<
> & { NextConfig,
images: Required<ImageConfigComplete> | 'configFile'
typescript: TypeScriptConfig | 'cacheLife'
configFile: string | undefined | 'expireTime'
configFileName: string | 'output'
// Normalized by config.ts: the `default` profile is backfilled to be complete | 'modularizeImports'
// (see `ResolvedCacheLifeProfiles`), unlike the optional/partial user input. | 'allowedDevOrigins'
// Omitted from the base so this is a clean replacement, not an intersection. | 'adapterPath'
cacheLife: ResolvedCacheLifeProfiles >
// override NextConfigComplete.experimental.htmlLimitedBots to string > &
// because it's not defined in NextConfigComplete.experimental // Don't apply `Required<>` for these properties. They really can be undefined in the finalized config.
htmlLimitedBots: string | undefined Pick<
experimental: ExperimentalConfig & { NextConfig,
// Normalized by config.ts: true and partial objects become resolved objects | 'cacheLife'
prefetchInlining?: PrefetchInliningConfig | 'expireTime'
// Normalized by config.ts: defaulted to 90% of staticPageGenerationTimeout | 'output'
useCacheTimeout: number | 'modularizeImports'
// Normalized by config.ts `finalizeConfig`: defaulted to `'warning'` | 'allowedDevOrigins'
instantInsights: { validationLevel: ValidationLevel } | 'adapterPath'
// Normalized by finalized config with a default and the expected type > & {
turbopackMemoryEvictionMode: MemoryEvictionMode images: Required<ImageConfigComplete>
typescript: TypeScriptConfig
configFile: string | undefined
configFileName: string
// Normalized by config.ts: the `default` profile is backfilled to be complete
// (see `ResolvedCacheLifeProfiles`), unlike the optional/partial user input.
// Omitted from the base so this is a clean replacement, not an intersection.
cacheLife: ResolvedCacheLifeProfiles
// override NextConfigComplete.experimental.htmlLimitedBots to string
// because it's not defined in NextConfigComplete.experimental
htmlLimitedBots: string | undefined
experimental: ExperimentalConfig & {
// Normalized by config.ts: true and partial objects become resolved objects
prefetchInlining?: PrefetchInliningConfig
// Normalized by config.ts: defaulted to 90% of staticPageGenerationTimeout
useCacheTimeout: number
// Normalized by config.ts `finalizeConfig`: defaulted to `'warning'`
instantInsights: { validationLevel: ValidationLevel }
// Normalized by finalized config with a default and the expected type
turbopackMemoryEvictionMode: MemoryEvictionMode
}
// The root directory of the distDir. In development mode, this is the parent directory of `distDir`
// since development builds use `{distDir}/dev`. This is used to ensure that the bundler doesn't
// traverse into the output directory.
distDirRoot: string
// The repository root, regardless of overwritten outputFileTracingRoot or turbopack.root.
repoRoot: string
} }
// The root directory of the distDir. In development mode, this is the parent directory of `distDir`
// since development builds use `{distDir}/dev`. This is used to ensure that the bundler doesn't
// traverse into the output directory.
distDirRoot: string
// The repository root, regardless of overwritten outputFileTracingRoot or turbopack.root.
repoRoot: string
}
export type I18NDomains = readonly DomainLocale[] export type I18NDomains = readonly DomainLocale[]
...@@ -2294,14 +2313,14 @@ export interface NextConfigRuntime { ...@@ -2294,14 +2313,14 @@ export interface NextConfigRuntime {
agentRules: NextConfigComplete['agentRules'] agentRules: NextConfigComplete['agentRules']
htmlLimitedBots: NextConfigComplete['htmlLimitedBots'] htmlLimitedBots: NextConfigComplete['htmlLimitedBots']
assetPrefix: NextConfigComplete['assetPrefix'] assetPrefix: NextConfigComplete['assetPrefix']
output: NextConfigComplete['output'] output?: NextConfigComplete['output']
crossOrigin: NextConfigComplete['crossOrigin'] crossOrigin: NextConfigComplete['crossOrigin']
trailingSlash: NextConfigComplete['trailingSlash'] trailingSlash: NextConfigComplete['trailingSlash']
images: NextConfigComplete['images'] images: NextConfigComplete['images']
reactMaxHeadersLength: NextConfigComplete['reactMaxHeadersLength'] reactMaxHeadersLength: NextConfigComplete['reactMaxHeadersLength']
cacheLife: NextConfigComplete['cacheLife'] cacheLife: NextConfigComplete['cacheLife']
basePath: NextConfigComplete['basePath'] basePath: NextConfigComplete['basePath']
expireTime: NextConfigComplete['expireTime'] expireTime?: NextConfigComplete['expireTime']
generateEtags: NextConfigComplete['generateEtags'] generateEtags: NextConfigComplete['generateEtags']
poweredByHeader: NextConfigComplete['poweredByHeader'] poweredByHeader: NextConfigComplete['poweredByHeader']
cacheHandler: NextConfigComplete['cacheHandler'] cacheHandler: NextConfigComplete['cacheHandler']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment