From e4a10affd8fb231dba2500aad1165304ade291df Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Mon, 16 Mar 2020 10:53:20 +0000 Subject: [PATCH] Extract tsconfig.base.json to obtain VSCode compatible tsconfig.json VS Code requires all files including .d.ts files to be included in order to correctly resolve their definitions. However, we can't add the include and exclude keywords to the tsconfig.json, as that would break inheriting tsconfig.json configurations. Therefore, extract a tsconfig.base.json with the original configuration and let tsconfig.json extend it. This should instruct VS Code to use the tsconfig, which includes all files, while all other infrastructure can remain working as-is. R=jacktfranklin@chromium.org DISABLE_THIRD_PARTY_CHECK=TypeScript update Fixed: 1056211 Change-Id: Ib4d127c745a3e69fd8c8c77eb0fb20c3a68689b1 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2095299 Commit-Queue: Tim van der Lippe Reviewed-by: Jack Franklin --- karma.conf.js | 2 +- test/e2e/tsconfig.json | 2 +- test/perf/tsconfig.json | 2 +- test/screenshots/tsconfig.json | 2 +- test/shared/tsconfig.json | 2 +- third_party/typescript/ts_library.py | 5 ++--- third_party/typescript/typescript.gni | 2 +- tsconfig.base.json | 24 +++++++++++++++++++++ tsconfig.json | 30 +++++++-------------------- 9 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 tsconfig.base.json diff --git a/karma.conf.js b/karma.conf.js index 3fa59626f7..537e04f702 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -57,7 +57,7 @@ module.exports = function(config) { frameworks: ['mocha', 'chai', 'karma-typescript'], karmaTypescriptConfig: { - tsconfig: './tsconfig.json', + tsconfig: './tsconfig.base.json', compilerOptions: { checkJs: false, baseUrl: '.', diff --git a/test/e2e/tsconfig.json b/test/e2e/tsconfig.json index 4db669b079..7ab6d4a89a 100644 --- a/test/e2e/tsconfig.json +++ b/test/e2e/tsconfig.json @@ -11,5 +11,5 @@ "path": "../shared/tsconfig.json" } ], - "extends": "../../tsconfig.json" + "extends": "../../tsconfig.base.json" } diff --git a/test/perf/tsconfig.json b/test/perf/tsconfig.json index 4db669b079..7ab6d4a89a 100644 --- a/test/perf/tsconfig.json +++ b/test/perf/tsconfig.json @@ -11,5 +11,5 @@ "path": "../shared/tsconfig.json" } ], - "extends": "../../tsconfig.json" + "extends": "../../tsconfig.base.json" } diff --git a/test/screenshots/tsconfig.json b/test/screenshots/tsconfig.json index 4db669b079..7ab6d4a89a 100644 --- a/test/screenshots/tsconfig.json +++ b/test/screenshots/tsconfig.json @@ -11,5 +11,5 @@ "path": "../shared/tsconfig.json" } ], - "extends": "../../tsconfig.json" + "extends": "../../tsconfig.base.json" } diff --git a/test/shared/tsconfig.json b/test/shared/tsconfig.json index 0db6bc9211..12f1aec4f6 100644 --- a/test/shared/tsconfig.json +++ b/test/shared/tsconfig.json @@ -7,5 +7,5 @@ "checkJs": false, "allowJs": false }, - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", } diff --git a/third_party/typescript/ts_library.py b/third_party/typescript/ts_library.py index 3d47686dc1..8bebb30493 100644 --- a/third_party/typescript/ts_library.py +++ b/third_party/typescript/ts_library.py @@ -23,7 +23,7 @@ finally: NODE_LOCATION = devtools_paths.node_path() ROOT_DIRECTORY_OF_REPOSITORY = path.join(_CURRENT_DIR, '..', '..') -ROOT_TS_CONFIG_LOCATION = path.join(ROOT_DIRECTORY_OF_REPOSITORY, 'tsconfig.json') +BASE_TS_CONFIG_LOCATION = path.join(ROOT_DIRECTORY_OF_REPOSITORY, 'tsconfig.base.json') TYPES_NODE_MODULES_DIRECTORY = path.join(ROOT_DIRECTORY_OF_REPOSITORY, 'node_modules', '@types') RESOURCES_INSPECTOR_PATH = path.join(os.getcwd(), 'resources', 'inspector') @@ -54,8 +54,7 @@ def main(): parser.set_defaults(test_only=False) opts = parser.parse_args() - - with open(ROOT_TS_CONFIG_LOCATION) as root_tsconfig: + with open(BASE_TS_CONFIG_LOCATION) as root_tsconfig: try: tsconfig = json.loads(root_tsconfig.read()) except Exception as e: diff --git a/third_party/typescript/typescript.gni b/third_party/typescript/typescript.gni index 10c35fa29c..c085c90791 100644 --- a/third_party/typescript/typescript.gni +++ b/third_party/typescript/typescript.gni @@ -45,7 +45,7 @@ template("ts_library") { ]) inputs = [ - "//$devtools_location/tsconfig.json", + "//$devtools_location/tsconfig.base.json", "//$devtools_location/node_modules/typescript/lib/tsc.js", "//$devtools_location/front_end/legacy/legacy-defs.d.ts", "//$devtools_location/front_end/generated/protocol.d.ts", diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000000..a88f49eaa9 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "esnext", + "target": "esnext", + "baseUrl": ".", + "paths": { + "/front_end/*": ["front_end/*"] + }, + "checkJs": true, + "allowJs": true, + + "noEmitOnError": true, + + "lib": [ + "esnext", + "dom" + ], + + "strict": true, + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 44dd5520a6..3ef756b521 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,24 +1,10 @@ { - "compilerOptions": { - "module": "esnext", - "target": "esnext", - "baseUrl": ".", - "paths": { - "/front_end/*": ["front_end/*"] - }, - "checkJs": true, - "allowJs": true, - - "noEmitOnError": true, - - "lib": [ - "esnext", - "dom" - ], - - "strict": true, - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - } + "extends": "./tsconfig.base.json", + "include": [ + "front_end/", + "test/" + ], + "exclude": [ + "front_end/externs.js" + ] }