Syntax

TypeScript Define an Interface Syntax

In TypeScript, define an interface: describes the shape of an object — interface User { id: number; name: string; }

Quick Answer

Syntax
interface User { id: number; name: string; }
TypeScriptSyntax

Define an Interface

Code example
interface User { id: number; name: string; }

Describes the shape of an object.

Learn More

How to define an interface in TypeScript

  1. Open your TypeScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

TypeScript Define an Interface Syntax

Use interface User { id: number; name: string; }.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for define an interface?

Use this pattern: interface User { id: number; name: string; }

Can I copy this TypeScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this TypeScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify