Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: skipLibCheck take 2 #350

Merged
merged 5 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
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(
alexeagle marked this conversation as resolved.
Show resolved Hide resolved
name = "skip_lib_check",
# Default is 0 to be a non-breaking change in rules_ts 1.x
# TODO(2.0): change default to -1 so we require users to consider which value of the flag is best.
build_setting_default = 0,
alexeagle marked this conversation as resolved.
Show resolved Hide resolved
)

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
26 changes: 25 additions & 1 deletion ts/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ 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 ########
TODO: describe

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 +418,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