Unverified Commit a3d875e0 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Enable `@typescript-eslint/switch-exhaustiveness-check` rule (#81583)

parent 6430cbc9
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
// .eslintrc.json for the matching files. // .eslintrc.json for the matching files.
"rules": { "rules": {
// TODO: enable in follow-up PR // TODO: enable in follow-up PR
"@typescript-eslint/no-floating-promises": "off" "@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/switch-exhaustiveness-check": "error"
} }
} }
] ]
......
...@@ -98,9 +98,11 @@ export = defineRule({ ...@@ -98,9 +98,11 @@ export = defineRule({
}) })
break break
} }
default: { case 'ClassDeclaration':
// We don't need to check typos in class declarations.
break break
} default:
decl satisfies never
} }
return return
}, },
......
...@@ -865,7 +865,7 @@ export function finalizeEntrypoint({ ...@@ -865,7 +865,7 @@ export function finalizeEntrypoint({
isServerComponent, isServerComponent,
hasAppDir, hasAppDir,
}: { }: {
compilerType?: CompilerNameValues compilerType: CompilerNameValues
name: string name: string
value: ObjectValue<webpack.EntryObject> value: ObjectValue<webpack.EntryObject>
isServerComponent?: boolean isServerComponent?: boolean
...@@ -958,9 +958,7 @@ export function finalizeEntrypoint({ ...@@ -958,9 +958,7 @@ export function finalizeEntrypoint({
...entry, ...entry,
} }
} }
default: { default:
// Should never happen. return compilerType satisfies never
throw new Error('Invalid compiler type')
}
} }
} }
...@@ -33,9 +33,11 @@ export async function rawEntrypointsToEntrypoints( ...@@ -33,9 +33,11 @@ export async function rawEntrypointsToEntrypoints(
app.set(route.originalName, route) app.set(route.originalName, route)
break break
} }
default: case 'conflict':
Log.info(`skipping ${pathname} (${route.type})`) Log.info(`skipping ${pathname} (${route.type})`)
break break
default:
route satisfies never
} }
} }
......
...@@ -276,16 +276,19 @@ function getEmotionOptions( ...@@ -276,16 +276,19 @@ function getEmotionOptions(
return null return null
} }
let autoLabel = !!development let autoLabel = !!development
switch (typeof emotionConfig === 'object' && emotionConfig.autoLabel) { if (typeof emotionConfig === 'object' && emotionConfig.autoLabel) {
case 'never': switch (emotionConfig.autoLabel) {
autoLabel = false case 'never':
break autoLabel = false
case 'always': break
autoLabel = true case 'always':
break autoLabel = true
case 'dev-only': break
default: case 'dev-only':
break break
default:
emotionConfig.autoLabel satisfies never
}
} }
return { return {
enabled: true, enabled: true,
......
...@@ -1947,6 +1947,8 @@ export default async function getBaseWebpackConfig( ...@@ -1947,6 +1947,8 @@ export default async function getBaseWebpackConfig(
case WEBPACK_LAYERS.actionBrowser: case WEBPACK_LAYERS.actionBrowser:
runtime = 'app-page' runtime = 'app-page'
break break
case null:
case undefined:
default: default:
runtime = 'pages' runtime = 'pages'
} }
......
...@@ -441,6 +441,7 @@ function processMessage( ...@@ -441,6 +441,7 @@ function processMessage(
return return
} }
default: { default: {
obj satisfies never
} }
} }
} }
......
...@@ -361,13 +361,16 @@ function processMessage(obj: HMR_ACTION_TYPES) { ...@@ -361,13 +361,16 @@ function processMessage(obj: HMR_ACTION_TYPES) {
dispatcher.onRefresh() dispatcher.onRefresh()
break break
} }
default: { case HMR_ACTIONS_SENT_TO_BROWSER.ADDED_PAGE:
case HMR_ACTIONS_SENT_TO_BROWSER.REMOVED_PAGE:
case HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE:
case HMR_ACTIONS_SENT_TO_BROWSER.DEV_PAGES_MANIFEST_UPDATE:
if (customHmrEventHandler) { if (customHmrEventHandler) {
customHmrEventHandler(obj) customHmrEventHandler(obj)
break
} }
break break
} default:
obj satisfies never
} }
} }
......
...@@ -48,6 +48,12 @@ function formatObject(arg: unknown, depth: number) { ...@@ -48,6 +48,12 @@ function formatObject(arg: unknown, depth: number) {
} }
case 'string': case 'string':
return JSON.stringify(arg) return JSON.stringify(arg)
case 'number':
case 'bigint':
case 'boolean':
case 'symbol':
case 'undefined':
case 'function':
default: default:
return String(arg) return String(arg)
} }
......
...@@ -52,8 +52,20 @@ export function pageBootstrap(assetPrefix: string) { ...@@ -52,8 +52,20 @@ export function pageBootstrap(assetPrefix: string) {
}) })
break break
} }
default: case HMR_ACTIONS_SENT_TO_BROWSER.ADDED_PAGE:
case HMR_ACTIONS_SENT_TO_BROWSER.REMOVED_PAGE:
case HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES:
case HMR_ACTIONS_SENT_TO_BROWSER.SYNC:
case HMR_ACTIONS_SENT_TO_BROWSER.BUILT:
case HMR_ACTIONS_SENT_TO_BROWSER.BUILDING:
case HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE:
case HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_CONNECTED:
case HMR_ACTIONS_SENT_TO_BROWSER.ISR_MANIFEST:
// Most of these action types are handled in
// src/client/dev/hot-reloader/pages/hot-reloader-pages.ts
break break
default:
payload satisfies never
} }
} else if ('event' in payload) { } else if ('event' in payload) {
switch (payload.event) { switch (payload.event) {
...@@ -116,7 +128,7 @@ export function pageBootstrap(assetPrefix: string) { ...@@ -116,7 +128,7 @@ export function pageBootstrap(assetPrefix: string) {
break break
} }
default: default:
break payload satisfies never
} }
} }
}) })
......
...@@ -117,10 +117,11 @@ export async function handleFetch( ...@@ -117,10 +117,11 @@ export async function handleFetch(
throw new Error( throw new Error(
`Proxy request aborted [${request.method} ${request.url}]` `Proxy request aborted [${request.method} ${request.url}]`
) )
case 'fetch':
return buildResponse(proxyResponse)
default: default:
break return api satisfies never
} }
return buildResponse(proxyResponse)
} }
export function interceptFetch(originalFetch: Fetch) { export function interceptFetch(originalFetch: Fetch) {
......
...@@ -269,6 +269,7 @@ async function mergeMetadata( ...@@ -269,6 +269,7 @@ async function mergeMetadata(
break break
} }
// directly assign fields that fallback to null // directly assign fields that fallback to null
case 'abstract':
case 'applicationName': case 'applicationName':
case 'description': case 'description':
case 'generator': case 'generator':
...@@ -290,18 +291,29 @@ async function mergeMetadata( ...@@ -290,18 +291,29 @@ async function mergeMetadata(
target.metadataBase = metadataBase target.metadataBase = metadataBase
break break
default: { case 'apple-touch-fullscreen': {
if ( buildState.warnings.add(
(key === 'viewport' || `Use appleWebApp instead\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-metadata`
key === 'themeColor' || )
key === 'colorScheme') && break
source[key] != null }
) { case 'apple-touch-icon-precomposed': {
buildState.warnings.add(
`Use icons.apple instead\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-metadata`
)
break
}
case 'themeColor':
case 'colorScheme':
case 'viewport':
if (source[key] != null) {
buildState.warnings.add( buildState.warnings.add(
`Unsupported metadata ${key} is configured in metadata export in ${route}. Please move it to viewport export instead.\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-viewport` `Unsupported metadata ${key} is configured in metadata export in ${route}. Please move it to viewport export instead.\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-viewport`
) )
} }
break break
default: {
key satisfies never
} }
} }
} }
...@@ -335,11 +347,20 @@ function mergeViewport({ ...@@ -335,11 +347,20 @@ function mergeViewport({
case 'colorScheme': case 'colorScheme':
target.colorScheme = source.colorScheme || null target.colorScheme = source.colorScheme || null
break break
default: case 'width':
case 'height':
case 'initialScale':
case 'minimumScale':
case 'maximumScale':
case 'userScalable':
case 'viewportFit':
case 'interactiveWidget':
// always override the target with the source // always override the target with the source
// @ts-ignore viewport properties // @ts-ignore viewport properties
target[key] = source[key] target[key] = source[key]
break break
default:
key satisfies never
} }
} }
} }
......
...@@ -247,8 +247,11 @@ export const resolveTwitter: FieldResolverExtraArgs< ...@@ -247,8 +247,11 @@ export const resolveTwitter: FieldResolverExtraArgs<
resolved.app = resolved.app || {} resolved.app = resolved.app || {}
break break
} }
default: case 'summary':
case 'summary_large_image':
break break
default:
resolved satisfies never
} }
} }
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
export interface DeprecatedMetadataFields { export interface DeprecatedMetadataFields {
/** /**
* Deprecated options that have a preferred method * Deprecated options that have a preferred method
* @deprecated Use appWebApp to configure mobile-web-app-capable which provides * @deprecated Use appleWebApp instead
*/ */
'apple-touch-fullscreen'?: never | undefined 'apple-touch-fullscreen'?: never | undefined
/** /**
* Obsolete since iOS 7. * Obsolete since iOS 7.
* @see https://web.dev/apple-touch-icon/ * @see https://web.dev/apple-touch-icon/
* @deprecated use icons.apple or instead * @deprecated Use icons.apple instead
*/ */
'apple-touch-icon-precomposed'?: never | undefined 'apple-touch-icon-precomposed'?: never | undefined
} }
......
import { bold, cyan, red, yellow } from '../picocolors' import { bold, cyan, red, yellow } from '../picocolors'
import path from 'path' import path from 'path'
// eslint typescript has a bug with TS enums
/* eslint-disable no-shadow */
export enum DiagnosticCategory {
Warning = 0,
Error = 1,
Suggestion = 2,
Message = 3,
}
function getFormattedLinkDiagnosticMessageText( function getFormattedLinkDiagnosticMessageText(
diagnostic: import('typescript').Diagnostic diagnostic: import('typescript').Diagnostic
) { ) {
...@@ -339,21 +330,22 @@ export function getFormattedDiagnostic( ...@@ -339,21 +330,22 @@ export function getFormattedDiagnostic(
const category = diagnostic.category const category = diagnostic.category
switch (category) { switch (category) {
// Warning // Warning
case DiagnosticCategory.Warning: { case ts.DiagnosticCategory.Warning: {
message += yellow(bold('Type warning')) + ': ' message += yellow(bold('Type warning')) + ': '
break break
} }
// Error // Error
case DiagnosticCategory.Error: { case ts.DiagnosticCategory.Error: {
message += red(bold('Type error')) + ': ' message += red(bold('Type error')) + ': '
break break
} }
// 2 = Suggestion, 3 = Message // 2 = Suggestion, 3 = Message
case DiagnosticCategory.Suggestion: case ts.DiagnosticCategory.Suggestion:
case DiagnosticCategory.Message: case ts.DiagnosticCategory.Message:
default: {
message += cyan(bold(category === 2 ? 'Suggestion' : 'Info')) + ': ' message += cyan(bold(category === 2 ? 'Suggestion' : 'Info')) + ': '
break break
default: {
category satisfies never
} }
} }
......
import path from 'path' import path from 'path'
import { import { getFormattedDiagnostic } from './diagnosticFormatter'
DiagnosticCategory,
getFormattedDiagnostic,
} from './diagnosticFormatter'
import { getTypeScriptConfiguration } from './getTypeScriptConfiguration' import { getTypeScriptConfiguration } from './getTypeScriptConfiguration'
import { getRequiredConfiguration } from './writeConfigurationDefaults' import { getRequiredConfiguration } from './writeConfigurationDefaults'
...@@ -91,14 +88,14 @@ export async function runTypeCheck( ...@@ -91,14 +88,14 @@ export async function runTypeCheck(
const firstError = const firstError =
allDiagnostics.find( allDiagnostics.find(
(d) => d.category === DiagnosticCategory.Error && Boolean(d.file) (d) => d.category === ts.DiagnosticCategory.Error && Boolean(d.file)
) ?? allDiagnostics.find((d) => d.category === DiagnosticCategory.Error) ) ?? allDiagnostics.find((d) => d.category === ts.DiagnosticCategory.Error)
// In test mode, we want to check all diagnostics, not just the first one. // In test mode, we want to check all diagnostics, not just the first one.
if (process.env.__NEXT_TEST_MODE) { if (process.env.__NEXT_TEST_MODE) {
if (firstError) { if (firstError) {
const allErrors = allDiagnostics const allErrors = allDiagnostics
.filter((d) => d.category === DiagnosticCategory.Error) .filter((d) => d.category === ts.DiagnosticCategory.Error)
.map( .map(
(d) => (d) =>
'[Test Mode] ' + '[Test Mode] ' +
...@@ -123,7 +120,7 @@ export async function runTypeCheck( ...@@ -123,7 +120,7 @@ export async function runTypeCheck(
} }
const warnings = allDiagnostics const warnings = allDiagnostics
.filter((d) => d.category === DiagnosticCategory.Warning) .filter((d) => d.category === ts.DiagnosticCategory.Warning)
.map((d) => .map((d) =>
getFormattedDiagnostic(ts, baseDir, distDir, d, isAppDirEnabled) getFormattedDiagnostic(ts, baseDir, distDir, d, isAppDirEnabled)
) )
......
...@@ -2,15 +2,31 @@ import type { DispatcherEvent, OverlayState } from '../shared' ...@@ -2,15 +2,31 @@ import type { DispatcherEvent, OverlayState } from '../shared'
import { useReducer } from 'react' import { useReducer } from 'react'
import { import {
ACTION_DEVTOOLS_POSITION, ACTION_BEFORE_REFRESH,
ACTION_BUILD_ERROR,
ACTION_BUILD_OK,
ACTION_BUILDING_INDICATOR_HIDE,
ACTION_BUILDING_INDICATOR_SHOW,
ACTION_DEBUG_INFO,
ACTION_DEV_INDICATOR,
ACTION_DEVTOOL_UPDATE_ROUTE_STATE,
ACTION_DEVTOOLS_PANEL_CLOSE, ACTION_DEVTOOLS_PANEL_CLOSE,
ACTION_DEVTOOLS_PANEL_OPEN,
ACTION_DEVTOOLS_PANEL_TOGGLE, ACTION_DEVTOOLS_PANEL_TOGGLE,
ACTION_DEVTOOLS_POSITION,
ACTION_DEVTOOLS_SCALE,
ACTION_ERROR_OVERLAY_CLOSE, ACTION_ERROR_OVERLAY_CLOSE,
ACTION_ERROR_OVERLAY_OPEN, ACTION_ERROR_OVERLAY_OPEN,
ACTION_ERROR_OVERLAY_TOGGLE, ACTION_ERROR_OVERLAY_TOGGLE,
ACTION_DEVTOOLS_SCALE, ACTION_REFRESH,
ACTION_RENDERING_INDICATOR_HIDE,
ACTION_RENDERING_INDICATOR_SHOW,
ACTION_RESTART_SERVER_BUTTON,
ACTION_STATIC_INDICATOR,
ACTION_UNHANDLED_ERROR,
ACTION_UNHANDLED_REJECTION,
ACTION_VERSION_INFO,
INITIAL_OVERLAY_STATE, INITIAL_OVERLAY_STATE,
ACTION_DEVTOOLS_PANEL_OPEN,
} from '../shared' } from '../shared'
export const storybookDefaultOverlayState: OverlayState = { export const storybookDefaultOverlayState: OverlayState = {
...@@ -52,8 +68,25 @@ export function useStorybookOverlayReducer(initialState?: OverlayState) { ...@@ -52,8 +68,25 @@ export function useStorybookOverlayReducer(initialState?: OverlayState) {
case ACTION_DEVTOOLS_SCALE: { case ACTION_DEVTOOLS_SCALE: {
return { ...state, scale: action.scale } return { ...state, scale: action.scale }
} }
default: { case ACTION_BEFORE_REFRESH:
case ACTION_BUILD_ERROR:
case ACTION_BUILD_OK:
case ACTION_BUILDING_INDICATOR_HIDE:
case ACTION_BUILDING_INDICATOR_SHOW:
case ACTION_DEBUG_INFO:
case ACTION_DEV_INDICATOR:
case ACTION_DEVTOOL_UPDATE_ROUTE_STATE:
case ACTION_REFRESH:
case ACTION_RENDERING_INDICATOR_HIDE:
case ACTION_RENDERING_INDICATOR_SHOW:
case ACTION_RESTART_SERVER_BUTTON:
case ACTION_STATIC_INDICATOR:
case ACTION_UNHANDLED_ERROR:
case ACTION_UNHANDLED_REJECTION:
case ACTION_VERSION_INFO:
return state return state
default: {
return action satisfies never
} }
} }
}, },
......
...@@ -31,168 +31,6 @@ export function prerenderAndAbortInSequentialTasks<R>( ...@@ -31,168 +31,6 @@ export function prerenderAndAbortInSequentialTasks<R>(
} }
} }
const PENDING = 0
const COMPLETE = 1
const INTERRUPTED = 2
const ERRORED = 3
export class ServerPrerenderStreamResult {
private currentChunks: Array<Uint8Array>
private chunksByPhase: Array<Array<Uint8Array>>
private trailingChunks: Array<Uint8Array>
private status: 0 | 1 | 2 | 3
private reason: null | unknown
constructor(stream: ReadableStream<Uint8Array>) {
this.status = PENDING
this.reason = null
this.trailingChunks = []
this.currentChunks = []
this.chunksByPhase = [this.currentChunks]
const reader = stream.getReader()
const progress = ({
done,
value,
}: ReadableStreamReadResult<Uint8Array>) => {
if (done) {
if (this.status === PENDING) {
this.status = COMPLETE
}
return
}
if (this.status === PENDING || this.status === INTERRUPTED) {
this.currentChunks.push(value)
} else {
this.trailingChunks.push(value)
}
reader.read().then(progress, error)
}
const error = (reason: unknown) => {
this.status = ERRORED
this.reason = reason
}
reader.read().then(progress, error)
}
markPhase() {
this.currentChunks = []
this.chunksByPhase.push(this.currentChunks)
}
markComplete() {
if (this.status === PENDING) {
this.status = COMPLETE
}
}
markInterrupted() {
this.status = INTERRUPTED
}
/**
* Returns a stream which only releases chunks when `releasePhase` is called. This stream will never "complete" because
* we rely upon the stream remaining open when prerendering to avoid triggering errors for incomplete chunks in the client.
*
* asPhasedStream is expected to be called once per result however it is safe to call multiple times as long as we have not
* transferred the underlying data. Generally this will only happen when streaming to a response
*/
asPhasedStream() {
switch (this.status) {
case COMPLETE:
case INTERRUPTED:
return new PhasedStream(this.chunksByPhase)
default:
throw new InvariantError(
`ServerPrerenderStreamResult cannot be consumed as a stream because it is not yet complete. status: ${this.status}`
)
}
}
/**
* Returns a stream which will release all chunks immediately. This stream will "complete" synchronously. It should be used outside
* of render use cases like loading client chunks ahead of SSR or writing the streamed content to disk.
*/
asStream() {
switch (this.status) {
case COMPLETE:
case INTERRUPTED:
const chunksByPhase = this.chunksByPhase
const trailingChunks = this.trailingChunks
return new ReadableStream({
start(controller) {
for (let i = 0; i < chunksByPhase.length; i++) {
const chunks = chunksByPhase[i]
for (let j = 0; j < chunks.length; j++) {
controller.enqueue(chunks[j])
}
}
for (let i = 0; i < trailingChunks.length; i++) {
controller.enqueue(trailingChunks[i])
}
controller.close()
},
})
default:
throw new InvariantError(
`ServerPrerenderStreamResult cannot be consumed as a stream because it is not yet complete. status: ${this.status}`
)
}
}
}
class PhasedStream<T> extends ReadableStream<T> {
private nextPhase: number
private chunksByPhase: Array<Array<T>>
private destination: ReadableStreamDefaultController<T>
constructor(chunksByPhase: Array<Array<T>>) {
if (chunksByPhase.length === 0) {
throw new InvariantError(
'PhasedStream expected at least one phase but none were found.'
)
}
let destination: ReadableStreamDefaultController<T>
super({
start(controller) {
destination = controller
},
})
// the start function above is called synchronously during construction so we will always have a destination
// We wait to assign it until after the super call because we cannot access `this` before calling super
this.destination = destination!
this.nextPhase = 0
this.chunksByPhase = chunksByPhase
this.releasePhase()
}
releasePhase() {
if (this.nextPhase < this.chunksByPhase.length) {
const chunks = this.chunksByPhase[this.nextPhase++]
for (let i = 0; i < chunks.length; i++) {
this.destination.enqueue(chunks[i])
}
} else {
throw new InvariantError(
'PhasedStream expected more phases to release but none were found.'
)
}
}
assertExhausted() {
if (this.nextPhase < this.chunksByPhase.length) {
throw new InvariantError(
'PhasedStream expected no more phases to release but some were found.'
)
}
}
}
// React's RSC prerender function will emit an incomplete flight stream when using `prerender`. If the connection // React's RSC prerender function will emit an incomplete flight stream when using `prerender`. If the connection
// closes then whatever hanging chunks exist will be errored. This is because prerender (an experimental feature) // closes then whatever hanging chunks exist will be errored. This is because prerender (an experimental feature)
// has not yet implemented a concept of resume. For now we will simulate a paused connection by wrapping the stream // has not yet implemented a concept of resume. For now we will simulate a paused connection by wrapping the stream
......
...@@ -153,10 +153,7 @@ import { createMutableActionQueue } from '../../client/components/app-router-ins ...@@ -153,10 +153,7 @@ import { createMutableActionQueue } from '../../client/components/app-router-ins
import { getRevalidateReason } from '../instrumentation/utils' import { getRevalidateReason } from '../instrumentation/utils'
import { PAGE_SEGMENT_KEY } from '../../shared/lib/segment' import { PAGE_SEGMENT_KEY } from '../../shared/lib/segment'
import type { FallbackRouteParams } from '../request/fallback-params' import type { FallbackRouteParams } from '../request/fallback-params'
import { import { processPrelude } from './app-render-prerender-utils'
ServerPrerenderStreamResult,
processPrelude,
} from './app-render-prerender-utils'
import { import {
type ReactServerPrerenderResult, type ReactServerPrerenderResult,
ReactServerResult, ReactServerResult,
...@@ -2889,10 +2886,7 @@ async function prerenderToStream( ...@@ -2889,10 +2886,7 @@ async function prerenderToStream(
onHTMLRenderSSRError onHTMLRenderSSRError
) )
let reactServerPrerenderResult: let reactServerPrerenderResult: null | ReactServerPrerenderResult = null
| null
| ReactServerPrerenderResult
| ServerPrerenderStreamResult = null
const setMetadataHeader = (name: string) => { const setMetadataHeader = (name: string) => {
metadata.headers ??= {} metadata.headers ??= {}
metadata.headers[name] = res.getHeader(name) metadata.headers[name] = res.getHeader(name)
...@@ -3945,10 +3939,7 @@ async function prerenderToStream( ...@@ -3945,10 +3939,7 @@ async function prerenderToStream(
// This is intentionally using the readable datastream from the main // This is intentionally using the readable datastream from the main
// render rather than the flight data from the error page render // render rather than the flight data from the error page render
const flightStream = const flightStream = reactServerPrerenderResult.consumeAsStream()
reactServerPrerenderResult instanceof ServerPrerenderStreamResult
? reactServerPrerenderResult.asStream()
: reactServerPrerenderResult.consumeAsStream()
return { return {
// Returning the error that was thrown so it can be used to handle // Returning the error that was thrown so it can be used to handle
......
...@@ -51,6 +51,7 @@ function matchWildcardDomain(domain: string, pattern: string) { ...@@ -51,6 +51,7 @@ function matchWildcardDomain(domain: string, pattern: string) {
// recursive wildcard matches anything so we terminate here if the domain part is non empty // recursive wildcard matches anything so we terminate here if the domain part is non empty
return domainPart !== undefined return domainPart !== undefined
} }
case undefined:
default: { default: {
if (domainPart !== patternPart) { if (domainPart !== patternPart) {
return false return false
......
...@@ -440,11 +440,25 @@ export async function handleLog( ...@@ -440,11 +440,25 @@ export async function handleLog(
await handleDir(entry, browserPrefix, ctx, distDir) await handleDir(entry, browserPrefix, ctx, distDir)
break break
} }
// xml log thing maybe needs an impl case 'dirxml': {
// xml log thing maybe needs an impl
// [browser] undefined (app/page.tsx:8:11) console.group // fallthrough
// check console assert }
default: { case 'group':
case 'groupCollapsed':
case 'groupEnd': {
// [browser] undefined (app/page.tsx:8:11) console.group
// fallthrough
}
case 'assert': {
// check console assert
// fallthrough
}
case 'log':
case 'info':
case 'debug':
case 'error':
case 'warn': {
await handleDefaultConsole( await handleDefaultConsole(
entry, entry,
browserPrefix, browserPrefix,
...@@ -452,6 +466,10 @@ export async function handleLog( ...@@ -452,6 +466,10 @@ export async function handleLog(
distDir, distDir,
config config
) )
break
}
default: {
entry satisfies never
} }
} }
break break
......
...@@ -119,11 +119,6 @@ export interface AppIsrManifestAction { ...@@ -119,11 +119,6 @@ export interface AppIsrManifestAction {
data: Record<string, boolean> data: Record<string, boolean>
} }
export interface DevIndicatorAction {
action: HMR_ACTIONS_SENT_TO_BROWSER.DEV_INDICATOR
devIndicator: DevIndicatorServerState
}
export type HMR_ACTION_TYPES = export type HMR_ACTION_TYPES =
| TurbopackMessageAction | TurbopackMessageAction
| TurbopackConnectedAction | TurbopackConnectedAction
...@@ -140,7 +135,6 @@ export type HMR_ACTION_TYPES = ...@@ -140,7 +135,6 @@ export type HMR_ACTION_TYPES =
| DevPagesManifestUpdateAction | DevPagesManifestUpdateAction
| ServerErrorAction | ServerErrorAction
| AppIsrManifestAction | AppIsrManifestAction
| DevIndicatorAction
export type TurbopackMsgToBrowser = export type TurbopackMsgToBrowser =
| { type: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE; data: any } | { type: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE; data: any }
......
...@@ -171,7 +171,10 @@ function formatCacheStatus(cacheStatus: FetchMetric['cacheStatus']): string { ...@@ -171,7 +171,10 @@ function formatCacheStatus(cacheStatus: FetchMetric['cacheStatus']): string {
return green('(HMR cache)') return green('(HMR cache)')
case 'hit': case 'hit':
return green('(cache hit)') return green('(cache hit)')
default: case 'miss':
case 'skip':
return yellow(`(cache ${cacheStatus})`) return yellow(`(cache ${cacheStatus})`)
default:
return cacheStatus satisfies never
} }
} }
...@@ -621,9 +621,11 @@ export async function handleEntrypoints({ ...@@ -621,9 +621,11 @@ export async function handleEntrypoints({
currentEntrypoints.app.set(route.originalName, route) currentEntrypoints.app.set(route.originalName, route)
break break
} }
default: case 'conflict':
Log.info(`skipping ${pathname} (${route.type})`) Log.info(`skipping ${pathname} (${route.type})`)
break break
default:
route satisfies never
} }
} }
......
...@@ -609,11 +609,17 @@ export function createPatchedFetcher( ...@@ -609,11 +609,17 @@ export function createPatchedFetcher(
} }
break break
} }
case 'default-cache':
case 'default-no-store':
case 'auto':
case undefined:
// sometimes we won't match the above cases. the reason we don't move
// everything to this switch is the use of autoNoCache which is not a fetchCacheMode
// I suspect this could be unified with fetchCacheMode however in which case we could
// simplify the switch case and ensure we have an exhaustive switch handling all modes
break
default: default:
// sometimes we won't match the above cases. the reason we don't move pageFetchCacheMode satisfies never
// everything to this switch is the use of autoNoCache which is not a fetchCacheMode
// I suspect this could be unified with fetchCacheMode however in which case we could
// simplify the switch case and ensure we have an exhaustive switch handling all modes
} }
if (typeof finalRevalidate === 'undefined') { if (typeof finalRevalidate === 'undefined') {
......
...@@ -611,9 +611,15 @@ export async function setupFsCheck(opts: { ...@@ -611,9 +611,15 @@ export async function setupFsCheck(opts: {
itemsRoot = publicFolderPath itemsRoot = publicFolderPath
break break
} }
default: { case 'appFile':
case 'pageFile':
case 'nextImage':
case 'devVirtualFsItem': {
break break
} }
default: {
;(type) satisfies never
}
} }
if (itemsRoot && curItemPath) { if (itemsRoot && curItemPath) {
......
...@@ -97,6 +97,8 @@ function dimConsoleCall( ...@@ -97,6 +97,8 @@ function dimConsoleCall(
switch (methodName) { switch (methodName) {
case 'dir': case 'dir':
case 'dirxml': case 'dirxml':
case 'group':
case 'groupCollapsed':
case 'groupEnd': case 'groupEnd':
case 'table': { case 'table': {
// These methods cannot be colorized because they don't take a formatting string. // These methods cannot be colorized because they don't take a formatting string.
...@@ -109,10 +111,17 @@ function dimConsoleCall( ...@@ -109,10 +111,17 @@ function dimConsoleCall(
...formatConsoleArguments(args[1], ...args.slice(2)) ...formatConsoleArguments(args[1], ...args.slice(2))
) )
} }
default: case 'error':
case 'debug':
case 'info':
case 'log':
case 'trace':
case 'warn':
return [ANSI_STYLE_DIMMING_TEMPLATE].concat( return [ANSI_STYLE_DIMMING_TEMPLATE].concat(
...formatConsoleArguments(args[0], ...args.slice(1)) ...formatConsoleArguments(args[0], ...args.slice(1))
) )
default:
return methodName satisfies never
} }
} }
......
...@@ -82,7 +82,10 @@ export function routeKindToIncrementalCacheKind( ...@@ -82,7 +82,10 @@ export function routeKindToIncrementalCacheKind(
return IncrementalCacheKind.IMAGE return IncrementalCacheKind.IMAGE
case RouteKind.APP_ROUTE: case RouteKind.APP_ROUTE:
return IncrementalCacheKind.APP_ROUTE return IncrementalCacheKind.APP_ROUTE
default: case RouteKind.PAGES_API:
// Pages Router API routes are not cached in the incremental cache.
throw new Error(`Unexpected route kind ${routeKind}`) throw new Error(`Unexpected route kind ${routeKind}`)
default:
return routeKind satisfies never
} }
} }
...@@ -754,9 +754,14 @@ export class AppRouteRouteModule extends RouteModule< ...@@ -754,9 +754,14 @@ export class AppRouteRouteModule extends RouteModule<
if (workStore.isStaticGeneration) if (workStore.isStaticGeneration)
request = new Proxy(req, requireStaticRequestHandlers) request = new Proxy(req, requireStaticRequestHandlers)
break break
default: case undefined:
// We proxy `NextRequest` to track dynamic access, and potentially bail out of static generation case 'auto':
// We proxy `NextRequest` to track dynamic access, and
// potentially bail out of static generation.
request = proxyNextRequest(req, workStore) request = proxyNextRequest(req, workStore)
break
default:
this.dynamic satisfies never
} }
// TODO: propagate this pathname from route matcher // TODO: propagate this pathname from route matcher
......
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