DEV Community

Discussion on: Vanilla TypeScript (gts)

Collapse
 
rfornal profile image
bob.ts

I'll look at that option; this article was something I came across ... perhaps I'll run this pattern on the next project I do. The article I found that generated this one was two years old and piqued my curiosity.

  1. Unfortunately, I didn't find this on a quick search.
  2. I did find something interesting I wanted to try out.

As to <any>window ... there is a specific need within my project (which will be made public soon, not yet).

Thanks for the "food for thought," awesome information!

Collapse
 
elarcis profile image
Elarcis • Edited

There is a way to extend the Window interface and declare the type of your globals so that you don't lose TS's help (using any should always be avoided):in a typings.d.ts file possibly at the root of your source folder, write something like that:

declare global {
  interface Window {
    myGlobal: string;
  }
}
Thread Thread
 
rfornal profile image
bob.ts

Elegant. I’ve gone through a few other things. I’ll try it out.