Skip to content

Incompatible with node12 TypesScript module resolution #6641

Closed
@demurgos

Description

@demurgos

Bug Report

Current Behavior
I am trying out the upcoming TypeScript 4.5.0 version (currently in beta), and its new "moduleResolution": "node12".

With the following tsconfig.json:

{
  "compilerOptions": {
    "module": "node12",
    "moduleResolution": "node12",
    "target": "es2021",
    "noImplicitAny": true
  }
}

I get the following error when trying to import from "rxjs":

main.mts:1:28 - error TS7016: Could not find a declaration file for module 'rxjs'. '/data/projects/various/rxjs-ts-node12/node_modules/rxjs/dist/cjs/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/rxjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'rxjs';`

1 import { Observable } from "rxjs";
                             ~~~~~~


Found 1 error.

Expected behavior

The type declaration for rxjs should be resolved.

Reproduction

The tsconfig.json should be enough to reproduce the issue. Here is a repo set-up to reproduce the issue: https://github.com/demurgos/rxjs-ts-node12.

Environment

  • Runtime: Node 12+ (with ESM support)
  • RxJS version: 7.4.0
  • (If bug is related) Loader, build configuration: N/A

Possible Solution

Add a types field above node to the exports config in the package.json.

Additional context/Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions