Answers for "typescript extend imported namespace"

0

typescript extend imported namespace

// We can import a namespace in a non-declaration .ts, and export it again as a extended type:

// custom-fc.ts : enhances declaration of FC namespace
import * as origFC from "fullcalendar";

declare namespace Complimentary {
    class TimeGrid {
        prepareHits(): void;
    }
    let views: any;
}

// apply additional types to origFc and export again
export const FC: (typeof Complimentary & typeof origFC) = origFC as any;
Posted by: Guest on October-04-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language