'What is the scope of .d.ts files
So I am using react-table in a Typescript Next.js projects. This package consists of modules (like sorting, pagination, etc...) that aren't included by default but must be enabled in the main useTable hook. By default the types are set up in a way that doesn't include properties related to the modules.
I am following the following instructions: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table
Where it says to create a react-table-config.d.ts file and place it somewhere in my source directory and then modify it to only include the modules I need.
However while I might need some modules in one component, I might not need it in another. So I was wondering whether such files have a global scope or if it is possible to have two such files for two seperate components.
So for example if I have the following directory structure:
src
|
|-- components
| |
| |-- sorted-table
| | |
| | |-- index.tsx
| | |
| | |-- react-table-config.d.ts
| |
| |-- paginated-table
| | |
| | |-- index.tsx
. . |
. . |-- react-table-config.d.ts
. .
```
Solution 1:[1]
I think it doesn't matter where you place it if used like this
declare global{
//write any interface,type,etc
}
// in the end of the file
export {};
now you will be able to use anything from the file with out the need to import it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Super sub |
