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

fix: do not rely on @npm_typescript if custom tsc is provided #693

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
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
16 changes: 12 additions & 4 deletions ts/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ def ts_project(
if tsc != _tsc and tsc_worker == _tsc_worker:
supports_workers = 0

# Disable typescript version detection if tsc is not the default:
# - it would be wrong anyways
# - it is only used to warn if worker support is configured incorrectly.
if tsc != _tsc:
is_typescript_5_or_greater = None
Copy link
Member

Choose a reason for hiding this comment

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

I guess it would be here that we can potentially set supports_worker = False and maybe remove some code from within the rule? Does that simplify anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this would be correct: It is possible to supply a custom that has worker support. But if we set supports_worker = 0 here, workers would be disabled.

They way I think about this is: is_typescript_5_or_greater is a best effort configuration fix: If we can "prove" the config is wrong, we correct it and warn. If we cannot "prove" the config is wrong, we do what it says (and it might fail).

else:
is_typescript_5_or_greater = select({
"@npm_typescript//:is_typescript_5_or_greater": True,
"//conditions:default": False,
})

ts_project_rule(
name = tsc_target_name,
srcs = srcs,
Expand Down Expand Up @@ -411,10 +422,7 @@ def ts_project(
tsc_worker = tsc_worker,
transpile = -1 if not transpiler else int(transpiler == "tsc"),
supports_workers = supports_workers,
is_typescript_5_or_greater = select({
"@npm_typescript//:is_typescript_5_or_greater": True,
"//conditions:default": False,
}),
is_typescript_5_or_greater = is_typescript_5_or_greater,
validate = validate,
validator = validator,
**kwargs
Expand Down
Loading