Skip to content

Commit 01cd4ab

Browse files
authored
fix: next build in typescript 5.0 (#45275)
Related: https://github.com/microsoft/TypeScript/blob/ff92ab0ac92b66397bd3b92ff5a3aca3c1ad8f43/src/compiler/types.ts#L6901 Upstream: https://github.com/microsoft/TypeScript/pull/51901/files#diff-e9fd483341eea176a38fbd370590e1dc65ce2d9bf70bfd317c5407f04dba9560R6890 ```shell > @blocksuite/next-example@ build /Users/himself65/Code/blocksuite/packages/react/examples/next > next build info - Linting and checking validity of types ..We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false by default. The following mandatory changes were made to your tsconfig.json: - moduleResolution was set to node (to match webpack resolution) warn - TypeScript project references are not fully supported. Attempting to build in incremental mode. > Build error occurred Error: Debug Failure. Unexpected moduleResolution: node at resolveModuleName (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:39044:24) at Object.resolve (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:114797:47) at loadWithModeAwareCache (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:114837:40) at actualResolveModuleNamesWorker (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:115072:126) at resolveModuleNamesWorker (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:115389:22) at resolveModuleNamesReusingOldState (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:115541:77) at processImportedModules (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:117013:29) at findSourceFileWorker (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:116775:9) at findSourceFile (/Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:116640:22) at /Users/himself65/Code/blocksuite/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js:116589:24 { type: 'Error' } info - Linting and checking validity of types . ELIFECYCLE  Command failed with exit code 1. Process finished with exit code 1 ``` ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent b90b48e commit 01cd4ab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/next/src/lib/typescript/writeConfigurationDefaults.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ function getDesiredCompilerOptions(
5353
reason: 'for dynamic import() support',
5454
},
5555
moduleResolution: {
56-
parsedValue: ts.ModuleResolutionKind.NodeJs,
56+
// In TypeScript 5.0, `NodeJs` has renamed to `Node10`
57+
parsedValue:
58+
(ts.ModuleResolutionKind as any).Node10 ??
59+
ts.ModuleResolutionKind.NodeJs,
5760
// All of these values work:
5861
parsedValues: [
59-
ts.ModuleResolutionKind.NodeJs,
62+
(ts.ModuleResolutionKind as any).Node10 ??
63+
ts.ModuleResolutionKind.NodeJs,
6064
// only newer TypeScript versions have this field, it
6165
// will be filtered for new versions of TypeScript
6266
(ts.ModuleResolutionKind as any).Node12,

0 commit comments

Comments
 (0)