DEV Community

Bruce Axtens
Bruce Axtens

Posted on

Typescript type declarations

Hey wow, you can embed namespaces within namespaces!

        var resp = CSEncoding.Default.GetString(rBody, 0, rBody.Length);
Enter fullscreen mode Exit fullscreen mode

I was wondering how I'd get that into external.d.ts and this is what works:

declare namespace CSEncoding {
    declare namespace Default {
        function GetString(s:string,n1:number,n2:number):string;
    }
}
Enter fullscreen mode Exit fullscreen mode

LATER

Uh oh, maybe you can't. Just reloaded the file and now I'm getting the following error:

A 'declare' modifier cannot be used in an already ambient context.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)