Can I disable a global type declaration?

Viewed 193

I would happily take edits on this title.

I am using npm install gsap and it comes with Types which is great! But I believe part of those types is a gsap global.

This means that at author time, I can use gsap and I get no errors, my build is a success, but I forgot to import { gsap } from "gsap" into the files that actually use it. So it fails at runtime only if you hit that non-imported code. VSCode thinks a global is there available to my project, but there isn't one in reality, and so even auto imports are skipped.

Is there a way to somehow disable global module declarations either on a per library basis or entirely? I want to use the types, but the ambient declation(?) included with them is hurting.

Sample:

// no imports
export class MyClass {
    constructor() {
        gsap.to(this, { y: 100 });
      //^^^^ gsap isn't imported,  this should be throwing an error
    }
}

0 Answers
Related