Search code examples
reactjstypescriptcreate-react-appreact-typescript

Module not found: Can't resoulve *.d.ts in "/file/path" in React TypeScript bootstrap with create-react-app


I'm new to TypeScript and likes to separate my type definition from my code so I created a *.d.ts file but the exported TS definition cannot be imported and use on other module file


Module not found: Can't resoulve *.d.ts in "/file/path"

would someone recommended a fix or explanation why this happen ?

enter image description here


Solution

  • The solution I found in my case is that if you import something from *.d.ts. If your file is name data.d.ts you can import it like this.

    import { testA } from data.d
    

    notice the data.d from which the name of the file that you want to import is data.d.ts