type script: Method 2 Array<type name> in the example below is a generic declaration method of an array type.
that is, if declared as an Array [Type Name], it will declare an array type containing only the content declared by the type name.
interface Bread{};
let applePie:Bread[]; // 1.Type name[]
let meetPie:Array<Bread>; // 2.Array<TypeName>
When using Promise in a type script by default, It is convenient to think that
is applying the generic type and getting the type back.function fetchItems(): Promise<string[]> { const items: string[] = ['a', 'b', 'c']; return new Promise(function(resolve) { // This part usually includes an asynchronous processing function resolve(items); }); }
TypeScript Example
// The example below defines the type for the function defineEventHandler
const defineEventHandler: <EventHandlerRequest, {
data: {name:string}[];
}>(handler: EventHandler<...> | EventHandlerObject<...>) => EventHandler<...>
// Example with the above function type signature
const definedEventHandler = defineEventHandler<EventHandlerRequest, typeof eventHandlerObject>(eventHandlerObject);
// It can be seen information below
함수명<제네릭타입>(매개변수)
참조
Oct 28, 2023
Views 122