I am writing a TypeScript definition file (.d.ts) for a JS library that doesn't currently have one.
Other .d.ts file seem to put all the types into the 'global' namespace (if you see what I mean), whereas I am trying do the following:
// root valerie object
//
declare var valerie: Valerie.ValerieStatic;
// additional types for Valerie (all inside this virtual namespace)
declare module Valerie {
//
// Static methods on valerie namespace
//
interface ValerieStatic {
// definitions go here.....
This means that I don't potentially get my interfaces crossed with others should they exist.
My question is - it seems to work, but is there a possible problem with this approach?
In general this is a good approach. If there are some interface types inside the Valerie
module that you would expect people to be using often, you might consider promoting them to top-level so it's more convenient to reference them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With