Answer the question
In order to leave comments, you need to log in
How to determine from 2 types: 1 or 2?
I am new to typing.
I have 2 types.
type Point = {
x: number;
y: number;
};
type Label = {
name: string;
};
let Duko: ? = {...};
let Duko = {
x: 0,
y: 0,
};
или
let Duko = {
name: "origin"
};
Answer the question
In order to leave comments, you need to log in
There is some crutch that can be dug out in the propositions of the typescript. Perhaps someday something like this will become part of the language. But this bullshit assumes that there can be no intersecting properties.
https://www.typescriptlang.org/play/index.html#cod...
In general, you just need to write in such a way that you don’t have to pervert like that. Make tipguards on the edge.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question