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

Upgrade typescript to 5.3 #64043

Merged
merged 14 commits into from
Apr 17, 2024
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@
"@types/html-validator": "5.0.3",
"@types/http-proxy": "1.17.3",
"@types/jest": "29.5.5",
"@types/node": "20.2.5",
"@types/node": "20.12.3",
"@types/node-fetch": "2.6.1",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@types/react": "18.2.74",
"@types/react-dom": "18.2.23",
"@types/relay-runtime": "14.1.13",
"@types/selenium-webdriver": "4.0.15",
"@types/sharp": "0.29.3",
Expand Down Expand Up @@ -233,7 +233,7 @@
"tree-kill": "1.2.2",
"tsec": "0.2.1",
"turbo": "1.12.5",
"typescript": "5.2.2",
"typescript": "5.3.3",
"unfetch": "4.2.0",
"wait-port": "0.2.2",
"webpack": "5.90.0",
Expand All @@ -246,13 +246,13 @@
"webpack": "5.90.0",
"browserslist": "4.22.2",
"caniuse-lite": "1.0.30001579",
"@types/node": "20.2.5",
"@types/node": "20.12.3",
"@babel/core": "7.22.5",
"@babel/parser": "7.22.5",
"@babel/types": "7.22.5",
"@babel/traverse": "7.22.5",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15"
"@types/react": "18.2.74",
"@types/react-dom": "18.2.23"
},
"engines": {
"node": ">=18.17.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@types/async-retry": "1.4.2",
"@types/ci-info": "2.0.0",
"@types/cross-spawn": "6.0.0",
"@types/node": "^20.2.5",
"@types/node": "^20.12.3",
"@types/prompts": "2.4.2",
"@types/tar": "6.1.5",
"@types/validate-npm-package-name": "3.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/next/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="./types/global" />
/// <reference types="./types/compiled" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically referenced in the files that are relevant.

/// <reference path="./dist/styled-jsx/types/global.d.ts" />
/// <reference path="./amp.d.ts" />
/// <reference path="./app.d.ts" />
Expand Down
9 changes: 5 additions & 4 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
"amp.d.ts",
"og.js",
"og.d.ts",
"types.d.ts",
"types.js",
"index.d.ts",
"types/index.d.ts",
"types/global.d.ts",
"types/compiled.d.ts",
"image-types/global.d.ts",
Expand Down Expand Up @@ -182,9 +183,9 @@
"@types/path-to-regexp": "1.7.0",
"@types/picomatch": "2.3.3",
"@types/platform": "1.3.4",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@types/react-is": "17.0.3",
"@types/react": "18.2.74",
"@types/react-dom": "18.2.23",
"@types/react-is": "18.2.4",
"@types/semver": "7.3.1",
"@types/send": "0.14.4",
"@types/shell-quote": "1.7.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/analysis/get-page-static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Middleware, RouteHas } from '../../lib/load-custom-routes'
import { promises as fs } from 'fs'
import LRUCache from 'next/dist/compiled/lru-cache'
import picomatch from 'next/dist/compiled/picomatch'
import type { ServerRuntime } from 'next/types'
import type { ServerRuntime } from '../../types'
import {
extractExportedConstValue,
UnsupportedValueError,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/babel/plugins/next-page-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
Visitor,
NodePath,
} from 'next/dist/compiled/babel/core'
import type { PageConfig } from 'next/types'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a public api that we are going to break? I dont know if next/types is something the user would expect to import from.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same content. next/types used to resolve to next/types/index.d.ts. Now it resolves to next/types.d.ts which just reexports next/dist/types.d.ts. And since I just moved everything from next/types/index.d.ts into next/src/types.ts, the content should also be the same.

It's really just reorganizing files so that the program using the root tsconfig doesn't include Next.js source files.

import type { PageConfig } from '../../../types'
import { STRING_LITERAL_DROP_BUNDLE } from '../../../shared/lib/constants'

const CONFIG_KEY = 'config'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
import { getPageStaticInfo } from './analysis/get-page-static-info'
import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep'
import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
import type { ServerRuntime } from '../../types'
import type { ServerRuntime } from '../types'
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'
import { encodeMatchers } from './webpack/loaders/next-middleware-loader'
import type { EdgeFunctionLoaderOptions } from './webpack/loaders/next-edge-function-loader'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
GetStaticPathsResult,
PageConfig,
ServerRuntime,
} from 'next/types'
} from '../types'
import type { BuildManifest } from '../server/get-page-files'
import type {
Redirect,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type webpack from 'webpack'
import type { SizeLimit } from '../../../../../types'
import type { SizeLimit } from '../../../../types'
import type { PagesRouteModuleOptions } from '../../../../server/future/route-modules/pages/module'
import type { MiddlewareConfig } from '../../../analysis/get-page-static-info'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { SERVER_RUNTIME } from '../../../../lib/constants'
import type { ManifestRewriteRoute, PrerenderManifest } from '../../..'
import { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths'
import type { SizeLimit } from '../../../../../types'
import type { SizeLimit } from '../../../../types'
import { internal_getCurrentFunctionWaitUntil } from '../../../../server/web/internal-edge-wait-until'
import type { PAGE_TYPES } from '../../../../lib/page-types'
import type { NextRequestHint } from '../../../../server/web/adapter'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/webpack/loaders/next-swc-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

import type { NextConfig } from '../../../../types'
import type { NextConfig } from '../../../types'
import type { WebpackLayerName } from '../../../lib/constants'
import { isWasm, transform } from '../../swc'
import { getLoaderSWCOptions } from '../../swc/options'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ declare namespace __next_route_internal_types__ {
}

declare module 'next' {
export { default } from 'next/types/index.js'
export * from 'next/types/index.js'
export { default } from 'next/types.js'
export * from 'next/types.js'

export type Route<T extends string = string> =
__next_route_internal_types__.RouteImpl<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ function createPendingCacheNode(

// Create a deferred promise. This will be fulfilled once the dynamic
// response is received from the server.
rsc: createDeferredRsc(),
head: isLeafSegment ? createDeferredRsc() : null,
rsc: createDeferredRsc() as React.ReactNode,
head: isLeafSegment ? (createDeferredRsc() as React.ReactNode) : null,
lazyDataResolved: false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ServerRuntime } from '../../types'
import type { ServerRuntime } from '../types'

export const NEXT_QUERY_PARAM_PREFIX = 'nxtP'

Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/lib/is-edge-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ServerRuntime } from '../../types'
import type { ServerRuntime } from '../types'
import { SERVER_RUNTIME } from './constants'

export function isEdgeRuntime(value?: string): value is ServerRuntime {
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/lib/memory/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export function enableMemoryDebuggingMode(): void {
// memory limit. It does not give any warning to the user though which
// can be jarring. If memory is large, this may take a long time.
if ('setHeapSnapshotNearHeapLimit' in v8) {
// @ts-expect-error - this method exists since Node 16.
v8.setHeapSnapshotNearHeapLimit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/api-utils/node/api-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IncomingMessage, ServerResponse } from 'http'
import type { NextApiRequest, NextApiResponse } from '../../../shared/lib/utils'
import type { PageConfig, ResponseLimit } from 'next/types'
import type { PageConfig, ResponseLimit } from '../../../types'
import type { __ApiPreviewProps } from '../.'
import type { CookieSerializeOptions } from 'next/dist/compiled/cookie'

Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/api-utils/node/parse-body.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IncomingMessage } from 'http'
import type { SizeLimit } from 'next/types'

import { parse } from 'next/dist/compiled/content-type'
import isError from '../../../lib/is-error'
import type { SizeLimit } from '../../../types'
import { ApiError } from '../index'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { NextApiResponse } from '../../../shared/lib/utils'
import { checkIsOnDemandRevalidate } from '../.'
import type { __ApiPreviewProps } from '../.'
import type { BaseNextRequest, BaseNextResponse } from '../../base-http'
import type { PreviewData } from 'next/types'
import type { PreviewData } from '../../../types'

import {
clearPreviewData,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/app-render/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http'
import type { SizeLimit } from '../../../types'
import type { SizeLimit } from '../../types'
import type { RequestStore } from '../../client/components/request-async-storage.external'
import type { AppRenderContext, GenerateFlight } from './app-render'
import type { AppPageModule } from '../../server/future/route-modules/app-page/module'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/app-render/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LoadComponentsReturnType } from '../load-components'
import type { ServerRuntime, SizeLimit } from '../../../types'
import type { ServerRuntime, SizeLimit } from '../../types'
import type { NextConfigComplete } from '../../server/config-shared'
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin'
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
normalizeRepeatedSlashes,
MissingStaticPage,
} from '../shared/lib/utils'
import type { PreviewData } from 'next/types'
import type { PreviewData } from '../types'
import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin'
import type { BaseNextRequest, BaseNextResponse } from './base-http'
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { VALID_LOADERS } from '../shared/lib/image-config'
import { z } from 'next/dist/compiled/zod'
import type zod from 'next/dist/compiled/zod'

import type { SizeLimit } from '../../types'
import type { SizeLimit } from '../types'
import type {
ExportPathMap,
TurboLoaderItem,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
import type { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin'
import type { WEB_VITALS } from '../shared/lib/utils'
import type { NextParsedUrlQuery } from './request-meta'
import type { SizeLimit } from '../../types'
import type { SizeLimit } from '../types'
import type { SwrDelta } from './lib/revalidate'

export type NextConfigComplete = Required<NextConfig> & {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ export default async function loadConfig(
require('./config-schema') as typeof import('./config-schema')
const state = configSchema.safeParse(userConfig)

if (!state.success) {
if (state.success === false) {
// error message header
const messages = [`Invalid ${configFileName} options detected: `]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IncomingMessage, ServerResponse } from 'http'
import type { PagesAPIRouteDefinition } from '../../route-definitions/pages-api-route-definition'
import type { PageConfig } from '../../../../../types'
import type { PageConfig } from '../../../../types'
import type { ParsedUrlQuery } from 'querystring'
import { wrapApiHandler, type __ApiPreviewProps } from '../../../api-utils'
import type { RouteModuleOptions } from '../route-module'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
GetStaticProps,
NextComponentType,
PageConfig,
} from '../../../../../types'
} from '../../../../types'
import type { PagesRouteDefinition } from '../../route-definitions/pages-route-definition'
import type { NextParsedUrlQuery } from '../../../request-meta'
import type { RenderOpts } from '../../../render'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { IncomingMessage, ServerResponse } from 'http'
import type { NextConfigComplete } from '../../config-shared'
import type { RenderServer, initialize } from '../router-server'
import type { PatchMatcher } from '../../../shared/lib/router/utils/path-match'
import type { Redirect } from '../../../../types'
import type { Redirect } from '../../../types'
import type { Header } from '../../../lib/load-custom-routes'
import type { UnwrapPromise } from '../../../lib/coalesced-function'
import type { NextUrlWithParsedQuery } from '../../request-meta'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/load-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
GetStaticPaths,
GetServerSideProps,
GetStaticProps,
} from 'next/types'
} from '../types'
import type { RouteModule } from './future/route-modules/route-module'
import type { BuildManifest } from './get-page-files'
import type { ActionManifest } from '../build/webpack/plugins/flight-client-entry-plugin'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/load-default-error-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
GetStaticPaths,
GetServerSideProps,
GetStaticProps,
} from 'next/types'
} from '../types'
import type { RouteModule } from './future/route-modules/route-module'
import type { BuildManifest } from './get-page-files'

Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type {
PreviewData,
ServerRuntime,
SizeLimit,
} from 'next/types'
} from '../types'
import type { UnwrapPromise } from '../lib/coalesced-function'
import type { ReactReadableStream } from './stream-utils/node-web-streams-helper'
import type { ClientReferenceManifest } from '../build/webpack/plugins/flight-manifest-plugin'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/setup-http-agent-env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextConfig } from '../../types'
import type { NextConfig } from '../types'
import { Agent as HttpAgent } from 'http'
import { Agent as HttpsAgent } from 'https'

Expand Down
3 changes: 3 additions & 0 deletions packages/next/src/shared/lib/get-hostname.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ describe('getHostname', () => {
// With headers.
expect(getHostname(parsed, { host: parsed.host })).toBe(hostname)
// With an empty headers array.
// @ts-expect-error passing an array of strings is not allowed
expect(getHostname(parsed, { host: [] })).toBe(hostname)
// With a headers array.
// @ts-expect-error passing an array of strings is not allowed
expect(getHostname({}, { host: [parsed.host] })).toBe(undefined)
})
})

it('should return undefined for empty input', () => {
expect(getHostname({})).toBe(undefined)
// @ts-expect-error passing an array of strings is not allowed
expect(getHostname({}, { host: [] })).toBe(undefined)
})
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BuildManifest } from '../../server/get-page-files'
import type { ServerRuntime } from 'next/types'
import type { ServerRuntime } from '../../types'
import type { NEXT_DATA } from './utils'
import type { FontConfig } from '../../server/font-utils'
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/shared/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Env } from '@next/env'
import type { IncomingMessage, ServerResponse } from 'http'
import type { NextRouter } from './router/router'
import type { ParsedUrlQuery } from 'querystring'
import type { PreviewData } from 'next/types'
import type { PreviewData } from '../../types'
import type { COMPILER_NAMES } from './constants'
import type fs from 'fs'

Expand Down
Loading
Loading