@@ -133,7 +133,6 @@ export type ServerFields = {
133
133
}
134
134
135
135
async function verifyTypeScript ( opts : SetupOpts ) {
136
- let usingTypeScript = false
137
136
const verifyResult = await verifyTypeScriptSetup ( {
138
137
dir : opts . dir ,
139
138
distDir : opts . nextConfig . distDir ,
@@ -146,9 +145,9 @@ async function verifyTypeScript(opts: SetupOpts) {
146
145
} )
147
146
148
147
if ( verifyResult . version ) {
149
- usingTypeScript = true
148
+ return true
150
149
}
151
- return usingTypeScript
150
+ return false
152
151
}
153
152
154
153
export async function propagateServerField (
@@ -242,8 +241,6 @@ async function startWatcher(
242
241
opts . nextConfig
243
242
)
244
243
245
- const usingTypeScript = await verifyTypeScript ( opts )
246
-
247
244
const routesManifestPath = path . join ( distDir , ROUTES_MANIFEST )
248
245
const routesManifest : DevRoutesManifest = {
249
246
version : 3 ,
@@ -348,14 +345,15 @@ async function startWatcher(
348
345
} ,
349
346
} )
350
347
const fileWatchTimes = new Map ( )
351
- let enabledTypeScript = usingTypeScript
348
+ let enabledTypeScript = await verifyTypeScript ( opts )
352
349
let previousClientRouterFilters : any
353
350
let previousConflictingPagePaths : Set < string > = new Set ( )
354
351
355
352
const routeTypesFilePath = path . join ( distDir , 'types' , 'routes.d.ts' )
356
353
const validatorFilePath = path . join ( distDir , 'types' , 'validator.ts' )
357
354
358
355
wp . on ( 'aggregated' , async ( ) => {
356
+ let typescriptStatusFromLastAggregation = enabledTypeScript
359
357
let middlewareMatchers : MiddlewareMatcher [ ] | undefined
360
358
const routedPages : string [ ] = [ ]
361
359
const knownFiles = wp . getTimeInfoEntries ( )
@@ -728,7 +726,8 @@ async function startWatcher(
728
726
}
729
727
}
730
728
731
- if ( ! usingTypeScript && enabledTypeScript ) {
729
+ // Using === false to make the check clearer.
730
+ if ( typescriptStatusFromLastAggregation === false && enabledTypeScript ) {
732
731
// we tolerate the error here as this is best effort
733
732
// and the manual install command will be shown
734
733
await verifyTypeScript ( opts )
@@ -753,7 +752,7 @@ async function startWatcher(
753
752
}
754
753
)
755
754
756
- if ( usingTypeScript && nextConfig . experimental ?. typedEnv ) {
755
+ if ( enabledTypeScript && nextConfig . experimental ?. typedEnv ) {
757
756
// do not await, this is not essential for further process
758
757
createEnvDefinitions ( {
759
758
distDir,
@@ -1091,7 +1090,7 @@ async function startWatcher(
1091
1090
}
1092
1091
prevSortedRoutes = sortedRoutes
1093
1092
1094
- if ( usingTypeScript ) {
1093
+ if ( enabledTypeScript ) {
1095
1094
const routeTypesManifest = await createRouteTypesManifest ( {
1096
1095
dir,
1097
1096
pageRoutes,
0 commit comments