From 88e624b1ef81ddf71a96ca438ac3823da18a5c56 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 14:17:32 -0600 Subject: [PATCH 1/6] Add go-to-definition instructions to TypeScript docs. --- docs/repo-docs/guides/tools/typescript.mdx | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/docs/repo-docs/guides/tools/typescript.mdx b/docs/repo-docs/guides/tools/typescript.mdx index 700014579fb46..97368ccb557b8 100644 --- a/docs/repo-docs/guides/tools/typescript.mdx +++ b/docs/repo-docs/guides/tools/typescript.mdx @@ -207,8 +207,8 @@ Then, create a `check-types` task in `turbo.json`. From the [Configuring tasks g }, "check-types": { "dependsOn": ["topo"] - }, - }, + } + } } ``` @@ -220,11 +220,35 @@ Then, run your task using `turbo check-types`. For [Internal Packages](/repo/docs/core-concepts/internal-packages), we recommend that you use `tsc` to compile your TypeScript libraries whenever possible. While you can use a bundler, it's not necessary and adds extra complexity to your build process. Additionally, bundling a library can mangle the code before it makes it to your applications' bundlers, causing hard to debug issues. +### Enable go-to-definition across package boundaries + +"Go-to-definition" is an editor feature for quickly navigating to the original declaration or symbol (like a variable or function) with a click or hotkey. Once TypeScript is configured correctly, you can navigate across [Internal Packages](/repo/docs/core-concepts/internal-packages) with ease. + +#### Just-in-Time Packages + +Exports from Just-in-Time Packages will automatically bring you to the original TypeScript source code as long as you aren't using [entrypoint wildcards](#package-entrypoint-wildcards). Go-to-definition will work as expected. + +#### Compiled Packages + +Exports from [Compiled Packages](/repo/docs/core-concepts/internal-packages#compiled-packages) require the use of [`declaration`](https://www.typescriptlang.org/tsconfig/#declaration) and [`declarationMap`](https://www.typescriptlang.org/tsconfig/#declarationMap) configurations for go-to-definition to work. After you've enabled these two configurations for the package, compile the package with `tsc`, and open the output directory to find declaration files and source maps. + + + + + + + + + + + + + ### Use Node.js subpath imports instead of TypeScript compiler `paths` It's possible to create absolute imports in your packages using [the TypeScript compiler's `paths` option](https://www.typescriptlang.org/tsconfig#paths), but these paths can cause failed compilation when using [Just-in-Time Packages](https://turbo.build/repo/docs/core-concepts/internal-packages#just-in-time-packages). [As of TypeScript 5.4](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#auto-import-support-for-subpath-imports), you can use [Node.js subpath imports](https://nodejs.org/api/packages.html#imports) instead for a more robust solution. -#### Just-in-Time packages +#### Just-in-Time Packages In [Just-in-Time packages](https://turbo.build/repo/docs/core-concepts/internal-packages#just-in-time-packages), `imports` must target the source code in the package, since build outputs like `dist` won't be created. @@ -252,9 +276,9 @@ export const Button = () => { -#### Compiled packages +#### Compiled Packages -In [Compiled packages](https://turbo.build/repo/docs/core-concepts/internal-packages#compiled-packages), `imports` target the built ouptuts for the package. +In [Compiled Packages](https://turbo.build/repo/docs/core-concepts/internal-packages#compiled-packages), `imports` target the built ouptuts for the package. From fd11259e8a96091d97efbb25f5be7e30cb0cd757 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 14:19:37 -0600 Subject: [PATCH 2/6] WIP --- docs/repo-docs/guides/tools/typescript.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/repo-docs/guides/tools/typescript.mdx b/docs/repo-docs/guides/tools/typescript.mdx index 97368ccb557b8..561efeee20952 100644 --- a/docs/repo-docs/guides/tools/typescript.mdx +++ b/docs/repo-docs/guides/tools/typescript.mdx @@ -244,6 +244,8 @@ Exports from [Compiled Packages](/repo/docs/core-concepts/internal-packages#comp +With these two files in place, your editor will now go to the definition you're expecting. + ### Use Node.js subpath imports instead of TypeScript compiler `paths` It's possible to create absolute imports in your packages using [the TypeScript compiler's `paths` option](https://www.typescriptlang.org/tsconfig#paths), but these paths can cause failed compilation when using [Just-in-Time Packages](https://turbo.build/repo/docs/core-concepts/internal-packages#just-in-time-packages). [As of TypeScript 5.4](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#auto-import-support-for-subpath-imports), you can use [Node.js subpath imports](https://nodejs.org/api/packages.html#imports) instead for a more robust solution. From 42e560e6f4c9843c1a96e680cf34cb81350525c8 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 14:24:25 -0600 Subject: [PATCH 3/6] Add link to go-to-definition doc. --- docs/repo-docs/guides/tools/typescript.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/repo-docs/guides/tools/typescript.mdx b/docs/repo-docs/guides/tools/typescript.mdx index 561efeee20952..beff4a8d5f3d6 100644 --- a/docs/repo-docs/guides/tools/typescript.mdx +++ b/docs/repo-docs/guides/tools/typescript.mdx @@ -226,7 +226,7 @@ For [Internal Packages](/repo/docs/core-concepts/internal-packages), we recommen #### Just-in-Time Packages -Exports from Just-in-Time Packages will automatically bring you to the original TypeScript source code as long as you aren't using [entrypoint wildcards](#package-entrypoint-wildcards). Go-to-definition will work as expected. +Exports from [Just-in-Time Packages](/repo/docs/core-concepts/internal-packages#just-in-time-packages) will automatically bring you to the original TypeScript source code as long as you aren't using [entrypoint wildcards](#package-entrypoint-wildcards). Go-to-definition will work as expected. #### Compiled Packages From f67effbe859eb8fb6cff9d07d9cfad2020279596 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 14:26:27 -0600 Subject: [PATCH 4/6] WIP --- docs/repo-docs/guides/tools/typescript.mdx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/repo-docs/guides/tools/typescript.mdx b/docs/repo-docs/guides/tools/typescript.mdx index c5454f236b7a7..beff4a8d5f3d6 100644 --- a/docs/repo-docs/guides/tools/typescript.mdx +++ b/docs/repo-docs/guides/tools/typescript.mdx @@ -244,12 +244,7 @@ Exports from [Compiled Packages](/repo/docs/core-concepts/internal-packages#comp -<<<<<<< HEAD With these two files in place, your editor will now go to the definition you're expecting. -======= -With these two files in place, your editor will now navigate to the original source code. - -> > > > > > > ed03d0c72a74cc74e83df86bd0d0b5bfd1b2131a ### Use Node.js subpath imports instead of TypeScript compiler `paths` From bb6a187dfba8fd31855b7e4f0ff45878adeb6813 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 14:27:15 -0600 Subject: [PATCH 5/6] Update docs/repo-docs/guides/tools/typescript.mdx --- docs/repo-docs/guides/tools/typescript.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/repo-docs/guides/tools/typescript.mdx b/docs/repo-docs/guides/tools/typescript.mdx index beff4a8d5f3d6..857c65cbe95fc 100644 --- a/docs/repo-docs/guides/tools/typescript.mdx +++ b/docs/repo-docs/guides/tools/typescript.mdx @@ -222,7 +222,7 @@ For [Internal Packages](/repo/docs/core-concepts/internal-packages), we recommen ### Enable go-to-definition across package boundaries -"Go-to-definition" is an editor feature for quickly navigating to the original declaration or symbol (like a variable or function) with a click or hotkey. Once TypeScript is configured correctly, you can navigate across [Internal Packages](/repo/docs/core-concepts/internal-packages) with ease. +"Go-to-definition" is an editor feature for quickly navigating to the original declaration or definition of a symbol (like a variable or function) with a click or hotkey. Once TypeScript is configured correctly, you can navigate across [Internal Packages](/repo/docs/core-concepts/internal-packages) with ease. #### Just-in-Time Packages From 31ec6a7230711be28759bf500d143627ccab02b5 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Sat, 28 Sep 2024 14:27:38 -0600 Subject: [PATCH 6/6] Update docs/repo-docs/guides/tools/typescript.mdx --- docs/repo-docs/guides/tools/typescript.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/repo-docs/guides/tools/typescript.mdx b/docs/repo-docs/guides/tools/typescript.mdx index 857c65cbe95fc..e98d6737607ba 100644 --- a/docs/repo-docs/guides/tools/typescript.mdx +++ b/docs/repo-docs/guides/tools/typescript.mdx @@ -244,7 +244,7 @@ Exports from [Compiled Packages](/repo/docs/core-concepts/internal-packages#comp -With these two files in place, your editor will now go to the definition you're expecting. +With these two files in place, your editor will now navigate to the original source code. ### Use Node.js subpath imports instead of TypeScript compiler `paths`