About 462 results
Open links in new tab
  1. TypeScript: Handbook - Interfaces

    In our first example using interfaces, TypeScript lets us pass { size: number; label: string; } to something that only expected a { label: string; }. We also just learned about optional properties, and how they’re useful when describing so-called “option bags”.

  2. TypeScript: Documentation - Everyday Types

    Using interfaces with extends can often be more performant for the compiler than type aliases with intersections; For the most part, you can choose based on personal preference, and TypeScript will tell you if it needs something to be the other kind of declaration. If you would like a heuristic, use interface until you need to use features from ...

  3. Documentation - TypeScript for JavaScript Programmers

    You should prefer interface. Use type when you need specific features. Composing Types. With TypeScript, you can create complex types by combining simple ones. There are two popular ways to do so: unions and generics. Unions. With a union, you …

  4. TypeScript Tooling in 5 minutes

    Interfaces. Let’s develop our sample further. Here we use an interface that describes objects that have a firstName and lastName field. In TypeScript, two types are compatible if their internal structure is compatible. This allows us to implement an interface just by having the shape the interface requires, without an explicit implements clause.

  5. TypeScript: Playground Example - Types vs Interfaces

    However for publicly exposed types, it's a better call to make them an interface. One of the best resources for seeing all of the edge cases around types vs interfaces, this stack overflow thread is a good place to start: https://stackoverflow.com/questions/37233735/typescript-interfaces-vs-types/52682220#52682220

  6. TypeScript: Documentation - Generics

    In this section, we’ll explore the type of the functions themselves and how to create generic interfaces. The type of generic functions is just like those of non-generic functions, with the type parameters listed first, similarly to function declarations:

  7. TypeScript: Documentation - Modules .d.ts

    The TypeScript playground can show you the .d.ts equivalent for JavaScript code. You can try it yourself here . The .d.ts syntax intentionally looks like ES Modules syntax.

  8. TypeScript: Documentation - Classes

    You can use this is Type in the return position for methods in classes and interfaces. When mixed with a type narrowing (e.g. if statements) the type of the target object would be narrowed to the specified Type.

  9. TypeScript Cheat Sheets

    Downloadable syntax reference pages for different parts of everyday TypeScript code. Learn more about Classes, Interfaces, Types and Control Flow Analysis

  10. TypeScript: Documentation - Symbols

    All of the common types in TypeScript. Creating Types from Types. Techniques to make more elegant types. More on Functions. How to provide types to functions in JavaScript. More on Objects. How to provide a type shape to JavaScript objects. Narrowing. How TypeScript infers types based on runtime behavior. Variable Declarations

Refresh