From 464ce4ba30e8fa14e301ccd029bd31b0199a4736 Mon Sep 17 00:00:00 2001 From: Nora Date: Thu, 27 Dec 2018 12:55:26 -0500 Subject: [PATCH 1/2] refactor: rename tsconfig.build files in examples --- packages/cli/generators/example/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/cli/generators/example/index.js b/packages/cli/generators/example/index.js index 11382f6364be..0962bffc8cd9 100644 --- a/packages/cli/generators/example/index.js +++ b/packages/cli/generators/example/index.js @@ -10,6 +10,7 @@ const chalk = require('chalk'); const downloadAndExtractExample = require('./downloader'); const path = require('path'); const utils = require('../../lib/utils'); +const fs = require('fs-extra'); const EXAMPLES = { todo: 'Tutorial example on how to build an application with LoopBack 4.', @@ -94,6 +95,10 @@ module.exports = class extends BaseGenerator { const cwd = process.cwd(); const absOutDir = await downloadAndExtractExample(this.exampleName, cwd); this.outDir = path.relative(cwd, absOutDir); + fs.rename( + `${this.outDir}/tsconfig.build.json`, + `${this.outDir}/tsconfig.json`, + ); } install() { From c77e3327030b7ac6f72001c2de15550c7f3edc6a Mon Sep 17 00:00:00 2001 From: Nora Date: Mon, 7 Jan 2019 14:32:26 -0500 Subject: [PATCH 2/2] docs: add tsconfig info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miroslav Bajtoš --- docs/site/DEVELOPING.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/site/DEVELOPING.md b/docs/site/DEVELOPING.md index b633c91e0a04..1de5c87348c9 100644 --- a/docs/site/DEVELOPING.md +++ b/docs/site/DEVELOPING.md @@ -510,3 +510,25 @@ configuration, it's important to verify that all usage scenarios keep working. 5. Test integration with supported IDEs: - [VS Code](./VSCODE.md#how-to-verify-tslint-setup) + +### tsconfig files + +In the [`loopback-next`](https://github.com/strongloop/loopback-next) monorepo, +`TypeScript` is set up in two places: + +1. When using VS Code, the `TypeScript` engine views `loopback-next` as a single + big project. + + This enables the "refactor - rename" command to change all places using the + renamed symbol, and also makes "go to definition" command jump to `.ts` files + containing the original source code. Otherwise "refactor - rename" works + within the same package only and "go to definition" jumps to `.d.ts` files. + +2. When building the monorepo, we need to build the packages individually, so + that one `dist` directory is created for each package. + +This is why we have two sets of `tsconfig` files: + +- At monorepo root, there is `tsconfig.json` used by VS Code. +- Inside each package, there is `tsconfig.build.json` used by `npm run build` + command.