About 224,000 results
Open links in new tab
  1. typescript - How to define type for a function callback (as any ...

    367 Typescript from v1.4 has the type keyword which declares a type alias (analogous to a typedef in C/C++). You can declare your callback type thus:

  2. How to declare Return Types for Functions in TypeScript

    You can read more about function types in the language specification in sections 3.5.3.5 and 3.5.5. The TypeScript compiler will infer types when it can, and this is done you do not need to specify explicit …

  3. typescript - How to apply a function type to a function declaration ...

    Nov 21, 2021 · type Add = (x:number, y:number) => number I can declare a const of that type and define the rest of the function without having to specify the types explicitly. Typescript knows that x is …

  4. How to declare a function type in typescript - Stack Overflow

    Dec 4, 2018 · 20 I am working with typescript and passing a function into another function. If I have a function that is passed into another function in typescript how should I write the type? I have tried …

  5. Overloading Typescript function with generics - Stack Overflow

    Jul 6, 2023 · 2 The trick with overloading functions in typescript is the last function argument declaration. Typescript ignores this last declaration externally from the function and uses only this declaration for …

  6. TypeScript function overloading - Stack Overflow

    Section 6.3 of the TypeScript language spec talks about function overloading and gives concrete examples on how to implement this. However if I try something like this: export class LayerFactory {...

  7. Specify return type in TypeScript arrow function - Stack Overflow

    Specify return type in TypeScript arrow function Asked 9 years, 1 month ago Modified 1 year ago Viewed 246k times

  8. typescript - Function declarations or expressions for class methods ...

    Aug 25, 2016 · A coworker of mine and I have had this discussion several times. There are two ways to define class methods. The first way is with a function declaration: class Action { public execute(): void...

  9. javascript - TypeScript declaration file for function with variable ...

    Oct 18, 2012 · The function arguments part of a function declaration in Javascript is just advisory. When calling a function Javascript allows you to call with less than the declared number of arguments …

  10. Typescript function declaration separate from implementation

    Aug 6, 2019 · I'd like to write a specification for a set of Typescript functions with the implementations in a separate file, and then have tsc check that the actual implementations match the specification.