Skip to content

Project references indirect dependencies: Error 2742 Inferred type of xxx ... #2233

@johnpyp

Description

@johnpyp

Potentially related: #1034

Steps to reproduce

https://github.com/johnpyp/tsgo-monorepo-reference-issue

Setup

  • package-c: exports MyType interface
  • package-b: project reference to package-c, exports createThing() returning MyType
  • package-a: project reference to package-b only (not package-c), uses createThing() without type annotation

The issue is that package-a reaches package-c types transitively through package-b, but doesn't have a direct project reference to package-c.

Behavior with typescript@5.9

No error

Behavior with tsgo

packages/package-a/src/index.ts(4,10): error TS2742: The inferred type of 'thing' cannot be named without a reference to '../../package-b/node_modules/package-c/out'. This is likely not portable. A type annotation is necessary.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions