A project reference setup using both strict and non-strict modes produces errors in VS Code #50035
Labels
Working as Intended
The behavior described is the intended behavior; this is not a bug
Bug Report
🔎 Search Terms
project references
project references vs code
🕗 Version & Regression Information
When did you start seeing this bug occur?
TypeScript 4.4.2+ (and likely earlier).
Tried 4.8.0-dev.20220725.
This is the behavior in every version I tried, and I reviewed the FAQ for entries about VS Code behaviour.
⏯ Playground Link
GitHub repo (impossible to reproduce in a playground).
💻 Code
🙁 Actual behavior
In a setup with two projects, where
foo
depends onbar
(via project references),foo
is using strict mode andbar
is not using strict mode, under certain scenarios VS Code will report errors thattsc
doesn't.This seems to happen when in the child project inferred types are generated.
The issue is best understood by looking at the reproduction repo.
In a project (
bar
) compiled withstrict: false
, consider a modulefoo.ts
:and
index.ts
:Here, the inferred type of
getMyNumber
is(): number
. If you build the project from the example repo (pnpm tsc -b bar
), this will be reflected in the generated.d.ts
file,dist/bar/index.d.ts
:You can also build the consuming project,
foo
, that is usingbar
, and would only compile ifgetMyNumber
's return type isnumber
:pnpm tsc -b foo
However, if you open
foo/index.ts
in VS Code, it will be reporting errors:🙂 Expected behavior
VS Code should behave like the
tsc
compiler.The text was updated successfully, but these errors were encountered: