We're updating the issue view to help you get more done. 

Suppress warnings for qualified references to transitively loaded Closure libs

Description

This ticket asks that analyzer warnings be suppressed when using transitively loaded Closure libs via qualified references.

co.edn

1 {:libs ["libs/mylib.js"]}

libs/mylib.js

1 2 3 4 5 goog.provide('my_lib.core') my_lib.core = { add: function(x, y) { return x + y; } }

src/foo/core.cljs

1 2 3 (ns foo.core (:require my-lib.core clojure.set))

Here is an example illustrating the concept:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 $ clj -m cljs.main -co co.edn -re node -r ClojureScript 1.10.339 cljs.user=> (clojure.set/intersection #{1 2 3} #{2 4 5}) WARNING: Use of undeclared Var clojure.set/intersection at line 1 <cljs repl> ... cljs.user=> (require 'foo.core) nil cljs.user=> (clojure.set/intersection #{1 2 3} #{2 4 5}) #{2} cljs.user=> (clojure.set/intersection) WARNING: Wrong number of args (0) passed to clojure.set/intersection at line 1 <cljs repl> cljs.user=> (my-lib.core/add 2 3) WARNING: No such namespace: my-lib.core, could not locate my_lib/core.cljs, my_lib/core.cljc, or JavaScript source providing "my-lib.core" (Please check that namespaces with dashes use underscores in the ClojureScript file name) at line 1 <cljs repl> WARNING: Use of undeclared Var my-lib.core/add at line 1 <cljs repl> 5 cljs.user=> (in-ns 'foo.core) nil foo.core=> (my-lib.core/add 2 3) 5

In the above, you can see that when a transitively loaded ClojureScript namespace (in this example clojure.set) is used via qualified symbols, the analyzer works properly.

This characteristic evidently doesn't currently apply to Closure libs, so (correctly functioning) source code would need to be revised in this example simply in order to avoid analyzer warnings (and the source code would need to be aware that a namespace is implemented by a Closure lib instead of a ClojureScript namespace).

The argument for this enhancement is that it leads to consistency and make it possible to cleanly use Closure libs in valid scenarios where transitive dependencies are used. (Normally it is a bad idea to not directly indicate your dependencies in a given namespace, but an arguably copacetic use is when you are using a namespace that exposes macros that expand to use code that the namespace transitively loads. This could occur, for example with macros that want to use libs defined via :libs or even libs in Closure Library.)

Environment

{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"}}}

Status

Assignee

Unassigned

Reporter

Mike Fikes

Labels

None

Approval

None

Patch

None

Priority

Major