new(…args) => T syntax

前端 未结 1 919
盖世英雄少女心
盖世英雄少女心 2021-01-03 07:58

I\'ve come across the following type annotation on a function parameter:

typeFilter : new(...args) => T

where T is a generi

相关标签:
1条回答
  • 2021-01-03 08:25

    TL;DR new(...args) => T represents constructor of T taking any parameters.

    new describes "static" part of a class/function, meaning it is a constructor and consumer can create new instance of T using new keyword. Example here.

    As for ...args - these are rest parameters

    Rest parameters are treated as a boundless number of optional parameters. When passing arguments for a rest parameter, you can use as many as you want; you can even pass none

    0 讨论(0)
提交回复
热议问题