Skip to content

Commit

Permalink
fix: next build in typescript 5.0 (#45275)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
himself65 authored Jan 27, 2023
1 parent b90b48e commit 01cd4ab
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ function getDesiredCompilerOptions(
reason: 'for dynamic import() support',
},
moduleResolution: {
parsedValue: ts.ModuleResolutionKind.NodeJs,
// In TypeScript 5.0, `NodeJs` has renamed to `Node10`
parsedValue:
(ts.ModuleResolutionKind as any).Node10 ??
ts.ModuleResolutionKind.NodeJs,
// All of these values work:
parsedValues: [
ts.ModuleResolutionKind.NodeJs,
(ts.ModuleResolutionKind as any).Node10 ??
ts.ModuleResolutionKind.NodeJs,
// only newer TypeScript versions have this field, it
// will be filtered for new versions of TypeScript
(ts.ModuleResolutionKind as any).Node12,
Expand Down

0 comments on commit 01cd4ab

Please sign in to comment.