zspitz / ts-activex-gen

Library + UI for generating Typescript definitions / DefinitelyTyped packages from COM type libraries / LibreOffice Doxygen XML
MIT License
12 stars 4 forks source link

Define event handler argument names and argument parameters as type aliases and interfaces, respectively #53

Closed zspitz closed 7 years ago

zspitz commented 7 years ago

Will hopefully resolve #51. Use #52 to hold the types:

namespace Word {
    namespace EventHelperTypes {
        //for the event EPostageInsertExEvent
       type EPostageInsertExEvent_ArgNames = ['Doc', 'cpDeliveryAddrStart', 'cpDeliveryAddrEnd', 'cpReturnAddrStart', 'cpReturnAddrEnd', 'xaWidth', 'yaHeight', 'bstrPrinterName',
        'bstrPaperFeed', 'fPrint', 'fCancel'];

        interface EPostageInsertExEvent_Parameter {
            readonly Doc: Word.Document;
            cpDeliverAddrStart: number;
            readonly cpReturnAddrEnd: number;
            readonly xaWidth: number;
            readonly yaHeight: number;
            readonly bstrPrinterName: string;
            readonly bstrPaperFeed: string;
            readonly fPrint: boolean;
            fCancel: boolean;
        }
    }
}

and the resultant on signature:

    on(
        obj: Word.Application, event: 'EPostageInsertEx', argNames: Word.EventHelperTypes.EPostageInsertExEvent_ArgNames, handler: (
            this: Word.Document, parameter: Word.EventHelperTypes.EPostageInsertExEvent_Parameter) => void): void;
zspitz commented 7 years ago

https://stackoverflow.com/q/45235028/111794