2

I'm using a 3rd party Javascript library that comes with an index.d.ts file. However, that file is not compatible with my version of TS. I've made a fix that works for me and submitted it to the library creator. In the meanwhile, I'd like to use this fix. I need to commit it to VCS for my entire team to use. node_modules folder is not committed to VCS, its content is installed on checkout, so I can't just overwrite / get rid of the file provided by 3rd party.

Where do I put my custom .d.ts file and how do I tell typescript to use it over supplied one?

Ivan Koshelev
  • 3,830
  • 2
  • 30
  • 50

1 Answers1

4

You can use the paths option in in tsconfig to map any module to a custom definition file:

{
    "compilerOptions" : {
        ..
        "baseUrl": ".",
        "paths": {
            "some_module": ["custom.d.ts"]
        }
    },
}

This feature is usually used with wild cards to map custom paths but it can be used for specific modules as well. You can read more here.

Titian Cernicova-Dragomir
  • 230,986
  • 31
  • 415
  • 357