code as follow
My expected is if b
is not declared, there should be no b
in the assigned value.
My another expected is if b
is not declared, there should be any b
in the assigned value, but also c
d
...
type Target =
| {
a: 1;
}
| {
a: 2;
b: number;
}
| {
a: 3;
b: boolean;
};
// The result is
const target: Target = {
a: 1,
// correct
};
const target: Target = {
a: 1,
b: 1, // correct
};
const target: Target = {
a: 1,
b: "true", // incorrect
};
const target: Target = {
a: 1,
b: true, // correct
};
// My expected result is
const target: Target = {
a: 1,
// correct
};
const target: Target = {
a: 1,
b: 1, // incorrect
};
const target: Target = {
a: 1,
b: "true", // incorrect
};
const target: Target = {
a: 1,
b: true, // incorrect
};
// My another expected result is
const target: Target = {
a: 1,
// correct
};
const target: Target = {
a: 1,
b: 1, // correct
};
const target: Target = {
a: 1,
b: "true", // correct
};
const target: Target = {
a: 1,
b: true, // correct
};
const target: Target = {
a: 1,
c: true, // correct
};
How can this be completed?