Configuring TypeScript 16 exercises

Navigate to Source Files Instead of Declaration Files

Consider the following index.ts file:

// src/index.ts
export const myFunc = (input: string) => {};

This file is converted into a index.d.ts file in the dist directory when we run the TypeScript compiler:

// dist/index.d.ts
export declare const myFunc: (input: string) => vo

Loading exercise


00:00 Building from our declaration problem that we saw before, we basically have our index.ts file here and we are converting that into a dist with index.js and an index.d.ts. But there's an interesting problem. When we actually use this, when we say, okay, import my func from dist index.js,

00:19 when we do a go to definition on the my func here, we end up in the declaration file. So we end up in the .d.ts file. This is a bit bloody annoying because ideally, let's say that we control this code and it lives in a monorepo somewhere. It lives in the same repo. We want to actually say that,

00:38 okay, when we command click on my func, we actually want to go to the source file here, not the built code. And so there is actually a ts config setting you can tweak for that. Your job is to work out which one it is and to go in here and add that in so that when you go into test.ts

00:57 and you command click on my func, you get taken to the source file and not the declaration file. Good luck.