Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.5 regression: The inferred type of '…' cannot be named without a reference to '…' #46659

Closed
OliverJAsh opened this issue Nov 3, 2021 · 2 comments · Fixed by #46670
Closed
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Recent Regression This is a new regression just found in the last major/minor version of TypeScript.

Comments

@OliverJAsh
Copy link
Contributor

Bug Report

🔎 Search Terms

  • rxjs
  • re-export
  • declaration
  • composite
  • project references

🕗 Version & Regression Information

  • This changed between versions 4.4.4 and 4.5.1-rc

⏯ Playground Link

N/A

💻 Code

package.json:

{
  "dependencies": {
    "rxjs": "^7.4.0",
    "typescript": "^4.5.1-rc"
  }
}

tsconfig.json:

{
    "compilerOptions": {
        "target": "ESNext",
        "module": "CommonJS",
        "declaration": true,
        "outDir": "./target/"
    },
    "files": ["./src/main.ts"],
}

src/facade.ts:

export { connectable, EMPTY } from 'rxjs';

src/main.ts:

import * as Rx from './facade';

export const myConnectable = Rx.connectable(Rx.EMPTY);

Steps to reproduce:

  • Run yarn
  • Run tsc

🙁 Actual behavior

No error, as it behaved in 4.4.4.

🙂 Expected behavior

Error:

$ tsc
src/main.ts:3:14 - error TS2742: The inferred type of 'myConnectable' cannot be named without a reference to '../node_modules/rxjs/dist/types'. This is likely not portable. A type annotation is necessary.

3 export const myConnectable = Rx.connectable(Rx.EMPTY);
               ~~~~~~~~~~~~~


Found 1 error.

I am able to workaround this by modifying src/facade.ts like so:

 export { connectable, EMPTY } from 'rxjs';
+export * from 'rxjs/internal/types'

Note also that the error doesn't reproduce if we import directly from rxjs:

src/main.ts:

import { EMPTY, connectable } from 'rxjs';

export const myConnectable = connectable(EMPTY);
@andrewbranch
Copy link
Member

Sounds like #46452 (comment) which would be expected for RxJS in node12/nodenext resolution mode, but you’re not in that mode 🤔

@andrewbranch andrewbranch added Bug A bug in TypeScript Recent Regression This is a new regression just found in the last major/minor version of TypeScript. labels Nov 3, 2021
@andrewbranch
Copy link
Member

It looks like module resolution ignores export maps in --moduleResolution node (expected at least for back compat—we would really break the world if we changed this), but module specifier resolution always looks at export maps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Recent Regression This is a new regression just found in the last major/minor version of TypeScript.
Projects
None yet
4 participants