Syntax

TypeScript Typed Class Syntax

In TypeScript, typed class: defines a class with typed fields — class Dog { constructor(public name: string) {} }

Quick Answer

Syntax
class Dog { constructor(public name: string) {} }
TypeScriptSyntax

Typed Class

Code example
class Dog { constructor(public name: string) {} }

Defines a class with typed fields.

Learn More

How to typed class in TypeScript

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

TypeScript Typed Class Syntax

Use class Dog { constructor(public name: string) {} }.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for typed class?

Use this pattern: class Dog { constructor(public 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