TS - how to declare global types correctly

Viewed 57

I have an issue with the reference to a global type

In this project, window.app is a generic container that will get filled in runtime by individually lazy loaded self-invoking scripts.

This is the global declaration (root/types/app.d.ts)

export { };

declare global {
    interface Node { innerHTML: string }
    interface app {
        modules?: {
            [key: string]: string;
        },
        plugInLoader?: {
            installModule(jsContent: string): void,
            installBaseModules(): void,
            load(url: string): void,
            installerScript: Node,
        },
        /* ..., ..., ..., ..., ..., */
    }
}

The path is added to tsconfig.json

{
    "compilerOptions": {
        /*...*/
        "typeRoots": ["./node_modules/@types", "./types"],
    }
}

VS Code can resolved this type:

resolving app.plugInLoader, resolving window,app

But tsc can't find name 'app'

0 Answers
Related