šµāš« Typescript Devs Suffer For 5 Years Because Of Thisā¦
An innocent default value of declarationMap makes DX of Typescript libraries miserable for five years. But there is a fix!
Gajus Kuizinas shared on Twitter a trick supposably a lot of Typescript library developers donāt know about.
You may have noticed that sometimes when you import a Typescript library, your IDE properly recognizes it and itās components.
However when you use the āgo to definitionā command, you are navigated toĀ XYZ.d.ts file. A file containing only Typescript definitions rather than the actual XYZ.ts file containing the implementation of a function or other component.
It occurs that itās a surprising default behavior of Typescript. Youād expect it to navigate you to the implementation.
Fortunately, there is a simple fix for this problem. Gajus writes:
Turns out, the fix is super simple! Just add "declarationMap"
After adding the parameter your tsconfig.json library file should look like this: