šŸ˜µā€šŸ’« Typescript Devs Suffer For 5 Years Because Of Thisā€¦

Tom Smykowski
3 min readMar 17, 2023

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:

--

--

Tom Smykowski
Tom Smykowski

Written by Tom Smykowski

Software Engineer & Tech Editor. Top 2% on StackOverflow, 3mil views on Quora. Won Shattered Pixel Dungeon.

Responses (1)