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

feat: skipLibCheck take 2 #350

merged 5 commits into from
Apr 3, 2023

Conversation

alexeagle
Copy link
Member

@alexeagle alexeagle commented Apr 1, 2023

Here's the DX of what the select failure message looks like, will be live for 2.0 under this proposal:

$ bazel build examples/simple:ts --strategy=TsProject=sandboxed -s
ERROR: /home/alexeagle/Projects/rules_ts/examples/simple/BUILD.bazel:9:11: configurable attribute "args" in //examples/simple:ts doesn't match this configuration: 

######## Required Typecheck Performance Selection ########

TypeScript's type-checking exposes a flag `--skipLibCheck`:
https://www.typescriptlang.org/tsconfig#skipLibCheck

Using this flag saves substantial time during type-checking.
Rather than doing a full check of all d.ts files, TypeScript will only type-check the code you
specifically refer to in your app's source code.
We recommend this for most rules_ts users.

HOWEVER this performance improvement comes at the expense of type-system accuracy. 
For example, two packages could define two copies of the same type in an inconsistent way.
If you publish a library from your repository, your incorrect types may result in errors for your users.

You must choose exactly one of the following flags:

1. To choose the faster performance, put this in /.bazelrc:

    # passes an argument `--skipLibCheck` to *every* spawn of tsc
    build --@aspect_rules_ts//ts:skipLibCheck=always

2. To choose more correct typechecks, put this in /.bazelrc:

    # honor the setting of `skipLibCheck` in the tsconfig.json file
    build --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig

##########################################################

This instance of //examples/simple:ts has configuration identifier 1cd096f. To inspect its configuration, run: bazel config 1cd096f.

For more help, see https://bazel.build/docs/configurable-attributes#faq-select-choose-condition.

ERROR: Analysis of target '//examples/simple:ts' failed; build aborted: 
INFO: Elapsed time: 0.095s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)

Fixes #348

@alexeagle alexeagle requested a review from thesayyn April 1, 2023 23:21
ts/BUILD.bazel Outdated Show resolved Hide resolved
ts/BUILD.bazel Outdated Show resolved Hide resolved
ts/defs.bzl Outdated Show resolved Hide resolved
ts/defs.bzl Outdated Show resolved Hide resolved
Co-authored-by: Sahin Yort <[email protected]>
ts/defs.bzl Outdated Show resolved Hide resolved
Copy link
Member

@thesayyn thesayyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome

@alexeagle alexeagle requested a review from gregmagolan April 2, 2023 18:09
@alexeagle alexeagle merged commit ed9d26c into main Apr 3, 2023
@alexeagle alexeagle deleted the config_setting branch April 3, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

FR: roll-forward a skipLibCheck performance gain for most users
2 participants