cljs / api

ClojureScript API parser
http://cljs.github.io/api/
MIT License
193 stars 23 forks source link

Syntax entry for $ (dollar sign) #186

Open shaunlebron opened 3 years ago

shaunlebron commented 3 years ago

As of 1.10.844, dollar signs can be used to refer to nested namespaces in JS: https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces

(ns foo
  (:require [react-native$NativeModules.SomeBridge :as woz]))

This might be related to inner class names in Clojure, due to JVM rules: https://clojure.org/reference/java_interop

Note that nested classes are named EnclosingClass$NestedClass, per the JVM spec

But it also looks like a convention from Closure Compiler in JS used to flatten foo.bar.baz to foo$bar$baz but I can’t remember how to find this. This mentions it for renaming anonymous functions: https://github.com/roman01la/closure-compiler-handbook#anonymous-functions-naming

math.simple.add = function $math$simple$add$(a, b) {
  return a + b;
};