What does this declaration show about TypeScript’s ‘this’ parameter? function toArray(this: { items: number[] }): number[] { return this.items; }

TypeScript Professional Hard

TypeScript Professional — Hard

What does this declaration show about TypeScript’s ‘this’ parameter? function toArray(this: { items: number[] }): number[] { return this.items; }

Key points

  • TypeScript's 'this' parameter is erased at compile time
  • Enforces calling context type at the call site
  • Helps maintain type safety in function calls

Ready to go further?

Related questions