Revision 8e13c351acb8087f5a101d70bd7f9f9aebbdc1bc authored by JoostK on 21 September 2021, 21:39:11 UTC, committed by Jessica Janiuk on 26 October 2021, 18:22:33 UTC
The `ErrorCode` enum in the `error_code.ts` file is governed by public api guards but the other top-level exports from that file are exempt from public api documentation and are therefore marked as `@internal`. However, TypeScript is configured with the `stripInternal` compiler option such that declarations with `@internal` markers are not emitted into the `.d.ts` files, but this means that the reexports in the barrel file end up referring to missing declarations. The `stripInternal` option is considered internal and its documentation states to use at your own risk (as per https://github.com/microsoft/TypeScript/issues/45307). Having the option enabled is desirable for us as it works well for hiding class fields that are marked `@internal`, which is an effective way to hide members from the .d.ts file. As a workaround for the issue with top-level symbols, the declarations with `@internal` markers are moved to dedicated files for which no public api guard is setup, therefore allowing their `@internal` markers to be dropped. Fixes #43097 PR Close #43527
1 parent 59e56e7
utils.bzl
"""Simple utility bazel macros for convenience usage."""
load("@npm//typescript:index.bzl", "tsc")
def transpile_js_to_es5(name, js_file):
"""Transpiles a provided javascript target to es5.
For testing on IE, shims must be served in es5, this macro can be used to
transpile es2015 JS shims to es5 for usage in IE testing.
Example usage:
transpile_js_to_es5(
name = "my-file",
js_file = "@npm//some_package/shim_files/es6_shim_file.js",
)
filegroup(
name = "some_shims_for_tests",
testonly = True,
srcs = [
":my-file",
...
]
)
"""
tsc(
name = name,
outs = [
"%s.js" % name,
],
args = [
# Allow JS files to be used for transpiling
"--allowJs",
# Skip lib check as pure local javascript transpiling should be done
"--skipLibCheck",
# Transpile to ES5
"--target ES5",
# Output the transpiled file to the location provided by the name
"--outFile $(execpath :%s.js)" % name,
# Transpile the provided js_file
"$(execpath %s)" % js_file,
],
data = [
js_file,
],
)
Computing file changes ...