You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 on bar (via project references), foo is using strict mode and bar is not using strict mode, under certain scenarios VS Code will report errors that tsc 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 with strict: false, consider a module foo.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:
exportdeclarefunctiongetMyNumber(): number;
You can also build the consuming project, foo, that is using bar, and would only compile if getMyNumber's return type is number:
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:
@Dremora this is kind of known behaviour as currently the editor uses the source files from referenced project insted of d.ts files to give you better experience without having to actually build. The issue arrises when you have different strict settings between projects. Currently you either have to choose between the not having to build referenced project to get seamless experience and these discrepancies in errors. @weswigham is currently looking into per file strict settings. once we have that we can get better experience in editor for this scenario.
I've also tried using disableSourceOfProjectReferenceRedirect, and while it resolves the issue, overall it does result in subpar developer experience compared to the default setting, so instead we will be gradually fixing strict mode errors as we encounter them in VS Code.
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: