Skip to content

[FR]: tsconfig extends & reference support #143

@lstanden

Description

@lstanden

What happened?

This is becoming a more common pattern in Typescript projects:

tsconfig.json

{
    "extends": "./tsconfig.base.json",
    "include": [],
    "references": [
      {
        "path": "tsconfig.src.json"
      },
      {
        "path": "tsconfig.test.json"
      }
    ]
  }

When these additional files are manually created as ts_config rules, this is correctly detected:

# now automatically maintained
ts_config(
    name = "tsconfig",
    src = "tsconfig.json",
    visibility = [":__subpackages__"],
    deps = [

        ":tsconfig_base",
        ":tsconfig_src",
        ":tsconfig_test",
    ],
)

# created manually
ts_config(
    name = "tsconfig_base",
    src = "tsconfig.base.json",
    visibility = [":__subpackages__"],
)

# created manually
ts_config(
    name = "tsconfig_test",
    src = "tsconfig.test.json",
    visibility = [":__subpackages__"],
)

# created manually
ts_config(
    name = "tsconfig_src",
    src = "tsconfig.src.json",
    visibility = [":__subpackages__"],
)

It would be nice if this was automatic, and it seems like it would be relatively easy to detect this and handle.

Version

Development (host) and target OS/architectures:

Output of bazel --version:

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

Any other information?

For additional context, the main reason this happens is so you can (for example) have Typescript know that jest or vitest types are active inside the tests folder, but not the src folder. You can also the same thing based on file patterns. Basically it's a way to get better type safety, which is why it's starting to become more common.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions