Project references indirect dependencies: Error 2742 Inferred type of xxx ...
Potentially related: https://github.com/microsoft/typescript-go/issues/1034
Steps to reproduce
https://github.com/johnpyp/tsgo-monorepo-reference-issue
Setup
package-c: exportsMyTypeinterfacepackage-b: project reference topackage-c, exportscreateThing()returningMyTypepackage-a: project reference topackage-bonly (notpackage-c), usescreateThing()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 [email protected]
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.
have same issue with pnpm
Likewise
@dimitraz @samdcoding please use the thumbs up instead. It is more considerate of subscribers watching issues.
I had to disable project references with composite: false to fix it.
Some related research from typescript/pnpm repos I did:
- https://github.com/microsoft/TypeScript/issues/42873#issuecomment-2065572017
- https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189
- https://github.com/microsoft/TypeScript/pull/58176#issuecomment-2052698294
- https://github.com/pnpm/pnpm/issues/7453
I presume it's solely an issue with ts-go, not the original typescript repo?