Answers for "typescript Erased Structural Types"

0

typescript Erased Structural Types

interface Pointlike {
  x: number;
  y: number;
}
interface Named {
  name: string;
}
 
function logPoint(point: Pointlike) {
  console.log("x = " + point.x + ", y = " + point.y);
}
 
function logName(x: Named) {
  console.log("Hello, " + x.name);
}
 
const obj = {
  x: 0,
  y: 0,
  name: "Origin",
};
 
logPoint(obj);
logName(obj);
Try
Posted by: Guest on March-18-2022

Code answers related to "typescript Erased Structural Types"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language