typescript any object type code example

Example 1: typescript object type

//is not strict mode
let endedCoord: {x: number, y: number} = {
  	x: -1,
  	y: -1,
}

Example 2: typescript type of object values

const data = {
  value: 123,
  text: 'text'
};
type Data = typeof data;

Example 3: typescript operate with html objects

ts// 1. Select the div element using the id property
const app = document.getElementById("app");

// 2. Create a new <p></p> element programmatically
const p = document.createElement("p");

// 3. Add the text content
p.textContent = "Hello, World!";

// 4. Append the p element to the div element
app?.appendChild(p);