Suggestion
interface Type {
isA?: true;
isB?: false;
}
class A implements Type {
isA: true = true;
a = 1;
}
let a: A;
a.isA
a.isB
🔍 Search Terms
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
class implements interface completions
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
📃 Motivating Example
💻 Use Cases
use case
interface Type {
isA?: false;
isB?: false;
}
type PickType<T extends keyof Type> = {
[K in keyof Type]?: K extends T ? true : false | undefined;
};
class A implements PickType<'isA'> {
isA: true = true;
a = 1;
}
class B implements PickType<'isB'> {
isB: true = true;
b = 1;
}
type AorB = A | B;
let a: AorB | undefined;
if (a) {
if (a.isA) a.a; // error Property 'isA' does not exist on type 'B'
if (a.isB) a.b; // error Property 'isB' does not exist on type 'A'
}
typescriptlang live link
Suggestion
🔍 Search Terms
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
class implements interface completions
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
📃 Motivating Example
💻 Use Cases
use case
typescriptlang live link