2017-06-19 4 views

Antwort

4

Ist das möglich?

Ja, wie unten gezeigt:

export interface IGrid { 
    gridFormat(gridCell: GridCell, grid: Grid): boolean 
} 

function validateFormat(validator: IGrid['gridFormat']) { // MAGIC 
    // ... 
} 
1

Sie können so etwas wie das folgende versuchen:

export interface IGrid { 
    gridFormat(gridCell: GridCell, grid: Grid): boolean 
} 

declare let igrid: IGrid; 

export class Test { 
    validateFormat(validator: typeof igrid.gridFormat) { 
    // ... 
    } 
} 

Darüber hinaus können Sie auch einen Typ für die Methode, wie erklären unter

declare type gridFormatMethodType = typeof igrid.gridFormat 

die umständliche Methode Signatur für validateFormat

zu vermeiden
validateFormat(validator: gridFormatMethodType){ ... } 

Hoffe, das hilft.

Verwandte Themen