Skip to content

Syntax entry for $ (dollar sign) #186

Open

Description

@shaunlebron

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;
};

Activity

  1. shaunlebron commented on Feb 27, 2026

    @shaunlebron
    MemberAuthor

    also shadow-cljs allows requiring package$default for the default export:

    (ns ...
      (:require ["string-comparison$default" :refer [jaroWinkler levenshtein]]))

    equivalent to node:

    const {jaroWinkler, levenshtein} = require('string-comparison').default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions