Skip to content

Commit 84b6d66

Browse files
committed
fixup! fix(bazel): handle additional cases for strict deps testing
1 parent 6c86ba1 commit 84b6d66

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

bazel/ts_project/strict_deps/test/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ts_project(
1212
strict_deps_test(
1313
name = "import_node_module",
1414
srcs = ["import_node_module.ts"],
15+
tsconfig = "//bazel:tsconfig",
1516
deps = [
1617
"//bazel:node_modules/@types/node",
1718
],
@@ -20,17 +21,20 @@ strict_deps_test(
2021
invalid_strict_deps_test(
2122
name = "invalid_import_node_module",
2223
srcs = ["import_node_module.ts"],
24+
tsconfig = "//bazel:tsconfig",
2325
)
2426

2527
strict_deps_test(
2628
name = "import_npm_module",
2729
srcs = ["import_npm_module.ts"],
30+
tsconfig = "//bazel:tsconfig",
2831
deps = ["//bazel:node_modules/@microsoft/api-extractor"],
2932
)
3033

3134
invalid_strict_deps_test(
3235
name = "invalid_import_npm_module_transitively",
3336
srcs = ["import_npm_module.ts"],
37+
tsconfig = "//bazel:tsconfig",
3438
deps = [
3539
"//bazel/ts_project/strict_deps/test/import_npm_module",
3640
],
@@ -39,17 +43,20 @@ invalid_strict_deps_test(
3943
invalid_strict_deps_test(
4044
name = "invalid_import_npm_module",
4145
srcs = ["import_npm_module.ts"],
46+
tsconfig = "//bazel:tsconfig",
4247
)
4348

4449
strict_deps_test(
4550
name = "import_from_depth",
4651
srcs = ["import_from_depth.ts"],
52+
tsconfig = "//bazel:tsconfig",
4753
deps = ["//bazel/ts_project/strict_deps/test/depth"],
4854
)
4955

5056
invalid_strict_deps_test(
5157
name = "invalid_import_from_depth",
5258
srcs = ["import_from_depth.ts"],
59+
tsconfig = "//bazel:tsconfig",
5360
deps = [
5461
":sibling_import_from_depth",
5562
],

bazel/ts_project/strict_deps/test/import_from_mts_cts_extensions/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ load("//bazel/ts_project/strict_deps:index.bzl", "strict_deps_test")
44
strict_deps_test(
55
name = "import_from_mts_cts_extensions",
66
srcs = ["index.ts"],
7+
tsconfig = "//bazel:tsconfig",
78
deps = [":mts_cts_extensions"],
89
)
910

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import * as ts from 'typescript';
10+
import {dirname} from 'path';
11+
12+
export function readTsConfig(filePath: string) {
13+
const configFile = ts.readConfigFile(filePath, ts.sys.readFile);
14+
if (configFile.error) {
15+
throw new Error(ts.formatDiagnostics([configFile.error], ts.createCompilerHost({})));
16+
}
17+
18+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, dirname(filePath));
19+
20+
if (parsedConfig.errors.length > 0) {
21+
throw new Error(ts.formatDiagnostics(parsedConfig.errors, ts.createCompilerHost({})));
22+
}
23+
24+
return parsedConfig;
25+
}

0 commit comments

Comments
 (0)