Report unused ts_declaration deps as unused instead of ambiguous.
PiperOrigin-RevId: 231466548
diff --git a/ts_auto_deps/analyze/analyze.go b/ts_auto_deps/analyze/analyze.go
index 851509a..644110a 100644
--- a/ts_auto_deps/analyze/analyze.go
+++ b/ts_auto_deps/analyze/analyze.go
@@ -506,10 +506,6 @@
for label, rule := range labelToRule {
if isTazeManagedRuleClass(rule.GetRuleClass()) || isGenerated(rule) {
report.UnnecessaryDependency = append(report.UnnecessaryDependency, label)
- } else if c := rule.GetRuleClass(); c == "ts_declaration" {
- // ts_declarations may be used even if there is no explicit import
- // since ambient types can't be detected.
- report.AmbiguousDependency = append(report.AmbiguousDependency, label)
}
}
return report, nil
diff --git a/ts_auto_deps/analyze/analyze_test.go b/ts_auto_deps/analyze/analyze_test.go
index 700ea84..3e669ad 100644
--- a/ts_auto_deps/analyze/analyze_test.go
+++ b/ts_auto_deps/analyze/analyze_test.go
@@ -7,6 +7,7 @@
"os"
"path/filepath"
"reflect"
+ "sort"
"strconv"
"strings"
"testing"
@@ -612,6 +613,9 @@
t.Errorf("got err %q, expected %q", err, test.err)
}
+ // getAllLiteralSrcPaths takes a map, so its output ordering isn't
+ // deterministic
+ sort.Strings(literalSrcPaths)
if diff := pretty.Compare(literalSrcPaths, test.expected); diff != "" {
t.Errorf("failed to get correct literal source paths: (-got, +want)\n%s", diff)
}
diff --git a/ts_auto_deps/analyze/loader.go b/ts_auto_deps/analyze/loader.go
index 51cfd44..cdfee61 100644
--- a/ts_auto_deps/analyze/loader.go
+++ b/ts_auto_deps/analyze/loader.go
@@ -380,8 +380,7 @@
func isTazeManagedRuleClass(class string) bool {
for _, c := range []string{
"ts_library",
- // TODO(alexeagle): Add ts_declaration once it can be determined
- // if they are unused.
+ "ts_declaration",
"ng_module",
"js_library",
} {