Skip to content

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

Closed
@OliverJAsh

Description

@OliverJAsh

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);

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions