File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 159
159
:protocol-impl-recur-with-target true
160
160
:single-segment-namespace true
161
161
:munged-namespace true
162
+ :js-used-as-alias true
162
163
:ns-var-clash true
163
164
:non-dynamic-earmuffed-var true
164
165
:extend-type-invalid-method-shape true
177
178
(::externs @env/*compiler*))
178
179
179
180
(defn checked-arrays
181
+ " Returns false-y, :warn, or :error based on configuration and the
180
182
" Returns false-y , :warn , or :error based on configuration and the
181
183
current value of *unchecked-arrays*. "
182
184
[]
439
441
(str " Namespace " name " contains a reserved JavaScript keyword,"
440
442
" the corresponding Google Closure namespace will be munged to " munged)))
441
443
444
+ (defmethod error-message :js-used-as-alias
445
+ [warning-type {:keys [spec] :as info}]
446
+ (str \"In \" (pr-str spec) \", the alias name js is reserved for JavaScript interop\"))
447
+
442
448
(defmethod error-message :ns-var-clash
443
449
[warning-type {:keys [ns var] :as info}]
444
450
(str " Namespace " ns " clashes with var " var))
2994
3000
lib' ((alias-type @aliases) alias)]
2995
3001
(when (and (some? lib') (not= lib lib'))
2996
3002
(throw (error env (parse-ns-error-msg spec " :as alias must be unique" ))))
3003
+ (when (= alias 'js)
3004
+ (when-not (= lib (get-in @aliases [(if macros? :fns :macros ) 'js])) ; warn only once
3005
+ (warning :js-used-as-alias env {:spec spec})))
2997
3006
(swap! aliases
2998
3007
update-in [alias-type]
2999
3008
conj [alias lib] (when js-module-provides [js-module-provides lib]))))
Original file line number Diff line number Diff line change 1493
1493
(:import goog))]))
1494
1494
(is (= {} (get-in @cenv [::ana/namespaces 'test.foo :imports ])))))
1495
1495
1496
+ (deftest test-cljs-3320
1497
+ (let [ws (atom [])]
1498
+ (ana/with-warning-handlers [(collecting-warning-handler ws)]
1499
+ (binding [ana/*cljs-ns* 'cljs.user]
1500
+ (analyze ns-env '(ns cljs3320.core (:require [cljs.js :as js])))))
1501
+ (is (string/includes? (first @ws) " the alias name js is reserved for JavaScript interop" ))))
1502
+
1496
1503
(deftest test-cljs-3371
1497
1504
(let [ws (atom [])]
1498
1505
(ana/with-warning-handlers [(collecting-warning-handler ws)]
You can’t perform that action at this time.
0 commit comments