Augmentations for the global scope can only be directly nested in external modules or ambient module declarations(2669)

后端 未结 2 941
不思量自难忘°
不思量自难忘° 2021-02-04 23:14

I would like to store my NodeJS config in the global scope.

I tried to follow this => Extending TypeScript Global object in node.js and other solution on stackoverflow,

2条回答
  •  我在风中等你
    2021-02-04 23:35

    You can indicate that the file is a module like so:

    export {};
    
    declare global {
        namespace NodeJS {
            interface Global {
                config: MyConfigType
            }
        }
    }
    

提交回复
热议问题