Upgrade typescript to 5.3 (#64043)
Closes NEXT-2997 --------- Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
This commit is contained in:
parent
1fd93eed90
commit
1e3a1cbaab
57 changed files with 312 additions and 301 deletions
14
package.json
14
package.json
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
1
packages/next/index.d.ts
vendored
1
packages/next/index.d.ts
vendored
|
@ -1,5 +1,4 @@
|
|||
/// <reference types="./types/global" />
|
||||
/// <reference types="./types/compiled" />
|
||||
/// <reference path="./dist/styled-jsx/types/global.d.ts" />
|
||||
/// <reference path="./amp.d.ts" />
|
||||
/// <reference path="./app.d.ts" />
|
||||
|
|
|
@ -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",
|
||||
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -5,7 +5,7 @@ import type {
|
|||
Visitor,
|
||||
NodePath,
|
||||
} from 'next/dist/compiled/babel/core'
|
||||
import type { PageConfig } from 'next/types'
|
||||
import type { PageConfig } from '../../../types'
|
||||
import { STRING_LITERAL_DROP_BUNDLE } from '../../../shared/lib/constants'
|
||||
|
||||
const CONFIG_KEY = 'config'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { ServerRuntime } from '../../types'
|
||||
import type { ServerRuntime } from '../types'
|
||||
|
||||
export const NEXT_QUERY_PARAM_PREFIX = 'nxtP'
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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> & {
|
||||
|
|
|
@ -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: `]
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -11,27 +11,22 @@ import type React from 'react'
|
|||
import type { ParsedUrlQuery } from 'querystring'
|
||||
import type { IncomingMessage, ServerResponse } from 'http'
|
||||
|
||||
import {
|
||||
import type {
|
||||
NextPageContext,
|
||||
NextComponentType,
|
||||
NextApiResponse,
|
||||
NextApiRequest,
|
||||
NextApiHandler,
|
||||
// @ts-ignore This path is generated at build time and conflicts otherwise
|
||||
} from '../dist/shared/lib/utils'
|
||||
} from './shared/lib/utils'
|
||||
|
||||
import type {
|
||||
NextApiRequestCookies,
|
||||
// @ts-ignore This path is generated at build time and conflicts otherwise
|
||||
} from '../dist/server/api-utils'
|
||||
import type { NextApiRequestCookies } from './server/api-utils'
|
||||
|
||||
// @ts-ignore This path is generated at build time and conflicts otherwise
|
||||
import next from '../dist/server/next'
|
||||
import next from './server/next'
|
||||
|
||||
export type ServerRuntime = 'nodejs' | 'experimental-edge' | 'edge' | undefined
|
||||
|
||||
// @ts-ignore This path is generated at build time and conflicts otherwise
|
||||
export { NextConfig } from '../dist/server/config'
|
||||
export { NextConfig } from './server/config'
|
||||
|
||||
export type {
|
||||
Metadata,
|
||||
|
@ -41,8 +36,7 @@ export type {
|
|||
Viewport,
|
||||
ResolvingViewport,
|
||||
ResolvedViewport,
|
||||
// @ts-ignore This path is generated at build time and conflicts otherwise
|
||||
} from '../dist/lib/metadata/types/metadata-interface'
|
||||
} from './lib/metadata/types/metadata-interface'
|
||||
|
||||
/**
|
||||
* Stub route type for typedRoutes before `next dev` or `next build` is run
|
||||
|
@ -160,7 +154,7 @@ export type PageConfig = {
|
|||
unstable_excludeFiles?: string[]
|
||||
}
|
||||
|
||||
export {
|
||||
export type {
|
||||
NextPageContext,
|
||||
NextComponentType,
|
||||
NextApiResponse,
|
|
@ -2576,7 +2576,10 @@ export async function trace(task, opts) {
|
|||
}
|
||||
|
||||
export async function build(task, opts) {
|
||||
await task.serial(['precompile', 'compile', 'generate_types'], opts)
|
||||
await task.serial(
|
||||
['precompile', 'compile', 'generate_types', 'rewrite_compiled_references'],
|
||||
opts
|
||||
)
|
||||
}
|
||||
|
||||
export async function generate_types(task, opts) {
|
||||
|
@ -2585,6 +2588,37 @@ export async function generate_types(task, opts) {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* TypeScript will emit references to the compiled types used to type the implementation.
|
||||
* The declarations however don't need such detailed types.
|
||||
* We rewrite the references to reference a more lightweight solution instead.
|
||||
* @param {import('taskr').Task} task
|
||||
*/
|
||||
export async function rewrite_compiled_references(task, opts) {
|
||||
const declarationDirectory = join(__dirname, 'dist')
|
||||
const declarationFiles = glob.sync('**/*.d.ts', { cwd: declarationDirectory })
|
||||
|
||||
for (const declarationFile of declarationFiles) {
|
||||
const content = await fs.readFile(
|
||||
join(declarationDirectory, declarationFile),
|
||||
'utf8'
|
||||
)
|
||||
// Rewrite
|
||||
// /// <reference path="../../../../types/$$compiled.internal.d.ts" />
|
||||
// to
|
||||
// /// <reference path="../../../../types/compiled.d.ts" />
|
||||
if (content.indexOf('/types/$$compiled.internal.d.ts" />') !== -1) {
|
||||
await fs.writeFile(
|
||||
join(declarationDirectory, declarationFile),
|
||||
content.replace(
|
||||
/\/types\/\$\$compiled\.internal\.d\.ts" \/>/g,
|
||||
'/types/compiled.d.ts" />'
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default async function (task) {
|
||||
const opts = { dev: true }
|
||||
await task.clear('dist')
|
||||
|
|
9
packages/next/types.d.ts
vendored
Normal file
9
packages/next/types.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Triple slash directives are copied from src/types.ts.
|
||||
// TypeScript currently does not preserve the tripple-slash directives.
|
||||
// Once https://github.com/microsoft/TypeScript/pull/57681 is released, we can remove the triple slash directives here.
|
||||
/// <reference types="react" />
|
||||
/// <reference types="react/experimental" />
|
||||
/// <reference types="react-dom" />
|
||||
/// <reference types="react-dom/experimental" />
|
||||
export * from './dist/types'
|
||||
export { default } from './dist/types'
|
1
packages/next/types.js
Normal file
1
packages/next/types.js
Normal file
|
@ -0,0 +1 @@
|
|||
// types-only
|
|
@ -446,3 +446,33 @@ declare module 'next/dist/compiled/zod' {
|
|||
import * as m from 'zod'
|
||||
export = m
|
||||
}
|
||||
|
||||
declare module 'mini-css-extract-plugin'
|
||||
declare module 'next/dist/compiled/loader-utils3'
|
||||
|
||||
declare module 'next/dist/compiled/webpack/webpack' {
|
||||
import type webpackSources from 'webpack-sources1'
|
||||
export function init(): void
|
||||
export let BasicEvaluatedExpression: any
|
||||
export let GraphHelpers: any
|
||||
export let sources: typeof webpackSources
|
||||
export let StringXor: any
|
||||
export {
|
||||
default as webpack,
|
||||
Compiler,
|
||||
Compilation,
|
||||
Module,
|
||||
Stats,
|
||||
Template,
|
||||
RuntimeModule,
|
||||
RuntimeGlobals,
|
||||
NormalModule,
|
||||
ResolvePluginInstance,
|
||||
ModuleFilenameHelpers,
|
||||
} from 'webpack'
|
||||
export type {
|
||||
LoaderDefinitionFunction,
|
||||
LoaderContext,
|
||||
ModuleGraph,
|
||||
} from 'webpack'
|
||||
}
|
54
packages/next/types/webpack.d.ts
vendored
54
packages/next/types/webpack.d.ts
vendored
|
@ -1,54 +0,0 @@
|
|||
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/no-unused-vars , no-shadow */
|
||||
// Type definitions for webpack 4.39
|
||||
// Project: https://github.com/webpack/webpack
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>
|
||||
// Benjamin Lim <https://github.com/bumbleblym>
|
||||
// Boris Cherny <https://github.com/bcherny>
|
||||
// Tommy Troy Lin <https://github.com/tommytroylin>
|
||||
// Mohsen Azimi <https://github.com/mohsen1>
|
||||
// Jonathan Creamer <https://github.com/jcreamer898>
|
||||
// Alan Agius <https://github.com/alan-agius4>
|
||||
// Spencer Elliott <https://github.com/elliottsj>
|
||||
// Jason Cheatham <https://github.com/jason0x43>
|
||||
// Dennis George <https://github.com/dennispg>
|
||||
// Christophe Hurpeau <https://github.com/christophehurpeau>
|
||||
// ZSkycat <https://github.com/ZSkycat>
|
||||
// John Reilly <https://github.com/johnnyreilly>
|
||||
// Ryan Waskiewicz <https://github.com/rwaskiewicz>
|
||||
// Kyle Uehlein <https://github.com/kuehlein>
|
||||
// Grgur Grisogono <https://github.com/grgur>
|
||||
// Rubens Pinheiro Gonçalves Cavalcante <https://github.com/rubenspgcavalcante>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare module 'mini-css-extract-plugin'
|
||||
declare module 'next/dist/compiled/loader-utils3'
|
||||
|
||||
declare module 'next/dist/compiled/webpack/webpack' {
|
||||
import type webpackSources from 'webpack-sources1'
|
||||
export function init(): void
|
||||
export let BasicEvaluatedExpression: any
|
||||
export let GraphHelpers: any
|
||||
export let sources: typeof webpackSources
|
||||
export let StringXor: any
|
||||
export {
|
||||
default as webpack,
|
||||
Compiler,
|
||||
Compilation,
|
||||
Module,
|
||||
Stats,
|
||||
Template,
|
||||
RuntimeModule,
|
||||
RuntimeGlobals,
|
||||
NormalModule,
|
||||
ResolvePluginInstance,
|
||||
ModuleFilenameHelpers,
|
||||
} from 'webpack'
|
||||
export type {
|
||||
LoaderDefinitionFunction,
|
||||
LoaderContext,
|
||||
ModuleGraph,
|
||||
} from 'webpack'
|
||||
}
|
333
pnpm-lock.yaml
333
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
import { NextInstance, createNext } from 'e2e-utils'
|
||||
import { trace } from 'next/src/trace'
|
||||
import { trace } from 'next/dist/trace'
|
||||
import { PHASE_DEVELOPMENT_SERVER } from 'next/constants'
|
||||
import {
|
||||
createDefineEnv,
|
||||
|
@ -11,8 +11,8 @@ import {
|
|||
StyledString,
|
||||
TurbopackResult,
|
||||
UpdateInfo,
|
||||
} from 'next/src/build/swc'
|
||||
import loadConfig from 'next/src/server/config'
|
||||
} from 'next/dist/build/swc'
|
||||
import loadConfig from 'next/dist/server/config'
|
||||
import path from 'path'
|
||||
|
||||
function normalizePath(path: string) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { NextInstance } from 'e2e-utils'
|
|||
import { check, waitFor } from 'next-test-utils'
|
||||
import webdriver, { BrowserInterface } from 'next-webdriver'
|
||||
|
||||
import type { HistoryState } from '../../../packages/next/src/shared/lib/router/router'
|
||||
import type { HistoryState } from 'next/dist/shared/lib/router/router'
|
||||
|
||||
const emitPopsStateEvent = (browser: BrowserInterface, state: HistoryState) =>
|
||||
browser.eval(
|
||||
|
|
|
@ -4,7 +4,7 @@ import { NextInstance } from 'e2e-utils'
|
|||
import { check, waitFor } from 'next-test-utils'
|
||||
import webdriver, { BrowserInterface } from 'next-webdriver'
|
||||
|
||||
import type { HistoryState } from '../../../packages/next/src/shared/lib/router/router'
|
||||
import type { HistoryState } from 'next/dist/shared/lib/router/router'
|
||||
|
||||
const emitPopsStateEvent = (browser: BrowserInterface, state: HistoryState) =>
|
||||
browser.eval(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import path from 'path'
|
||||
import assert from 'assert'
|
||||
import { flushAllTraces, setGlobal, trace } from 'next/src/trace'
|
||||
import { flushAllTraces, setGlobal, trace } from 'next/dist/trace'
|
||||
import { PHASE_DEVELOPMENT_SERVER } from 'next/constants'
|
||||
import { NextInstance, NextInstanceOpts } from './next-modes/base'
|
||||
import { NextDevInstance } from './next-modes/next-dev'
|
||||
|
|
|
@ -6,7 +6,7 @@ import type { NextConfig } from 'next'
|
|||
import { FileRef, isNextDeploy, isNextDev } from '../e2e-utils'
|
||||
import { ChildProcess } from 'child_process'
|
||||
import { createNextInstall } from '../create-next-install'
|
||||
import { Span } from 'next/src/trace'
|
||||
import { Span } from 'next/dist/trace'
|
||||
import webdriver from '../next-webdriver'
|
||||
import { renderViaHTTP, fetchViaHTTP, waitFor } from 'next-test-utils'
|
||||
import cheerio from 'cheerio'
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
TEST_TOKEN,
|
||||
} from '../../../scripts/reset-project.mjs'
|
||||
import fetch from 'node-fetch'
|
||||
import { Span } from 'next/src/trace'
|
||||
import { Span } from 'next/dist/trace'
|
||||
|
||||
export class NextDeployInstance extends NextInstance {
|
||||
private _cliOutput: string
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import spawn from 'cross-spawn'
|
||||
import { Span } from 'next/src/trace'
|
||||
import { Span } from 'next/dist/trace'
|
||||
import { NextInstance } from './base'
|
||||
import { getTurbopackFlag } from '../turbo'
|
||||
import stripAnsi from 'strip-ansi'
|
||||
|
|
|
@ -2,7 +2,7 @@ import path from 'path'
|
|||
import fs from 'fs-extra'
|
||||
import { NextInstance } from './base'
|
||||
import spawn from 'cross-spawn'
|
||||
import { Span } from 'next/src/trace'
|
||||
import { Span } from 'next/dist/trace'
|
||||
import stripAnsi from 'strip-ansi'
|
||||
|
||||
export class NextStartInstance extends NextInstance {
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
// Make development mode typescript module resolving and jsx parsing correct for all tests.
|
||||
// We want to apply the compiler options to the testing app, but we don't want to do strict type checking for them.
|
||||
// e.g. testing app could have import a from '3rd-lib-nextjs-ws-doesnt-have'
|
||||
{
|
||||
"extends": "../tsconfig.base.json"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import postcss from 'postcss'
|
||||
|
||||
import mod from 'next/src/bundles/cssnano-simple/index'
|
||||
import mod from 'next/dist/compiled/cssnano-simple/index'
|
||||
import css from '../noop-template'
|
||||
|
||||
describe('basic test', () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import postcss from 'postcss'
|
||||
|
||||
import mod from 'next/src/bundles/cssnano-simple/index'
|
||||
import mod from 'next/dist/compiled/cssnano-simple/index'
|
||||
import css from '../noop-template'
|
||||
|
||||
describe('exclude all test', () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import postcss from 'postcss'
|
||||
|
||||
import mod from 'next/src/bundles/cssnano-simple/index'
|
||||
import mod from 'next/dist/compiled/cssnano-simple'
|
||||
import css from '../noop-template'
|
||||
|
||||
describe('accepts plugin configuration', () => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import { expectTypeOf } from 'expect-type'
|
||||
import { NextRequest } from 'next/src/server/web/spec-extension/request'
|
||||
import { NextRequest } from 'next/dist/server/web/spec-extension/request'
|
||||
|
||||
it('should have 1 required parameter for constructor', () => {
|
||||
expect(NextRequest.length).toBe(1)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @jest-environment @edge-runtime/jest-environment
|
||||
*/
|
||||
|
||||
import { NextResponse } from 'next/src/server/web/spec-extension/response'
|
||||
import { NextResponse } from 'next/dist/server/web/spec-extension/response'
|
||||
|
||||
it('reflect .set into `set-cookie`', async () => {
|
||||
const response = new NextResponse()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @jest-environment @edge-runtime/jest-environment
|
||||
*/
|
||||
|
||||
import { NextResponse } from 'next/src/server/web/spec-extension/response'
|
||||
import { NextResponse } from 'next/dist/server/web/spec-extension/response'
|
||||
|
||||
const toJSON = async (response: Response) => ({
|
||||
body: await response.json(),
|
||||
|
|
Loading…
Reference in a new issue