The default_tsconfig feature has a design flaw.

If you use this feature, and add a strictness option to your tsconfig.json, code from other workspaces which relies on the default tsconfig.json will be compiled with your new setting, and may fail. This violates the encapsulation guarantee you'd expect: code from another workspace should be compiled with the tsconfig.json from that workspace, and its compilation should not depend on a file owned in a dependent workspace.

If you really want this feature, you can use a macro to declare a variant of ts_library that picks up your default value, like https://github.com/alexeagle/angular-bazel-example/pull/45/files

Fixes #122

PiperOrigin-RevId: 181327885
diff --git a/README.md b/README.md
index bc59a1a..973cce6 100644
--- a/README.md
+++ b/README.md
@@ -30,8 +30,6 @@
 containing:
 
 ```python
-workspace(name = "my_workspace")
-
 load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
 
 git_repository(
@@ -51,12 +49,9 @@
     path = "node_modules/@bazel/typescript",
 )
 
-load("@build_bazel_rules_typescript//:setup.bzl", "ts_setup_workspace")
+load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
 
-# This points all `ts_library` rules at your normal tsconfig.json file, which
-# should also be the one your editor uses so that settings match.
-# Update this value to match where your tsconfig.json file lives.
-ts_setup_workspace(default_tsconfig = "@my_workspace//:tsconfig.json")
+ts_setup_workspace()
 
 # ts_devserver needs the Go rules.
 # See https://github.com/bazelbuild/rules_go#setup for the latest version.
diff --git a/WORKSPACE b/WORKSPACE
index cec05d0..69a7659 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -31,7 +31,7 @@
 #   @yarn//:yarn
 node_repositories(package_json = ["//:package.json"])
 
-load("@build_bazel_rules_typescript//:setup.bzl", "ts_setup_workspace")
+load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
 
 ts_setup_workspace()
 
diff --git a/defs.bzl b/defs.bzl
index 0d8835f..644d3c7 100644
--- a/defs.bzl
+++ b/defs.bzl
@@ -16,11 +16,13 @@
 
 Users should not load files under "/internal"
 """
+load("//internal:ts_repositories.bzl", _ts_setup_workspace = "ts_setup_workspace")
 load("//internal:build_defs.bzl", _ts_library = "ts_library")
 load("//internal:ts_config.bzl", _ts_config = "ts_config")
 load("//internal/devserver:ts_devserver.bzl", _ts_devserver = "ts_devserver_macro")
 load("//internal/karma:ts_web_test.bzl", _ts_web_test = "ts_web_test_macro")
 
+ts_setup_workspace = _ts_setup_workspace
 ts_library = _ts_library
 ts_config = _ts_config
 ts_devserver = _ts_devserver
diff --git a/internal/build_defs.bzl b/internal/build_defs.bzl
index fc67c45..84fe5e4 100644
--- a/internal/build_defs.bzl
+++ b/internal/build_defs.bzl
@@ -18,8 +18,6 @@
 # pylint: disable=missing-docstring
 load(":common/compilation.bzl", "COMMON_ATTRIBUTES", "compile_ts", "ts_providers_dict_to_struct")
 load(":executables.bzl", "get_tsc")
-# This is created by the ts_repositories() repository rule
-load("@build_bazel_rules_typescript_install//:tsconfig.bzl", "get_default_tsconfig")
 load(":common/tsconfig.bzl", "create_tsconfig")
 load(":ts_config.bzl", "TsConfigInfo")
 
@@ -128,6 +126,7 @@
 # ts_library   #
 # ************ #
 
+
 def _ts_library_impl(ctx):
   """Implementation of ts_library.
 
@@ -158,10 +157,7 @@
         # be portable across internal/external, so we need this attribute
         # internally as well.
         "tsconfig":
-            attr.label(
-                default = get_default_tsconfig(),
-                allow_files = True,
-                single_file = True),
+            attr.label(allow_files = True, single_file = True),
         "compiler":
             attr.label(
                 default=get_tsc(),
diff --git a/internal/ts_repositories.bzl b/internal/ts_repositories.bzl
index fa69d9f..3b0a91e 100644
--- a/internal/ts_repositories.bzl
+++ b/internal/ts_repositories.bzl
@@ -12,49 +12,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""The ts_repositories rule installs build-time dependencies.
+"""The ts_setup_workspace rule installs build-time dependencies.
 """
 
 load("@build_bazel_rules_nodejs//:defs.bzl", "npm_install")
 
-def _ts_install_impl(repository_ctx):
-  repository_ctx.file("BUILD", content="# Marker that this is a package")
-
-  default_tsconfig = repository_ctx.attr.default_tsconfig
-  if default_tsconfig != None:
-    if not default_tsconfig.workspace_root:
-      fail("""ts_repositories failed to install:
-      default_tsconfig must be an absolute label, including workspace.
-      For example, @my_project//:tsconfig.json""")
-
-    # Wrap string value in quotes, but not None
-    default_tsconfig = "Label(\"%s\")" % default_tsconfig
-  repository_ctx.file("tsconfig.bzl", content="""
-def get_default_tsconfig():
-  return %s
-""" % default_tsconfig)
-
-_ts_install = repository_rule(implementation = _ts_install_impl, attrs = {
-  "default_tsconfig": attr.label(allow_files = True, single_file = True),
-})
-
-def ts_repositories(default_tsconfig = None):
-  """Installs the dependencies for TypeScript build rules.
-
-  Args:
-    default_tsconfig: a label pointing to a tsconfig.json file which will be
-                      used for any ts_library rule which doesn't specify one.
-  """
-  _ts_install(
-      name = "build_bazel_rules_typescript_install",
-      default_tsconfig = default_tsconfig,
-  )
-
+def ts_setup_workspace():
   npm_install(
       name = "build_bazel_rules_typescript_deps",
       package_json = "@build_bazel_rules_typescript//internal/tsc_wrapped:package.json",
   )
-
   npm_install(
       name = "build_bazel_rules_typescript_devserver_deps",
       package_json = "@build_bazel_rules_typescript//internal/devserver:package.json",
diff --git a/internal/tsc_wrapped/BUILD.bazel b/internal/tsc_wrapped/BUILD.bazel
index 9a18aff..72d5c39 100644
--- a/internal/tsc_wrapped/BUILD.bazel
+++ b/internal/tsc_wrapped/BUILD.bazel
@@ -42,7 +42,7 @@
     module_root = "index.d.ts",
     tsconfig = ":tsconfig.json",
     visibility = ["//visibility:public"],
-    data = [
+    data = [ 
         # Should be @bazel_tools//src/main/protobuf:worker_protocol.proto
         # see https://github.com/bazelbuild/bazel/issues/3155#issuecomment-308156976
         "//internal:worker_protocol.proto",
@@ -57,14 +57,12 @@
 ts_library(
     name = "plugin_api",
     srcs = ["plugin_api.ts"],
-    tsconfig = ":tsconfig.json",
     visibility = ["//internal/tsetse:__pkg__"],
 )
 
 ts_library(
     name = "perf_trace",
     srcs = ["perf_trace.ts"],
-    tsconfig = ":tsconfig.json",
     visibility = ["//internal/tsetse:__pkg__"],
 )
 
diff --git a/package.json b/package.json
index dd8e166..9e66792 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
     "name": "@bazel/typescript",
     "description": "Build TypeScript with Bazel",
-    "version": "0.8.0",
+    "version": "0.9.0",
     "keywords": [
         "typescript",
         "bazel"
diff --git a/setup.bzl b/setup.bzl
deleted file mode 100644
index 92b6e8e..0000000
--- a/setup.bzl
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-""" Public API surface is re-exported here.
-
-Users should not load files under "/internal"
-"""
-load("//internal:ts_repositories.bzl", _ts_repositories = "ts_repositories")
-ts_setup_workspace = _ts_repositories