-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Protected field with same name in two classes messing up type constraint when narrowing array. #49517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Workaround type Broken<V extends Array<Foo | Bar>> = {
readonly [P in keyof V]: V[P] extends (infer T extends Foo) ? Nothing<T> : never;
}; |
Thanks. Workaround works fine in the real code too 😄 |
It seems that the workaround breaks |
@typescript-bot bisect good v4.6.4 bad v4.7.4 |
The change between v4.6.4 and v4.7.4 occurred at 787bb9d. |
Hey this is the second bisect today that blames #48837 😅 |
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript. Issue body code block by @Jym77 ❌ Failed: -
Historical Information
|
Bug Report
(I'm not even sure how to properly name that issue 🙃 )
🔎 Search Terms
typescript inheritance protected intersection
🕗 Version & Regression Information
Seen it recently in 4.6.2. Update to 4.7.3 without changing the behaviour (and 4.8.0 nightly in the playground). I don't know if it was here before.
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
(error located at the
V[P]
inNothing<V[P]>
)Changing
foo
fromprotected
topublic
in eitherFoo
orBar
makes the error disappear.Removing (or renaming)
protected foo = 0
from eitherFoo
orBar
makes the error disappear.Replacing the
Array<Foo | Bar>
inBroken
byArray<Foo>
makes the error disappear.🙂 Expected behavior
Since
V[P]
is already in a type guard that is the same as the constraint forNothing
, this should not generate any typing error.The text was updated successfully, but these errors were encountered: