You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incompatible with node12 TypesScript module resolution #6641
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.
I think we may need few internal try to understand some of behaviors.
One of notable thing is rxjs does not support native esm yet. I'm not sure what's implication if we add this property for both of cases, if tsc try to import as native esm vs. other tooling's esm handling behavior such as tree shaking.
Peeking this bit more, there is specific concern from TSC's core team iteslf microsoft/TypeScript#46452.
We will observe official release & discussion thread itself, along with some internal understandings how this'll affect across users of rxjs. Which means, we'll not try to make any immediate changes for now unfortunately.
If you try to use these settings in TypeScript 4.5 RC or stable, you’ll receive an error message directing you to use a nightly build instead
Given we do not support our official release for non-release version of typescript, I do not think we'll going to have this until tsc gets finalized support for this feature.
We'll keep follow latest upstream and will try to align with ecosystem but at this moment this issue better to be closed as no one knows later upstream tsc will have exact same way to support this or will there be breaking features.
The types need to be mentioned in tsconfig.json I guess.
I have added this "./node_modules/rxjs/dist/types/**/*.d.ts" to "typeRoots". But still facing this issue.
I'm also facing the same issue (with "rxjs": "7.2.0") and I noticed lots of .ts files are under node_modules/rxjs/dist/types/. However, import { Observable } from "rxjs" fails with the same error as mentioned on the first post.
Activity
fix: Add types to the package export map
ievgennaida commentedon Oct 16, 2021
Same problem when "module": "esnext" is used.
RxJS version: 7.4.0
Typescript 4.4.4
demurgos commentedon Oct 28, 2021
@benlesh @kwonoj
I sent a patch in #6642 to fix this issue.
Could you review it please?
This issue is the main blocker preventing my projects from fully using true ESM.
kwonoj commentedon Oct 29, 2021
I think we may need few internal try to understand some of behaviors.
One of notable thing is rxjs does not support native esm yet. I'm not sure what's implication if we add this property for both of cases, if tsc try to import as native esm vs. other tooling's esm handling behavior such as tree shaking.
kwonoj commentedon Oct 29, 2021
Peeking this bit more, there is specific concern from TSC's core team iteslf microsoft/TypeScript#46452.
We will observe official release & discussion thread itself, along with some internal understandings how this'll affect across users of rxjs. Which means, we'll not try to make any immediate changes for now unfortunately.
kwonoj commentedon Nov 2, 2021
See ref: #6642 (comment)
In short, tsc will not enable this for the release (https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-rc/#beta-delta)
Given we do not support our official release for non-release version of typescript, I do not think we'll going to have this until tsc gets finalized support for this feature.
We'll keep follow latest upstream and will try to align with ecosystem but at this moment this issue better to be closed as no one knows later upstream tsc will have exact same way to support this or will there be breaking features.
Please feel free to create new suggestions via discussions (https://github.com/ReactiveX/rxjs/discussions) for the feature request when tsc supports similar officially if needed.
lazy-coder-1 commentedon Mar 18, 2022
The types need to be mentioned in tsconfig.json I guess.
I have added this "./node_modules/rxjs/dist/types/**/*.d.ts" to "typeRoots". But still facing this issue.
snawaz commentedon Oct 2, 2022
I'm also facing the same issue (with
"rxjs": "7.2.0") and I noticed lots of.tsfiles are undernode_modules/rxjs/dist/types/. However,import { Observable } from "rxjs"fails with the same error as mentioned on the first post.My project
tsconfig.jsonis this:{ "compilerOptions": { "module": "commonjs", "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "lib": ["ES2019"], "target": "es2019", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "strict": true, "allowJs": true, "skipLibCheck": true, "jsx": "preserve" }, "exclude": [ "dist/**" ] }and
How do I fix this issue?