Basically I am trying to customize a library file written in plain javascript and put it as a local file in a React-Native typescript project, the moment I try to convert the .js file to .ts/.tsx file, it throws a lots of linting issues, so fixing it is bit chaotic so I thought of keeping it as .js file only but I don't want to make any changes in the tsconfig file(i.e., adding jsallow = true), I know their is a way of adding some .d.ts file but not sure will it work or not and if it is, then what would be the syntax.
1 Answer
If this is a package named example, you can add types in example.d.ts using declare module "example" {}. There's more detailed information the Declaration Files Documentation.
3 Comments
Saikat Saha
it would be good if you can hint me with the exact syntax as I am aware of this one but not sure how to import the file or point to that file within the application
Nicky McCurdy
I'd need more information about what you're importing and how, as TypeScript has different syntaxes for different types of modules that aren't compatible with each other.
Saikat Saha
I have customized the index.js(github.com/computerjazz/react-native-draggable-flatlist/…) and put it locally within the application source code folder