Type Declaration

Noun · Development

Definitions

  1. A statement that introduces a new named type into the type system — such as an `interface`, `type`, `class`, or `enum` in TypeScript, or a `struct`/`enum` in Rust. In TypeScript specifically, `.d.ts` declaration files provide type information for JavaScript libraries without containing runtime code, enabling type checking against untyped packages.

    In plain English: Formally defining a new named type in your code so the compiler knows what shape the data should have.

    Example: "The library doesn't ship types, so I wrote a type declaration file to get autocomplete and type checking working."

Related Terms