Skip to content

logic operator for 2 incompatible inherit class cause error #2407

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

Closed
HerrCai0907 opened this issue Aug 5, 2022 · 1 comment
Closed

logic operator for 2 incompatible inherit class cause error #2407

HerrCai0907 opened this issue Aug 5, 2022 · 1 comment
Labels

Comments

@HerrCai0907
Copy link
Member

class A {}
class B extends A {}
class D extends A {}

export function testOr(v: B | null): void {
  let v0: A | null = v || new D();
  let v1: A | null = v && new D();
}
ERROR TS2322: Type 'assembly/index/D' is not assignable to type 'assembly/index/B | null'.
   :
 6 │ let v0: A | null = v || new D();
   │                         ~~~~~~~
   └─ in assembly/index.ts(6,27)

ERROR TS2322: Type 'assembly/index/D' is not assignable to type 'assembly/index/B | null'.
   :
 7 │ let v1: A | null = v && new D();
   │                         ~~~~~~~
   └─ in assembly/index.ts(7,27)
@dcodeIO
Copy link
Member

dcodeIO commented Jan 6, 2023

This particular issue has been addressed in #2594.

@dcodeIO dcodeIO closed this as completed Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants