Skip to content

Commit

Permalink
feat: skipLibCheck take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Apr 1, 2023
1 parent dab5e3f commit fd40bb4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
22 changes: 22 additions & 0 deletions ts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "int_flag")

exports_files(
glob(["*.bzl"]),
visibility = ["//docs:__pkg__"],
)

# Enable with --@aspect_rules_ts//ts:skip_lib_check=1
int_flag(
name = "skip_lib_check",
# TODO(2.0): change default to -1 so we require users to consider which value of the flag is best.
build_setting_default = -1,
)

config_setting(
name = "skip_lib_check_honor_tsconfig",
flag_values = {
":skip_lib_check": "0",
},
)

config_setting(
name = "skip_lib_check_always",
flag_values = {
":skip_lib_check": "1",
},
)

bzl_library(
name = "defs",
srcs = ["defs.bzl"],
Expand Down
25 changes: 24 additions & 1 deletion ts/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ load("//ts/private:ts_lib.bzl", _lib = "lib")
ts_config = _ts_config
TsConfigInfo = _TsConfigInfo

# TODO(2.0): fill in more docs
_skip_lib_check_selection_required = """\
######## Required Typecheck Performance Selection ########
This flag This can save time during compilation at the expense of type-system accuracy.
For example, two libraries could define two copies of the same type in an inconsistent way.
Rather than doing a full check of all d.ts files, TypeScript will type check the code you specifically refer to in your app's source code.
To select skipLibCheck, put this in /.bazelrc:
xxx
To choose slower but more correct typechecks, put this in /.bazelrc:
yyy
##########################################################
"""

validate_options = rule(
doc = """Validates that some tsconfig.json properties match attributes on ts_project.
See the documentation of [`ts_project`](#ts_project) for more information.""",
Expand Down Expand Up @@ -400,7 +417,13 @@ def ts_project(
ts_project_rule(
name = tsc_target_name,
srcs = srcs,
args = args,
args = args + select(
{
"//ts:skip_lib_check_always": ["--skipLibCheck"],
"//ts:skip_lib_check_honor_tsconfig": [],
},
no_match_error = _skip_lib_check_selection_required,
),
assets = assets,
data = data,
deps = tsc_deps,
Expand Down

0 comments on commit fd40bb4

Please sign in to comment.