Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99078

Custom global variable does not exist

$
0
0

I am trying to extend the Global object in Node, but am having no luck at all. Here is what I have:

custom.d.ts:

declare namespace NodeJS {
interface Global {
  test: string;
}
}

tsconfig.json:

"files": [
"./src/types/custom.d.ts"
]

Based on the links I've found on SO, these updates should allow me to use 'global.test'. However, when I try that, the editor complains that 'test' does not exist on global.

Am I setting this up correctly? Is there some other setting I'm missing?

Follow-up: Maybe the issue is with my tsconfig.json file. Here it is:

{
"compilerOptions": {
"target": "es6",                       /* Specify ECMAScript target 
version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 
'ES2019' or 'ESNEXT'. */
"module": "commonjs",                     /* Specify module code 
generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 
'ESNext'. */
"sourceMap": true,                        /* Generates corresponding 
'.map' file. */
"outDir": "dist",                         /* Redirect output structure 
to the directory. */
"strict": true,                           /* Enable all strict type- 
checking options. */
"noImplicitAny": false,                 /* Raise error on expressions 
and declarations with an implied 'any' type. */
"esModuleInterop": true,                /* Enables emit interoperability 
between CommonJS and ES Modules via creation of namespace objects for 
all imports. Implies 'allowSyntheticDefaultImports'. */
"forceConsistentCasingInFileNames": true  /* Disallow inconsistently- 
cased references to the same file. */
},
  "files": ["src/types/custom.d.ts"]
}

For some reason, if I leave the "files" there, Visual Studio TSC Watch stops automatically compiling. If I remove it, everything returns to normal.


Viewing all articles
Browse latest Browse all 99078

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>