Skip to content

Commit 16cbc6f

Browse files
Alex Eaglealexeagle
authored andcommitted
fix(typescript): exclude package.json from tsconfig#files
1 parent 1c70656 commit 16cbc6f

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

internal/providers/declaration_info.bzl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""This module contains a provider for TypeScript typings files (.d.ts)"""
15+
"""This module contains a provider for TypeScript typings (*.d.ts and package.json#typings)"""
1616

1717
DeclarationInfo = provider(
18-
doc = """The DeclarationInfo provider allows JS rules to communicate typing information. TypeScript's .d.ts files are used as the interop format for describing types.
18+
doc = """The DeclarationInfo provider allows JS rules to communicate typing information.
19+
TypeScript's .d.ts files are used as the interop format for describing types.
20+
package.json files are included as well, as TypeScript needs to read the "typings" property.
1921
2022
Do not create DeclarationInfo instances directly, instead use the declaration_info factory function.
2123
@@ -24,18 +26,18 @@ Note: historically this was a subset of the string-typed "typescript" provider.
2426
# TODO(alexeagle): The ts_library#deps attribute should require that this provider is attached.
2527
# TODO: if we ever enable --declarationMap we will have .d.ts.map files too
2628
fields = {
27-
"declarations": "A depset of .d.ts files produced by this rule",
28-
"transitive_declarations": """A depset of .d.ts files produced by this rule and all its transitive dependencies.
29+
"declarations": "A depset of typings files produced by this rule",
30+
"transitive_declarations": """A depset of typings files produced by this rule and all its transitive dependencies.
2931
This prevents needing an aspect in rules that consume the typings, which improves performance.""",
3032
"type_blacklisted_declarations": """A depset of .d.ts files that we should not use to infer JSCompiler types (via tsickle)""",
3133
},
3234
)
3335

3436
def declaration_info(declarations, deps = []):
35-
"""Constructs a DeclarationInfo including all transitive declarations from DeclarationInfo providers in a list of deps.
37+
"""Constructs a DeclarationInfo including all transitive files needed to type-check from DeclarationInfo providers in a list of deps.
3638
3739
Args:
38-
declarations: list of .d.ts files
40+
declarations: list of typings files
3941
deps: list of labels of dependencies where we should collect their DeclarationInfo to pass transitively
4042
4143
Returns:

packages/typescript/internal/build_defs.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ def tsc_wrapped_tsconfig(
244244
node_modules_root = _compute_node_modules_root(ctx)
245245
config = create_tsconfig(
246246
ctx,
247-
files,
247+
# Filter out package.json files that are included in DeclarationInfo
248+
# tsconfig files=[] property should only be .ts/.d.ts
249+
[f for f in files if f.path.endswith(".ts")],
248250
srcs,
249251
devmode_manifest = devmode_manifest,
250252
node_modules_root = node_modules_root,

0 commit comments

Comments
 (0)