Skip to content

Commit 1e3a1cb

Browse files
huozhieps1lon
andauthored
Upgrade typescript to 5.3 (#64043)
Closes NEXT-2997 --------- Co-authored-by: eps1lon <[email protected]>
1 parent 1fd93ee commit 1e3a1cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+312
-301
lines changed

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@
103103
"@types/html-validator": "5.0.3",
104104
"@types/http-proxy": "1.17.3",
105105
"@types/jest": "29.5.5",
106-
"@types/node": "20.2.5",
106+
"@types/node": "20.12.3",
107107
"@types/node-fetch": "2.6.1",
108-
"@types/react": "18.2.37",
109-
"@types/react-dom": "18.2.15",
108+
"@types/react": "18.2.74",
109+
"@types/react-dom": "18.2.23",
110110
"@types/relay-runtime": "14.1.13",
111111
"@types/selenium-webdriver": "4.0.15",
112112
"@types/sharp": "0.29.3",
@@ -233,7 +233,7 @@
233233
"tree-kill": "1.2.2",
234234
"tsec": "0.2.1",
235235
"turbo": "1.12.5",
236-
"typescript": "5.2.2",
236+
"typescript": "5.3.3",
237237
"unfetch": "4.2.0",
238238
"wait-port": "0.2.2",
239239
"webpack": "5.90.0",
@@ -246,13 +246,13 @@
246246
"webpack": "5.90.0",
247247
"browserslist": "4.22.2",
248248
"caniuse-lite": "1.0.30001579",
249-
"@types/node": "20.2.5",
249+
"@types/node": "20.12.3",
250250
"@babel/core": "7.22.5",
251251
"@babel/parser": "7.22.5",
252252
"@babel/types": "7.22.5",
253253
"@babel/traverse": "7.22.5",
254-
"@types/react": "18.2.37",
255-
"@types/react-dom": "18.2.15"
254+
"@types/react": "18.2.74",
255+
"@types/react-dom": "18.2.23"
256256
},
257257
"engines": {
258258
"node": ">=18.17.0",

packages/create-next-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@types/async-retry": "1.4.2",
3333
"@types/ci-info": "2.0.0",
3434
"@types/cross-spawn": "6.0.0",
35-
"@types/node": "^20.2.5",
35+
"@types/node": "^20.12.3",
3636
"@types/prompts": "2.4.2",
3737
"@types/tar": "6.1.5",
3838
"@types/validate-npm-package-name": "3.0.0",

packages/next/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference types="./types/global" />
2-
/// <reference types="./types/compiled" />
32
/// <reference path="./dist/styled-jsx/types/global.d.ts" />
43
/// <reference path="./amp.d.ts" />
54
/// <reference path="./app.d.ts" />

packages/next/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
"amp.d.ts",
5050
"og.js",
5151
"og.d.ts",
52+
"types.d.ts",
53+
"types.js",
5254
"index.d.ts",
53-
"types/index.d.ts",
5455
"types/global.d.ts",
5556
"types/compiled.d.ts",
5657
"image-types/global.d.ts",
@@ -182,9 +183,9 @@
182183
"@types/path-to-regexp": "1.7.0",
183184
"@types/picomatch": "2.3.3",
184185
"@types/platform": "1.3.4",
185-
"@types/react": "18.2.37",
186-
"@types/react-dom": "18.2.15",
187-
"@types/react-is": "17.0.3",
186+
"@types/react": "18.2.74",
187+
"@types/react-dom": "18.2.23",
188+
"@types/react-is": "18.2.4",
188189
"@types/semver": "7.3.1",
189190
"@types/send": "0.14.4",
190191
"@types/shell-quote": "1.7.1",

packages/next/src/build/analysis/get-page-static-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Middleware, RouteHas } from '../../lib/load-custom-routes'
44
import { promises as fs } from 'fs'
55
import LRUCache from 'next/dist/compiled/lru-cache'
66
import picomatch from 'next/dist/compiled/picomatch'
7-
import type { ServerRuntime } from 'next/types'
7+
import type { ServerRuntime } from '../../types'
88
import {
99
extractExportedConstValue,
1010
UnsupportedValueError,

packages/next/src/build/babel/plugins/next-page-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
Visitor,
66
NodePath,
77
} from 'next/dist/compiled/babel/core'
8-
import type { PageConfig } from 'next/types'
8+
import type { PageConfig } from '../../../types'
99
import { STRING_LITERAL_DROP_BUNDLE } from '../../../shared/lib/constants'
1010

1111
const CONFIG_KEY = 'config'

packages/next/src/build/entries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import {
5050
import { getPageStaticInfo } from './analysis/get-page-static-info'
5151
import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep'
5252
import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
53-
import type { ServerRuntime } from '../../types'
53+
import type { ServerRuntime } from '../types'
5454
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'
5555
import { encodeMatchers } from './webpack/loaders/next-middleware-loader'
5656
import type { EdgeFunctionLoaderOptions } from './webpack/loaders/next-edge-function-loader'

packages/next/src/build/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
GetStaticPathsResult,
77
PageConfig,
88
ServerRuntime,
9-
} from 'next/types'
9+
} from '../types'
1010
import type { BuildManifest } from '../server/get-page-files'
1111
import type {
1212
Redirect,

packages/next/src/build/webpack/loaders/next-edge-ssr-loader/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type webpack from 'webpack'
2-
import type { SizeLimit } from '../../../../../types'
2+
import type { SizeLimit } from '../../../../types'
33
import type { PagesRouteModuleOptions } from '../../../../server/future/route-modules/pages/module'
44
import type { MiddlewareConfig } from '../../../analysis/get-page-static-info'
55

packages/next/src/build/webpack/loaders/next-edge-ssr-loader/render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { SERVER_RUNTIME } from '../../../../lib/constants'
1616
import type { ManifestRewriteRoute, PrerenderManifest } from '../../..'
1717
import { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths'
18-
import type { SizeLimit } from '../../../../../types'
18+
import type { SizeLimit } from '../../../../types'
1919
import { internal_getCurrentFunctionWaitUntil } from '../../../../server/web/internal-edge-wait-until'
2020
import type { PAGE_TYPES } from '../../../../lib/page-types'
2121
import type { NextRequestHint } from '../../../../server/web/adapter'

packages/next/src/build/webpack/loaders/next-swc-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29-
import type { NextConfig } from '../../../../types'
29+
import type { NextConfig } from '../../../types'
3030
import type { WebpackLayerName } from '../../../lib/constants'
3131
import { isWasm, transform } from '../../swc'
3232
import { getLoaderSWCOptions } from '../../swc/options'

packages/next/src/build/webpack/plugins/next-types-plugin/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ declare namespace __next_route_internal_types__ {
441441
}
442442
443443
declare module 'next' {
444-
export { default } from 'next/types/index.js'
445-
export * from 'next/types/index.js'
444+
export { default } from 'next/types.js'
445+
export * from 'next/types.js'
446446
447447
export type Route<T extends string = string> =
448448
__next_route_internal_types__.RouteImpl<T>

packages/next/src/client/components/router-reducer/ppr-navigations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ function createPendingCacheNode(
528528

529529
// Create a deferred promise. This will be fulfilled once the dynamic
530530
// response is received from the server.
531-
rsc: createDeferredRsc(),
532-
head: isLeafSegment ? createDeferredRsc() : null,
531+
rsc: createDeferredRsc() as React.ReactNode,
532+
head: isLeafSegment ? (createDeferredRsc() as React.ReactNode) : null,
533533
lazyDataResolved: false,
534534
}
535535
}

packages/next/src/lib/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ServerRuntime } from '../../types'
1+
import type { ServerRuntime } from '../types'
22

33
export const NEXT_QUERY_PARAM_PREFIX = 'nxtP'
44

packages/next/src/lib/is-edge-runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ServerRuntime } from '../../types'
1+
import type { ServerRuntime } from '../types'
22
import { SERVER_RUNTIME } from './constants'
33

44
export function isEdgeRuntime(value?: string): value is ServerRuntime {

packages/next/src/lib/memory/startup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export function enableMemoryDebuggingMode(): void {
99
// memory limit. It does not give any warning to the user though which
1010
// can be jarring. If memory is large, this may take a long time.
1111
if ('setHeapSnapshotNearHeapLimit' in v8) {
12-
// @ts-expect-error - this method exists since Node 16.
1312
v8.setHeapSnapshotNearHeapLimit(1)
1413
}
1514

packages/next/src/server/api-utils/node/api-resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { IncomingMessage, ServerResponse } from 'http'
22
import type { NextApiRequest, NextApiResponse } from '../../../shared/lib/utils'
3-
import type { PageConfig, ResponseLimit } from 'next/types'
3+
import type { PageConfig, ResponseLimit } from '../../../types'
44
import type { __ApiPreviewProps } from '../.'
55
import type { CookieSerializeOptions } from 'next/dist/compiled/cookie'
66

packages/next/src/server/api-utils/node/parse-body.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { IncomingMessage } from 'http'
2-
import type { SizeLimit } from 'next/types'
32

43
import { parse } from 'next/dist/compiled/content-type'
54
import isError from '../../../lib/is-error'
5+
import type { SizeLimit } from '../../../types'
66
import { ApiError } from '../index'
77

88
/**

packages/next/src/server/api-utils/node/try-get-preview-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { NextApiResponse } from '../../../shared/lib/utils'
33
import { checkIsOnDemandRevalidate } from '../.'
44
import type { __ApiPreviewProps } from '../.'
55
import type { BaseNextRequest, BaseNextResponse } from '../../base-http'
6-
import type { PreviewData } from 'next/types'
6+
import type { PreviewData } from '../../../types'
77

88
import {
99
clearPreviewData,

packages/next/src/server/app-render/action-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http'
2-
import type { SizeLimit } from '../../../types'
2+
import type { SizeLimit } from '../../types'
33
import type { RequestStore } from '../../client/components/request-async-storage.external'
44
import type { AppRenderContext, GenerateFlight } from './app-render'
55
import type { AppPageModule } from '../../server/future/route-modules/app-page/module'

packages/next/src/server/app-render/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { LoadComponentsReturnType } from '../load-components'
2-
import type { ServerRuntime, SizeLimit } from '../../../types'
2+
import type { ServerRuntime, SizeLimit } from '../../types'
33
import type { NextConfigComplete } from '../../server/config-shared'
44
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin'
55
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin'

packages/next/src/server/base-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
normalizeRepeatedSlashes,
2121
MissingStaticPage,
2222
} from '../shared/lib/utils'
23-
import type { PreviewData } from 'next/types'
23+
import type { PreviewData } from '../types'
2424
import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin'
2525
import type { BaseNextRequest, BaseNextResponse } from './base-http'
2626
import type {

packages/next/src/server/config-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { VALID_LOADERS } from '../shared/lib/image-config'
44
import { z } from 'next/dist/compiled/zod'
55
import type zod from 'next/dist/compiled/zod'
66

7-
import type { SizeLimit } from '../../types'
7+
import type { SizeLimit } from '../types'
88
import type {
99
ExportPathMap,
1010
TurboLoaderItem,

packages/next/src/server/config-shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
import type { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin'
1010
import type { WEB_VITALS } from '../shared/lib/utils'
1111
import type { NextParsedUrlQuery } from './request-meta'
12-
import type { SizeLimit } from '../../types'
12+
import type { SizeLimit } from '../types'
1313
import type { SwrDelta } from './lib/revalidate'
1414

1515
export type NextConfigComplete = Required<NextConfig> & {

packages/next/src/server/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ export default async function loadConfig(
10141014
require('./config-schema') as typeof import('./config-schema')
10151015
const state = configSchema.safeParse(userConfig)
10161016

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

packages/next/src/server/future/route-modules/pages-api/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { IncomingMessage, ServerResponse } from 'http'
22
import type { PagesAPIRouteDefinition } from '../../route-definitions/pages-api-route-definition'
3-
import type { PageConfig } from '../../../../../types'
3+
import type { PageConfig } from '../../../../types'
44
import type { ParsedUrlQuery } from 'querystring'
55
import { wrapApiHandler, type __ApiPreviewProps } from '../../../api-utils'
66
import type { RouteModuleOptions } from '../route-module'

packages/next/src/server/future/route-modules/pages/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
GetStaticProps,
66
NextComponentType,
77
PageConfig,
8-
} from '../../../../../types'
8+
} from '../../../../types'
99
import type { PagesRouteDefinition } from '../../route-definitions/pages-route-definition'
1010
import type { NextParsedUrlQuery } from '../../../request-meta'
1111
import type { RenderOpts } from '../../../render'

packages/next/src/server/lib/router-utils/resolve-routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { IncomingMessage, ServerResponse } from 'http'
33
import type { NextConfigComplete } from '../../config-shared'
44
import type { RenderServer, initialize } from '../router-server'
55
import type { PatchMatcher } from '../../../shared/lib/router/utils/path-match'
6-
import type { Redirect } from '../../../../types'
6+
import type { Redirect } from '../../../types'
77
import type { Header } from '../../../lib/load-custom-routes'
88
import type { UnwrapPromise } from '../../../lib/coalesced-function'
99
import type { NextUrlWithParsedQuery } from '../../request-meta'

packages/next/src/server/load-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
GetStaticPaths,
1010
GetServerSideProps,
1111
GetStaticProps,
12-
} from 'next/types'
12+
} from '../types'
1313
import type { RouteModule } from './future/route-modules/route-module'
1414
import type { BuildManifest } from './get-page-files'
1515
import type { ActionManifest } from '../build/webpack/plugins/flight-client-entry-plugin'

packages/next/src/server/load-default-error-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
GetStaticPaths,
1010
GetServerSideProps,
1111
GetStaticProps,
12-
} from 'next/types'
12+
} from '../types'
1313
import type { RouteModule } from './future/route-modules/route-module'
1414
import type { BuildManifest } from './get-page-files'
1515

packages/next/src/server/render.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import type {
2929
PreviewData,
3030
ServerRuntime,
3131
SizeLimit,
32-
} from 'next/types'
32+
} from '../types'
3333
import type { UnwrapPromise } from '../lib/coalesced-function'
3434
import type { ReactReadableStream } from './stream-utils/node-web-streams-helper'
3535
import type { ClientReferenceManifest } from '../build/webpack/plugins/flight-manifest-plugin'

packages/next/src/server/setup-http-agent-env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { NextConfig } from '../../types'
1+
import type { NextConfig } from '../types'
22
import { Agent as HttpAgent } from 'http'
33
import { Agent as HttpsAgent } from 'https'
44

packages/next/src/shared/lib/get-hostname.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ describe('getHostname', () => {
2626
// With headers.
2727
expect(getHostname(parsed, { host: parsed.host })).toBe(hostname)
2828
// With an empty headers array.
29+
// @ts-expect-error passing an array of strings is not allowed
2930
expect(getHostname(parsed, { host: [] })).toBe(hostname)
3031
// With a headers array.
32+
// @ts-expect-error passing an array of strings is not allowed
3133
expect(getHostname({}, { host: [parsed.host] })).toBe(undefined)
3234
})
3335
})
3436

3537
it('should return undefined for empty input', () => {
3638
expect(getHostname({})).toBe(undefined)
39+
// @ts-expect-error passing an array of strings is not allowed
3740
expect(getHostname({}, { host: [] })).toBe(undefined)
3841
})
3942
})

packages/next/src/shared/lib/html-context.shared-runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { BuildManifest } from '../../server/get-page-files'
2-
import type { ServerRuntime } from 'next/types'
2+
import type { ServerRuntime } from '../../types'
33
import type { NEXT_DATA } from './utils'
44
import type { FontConfig } from '../../server/font-utils'
55
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin'

packages/next/src/shared/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Env } from '@next/env'
55
import type { IncomingMessage, ServerResponse } from 'http'
66
import type { NextRouter } from './router/router'
77
import type { ParsedUrlQuery } from 'querystring'
8-
import type { PreviewData } from 'next/types'
8+
import type { PreviewData } from '../../types'
99
import type { COMPILER_NAMES } from './constants'
1010
import type fs from 'fs'
1111

0 commit comments

Comments
 (0)