I am unable to import xml file in tsx file, but in jsx file i can able to access that xml file
Asked
Active
Viewed 3,775 times
2 Answers
4
You need to define a module for typescript to evaluate, otherwise it will try to look for something like toolbox.xml.ts
.
Something along these lines in a file called XML.d.ts (for this placed in a folder @types in src):
declare module "*.xml" {
const doc: any; // Change this to an actual XML type
export default doc;
}
and add "typeRoots": ["src/@types", "node_modules/@types"]
to your tsconfig.json (this makes typescript pick up the new typings file along with all installed types).

Elias Schablowski
- 2,619
- 9
- 19
-1
I have the same issue and am not sure how this works; I cannot even solve a simple txt file import issue. In my case, my target is esnext and ESM modules

Rati_Ge
- 1,262
- 2
- 15
- 37