Answer the question
In order to leave comments, you need to log in
TypeScript interfaces accessed from global space?
I have this line in my config.
"types": ["react","node","ragemp-c"]
, I installed these interfaces via NPM package. And they are available in the global space, I can not import them in order to initialize. How can I do the same with my working interfaces?
Answer the question
In order to leave comments, you need to log in
You can specify in the types field any package installed in node_modules or in node_modules/@types that has the types field in package.json
. You can also simply drop a file with any name with a .d.ts extension to the root of the project (where tsconfig.json ), but with such a name that the .js file of the same name does not lie next to it, for example global.d.ts if global.js is missing.
Any declarations in such a file will be global.
You can also declare modules for import in it, for example for css-modules:
declare module '*.css' {
const classes: Readonly<Record<string, string>>;
export default classes;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question