The method parameters in the Class class under Nodejs are written with colons and < T >, which is similar to generics.

I see a way of writing in other people"s blogs that makes me confused. I can"t understand it. Can you tell me what version of grammar this is in ES? I only know ES6

.

clipboard.png
instance method name followed by < T >, mapper: (doc:object) = > T): promise.. in the method parameters Two colons are concatenated to indicate that they do not understand

Mar.20,2021

this should be the syntax of typescript and requires the compilation environment corresponding to typescript. But node is not enough


keywords: static type checking TypeScript flow
if you haven't seen this syntax before, you can take a look at TypeScript
< T > search < string > () pass in type
< T > . : Promise is the type of value returned by the method

Menu