Page:
Singleton Pattern Externs Inference Support
Pages
Advanced Compilation
Atom
Bootstrapped ClojureScript FAQ
Bootstrapping the Compiler
Building the compiler
ClojureScript Puppet Manifest
Common Problems
Companies Using ClojureScript
Comparators
Compile Time Type Checking
Compiler Options
Cursive
Custom Build Tools
Custom REPLs
Dependencies
Developers
Differences from Clojure
Emacs & Inferior Clojure Interaction Mode
Emacs & Inferior Clojure Interaction Mode
Enhanced JavaScript Module Support
Enhanced Node.js Modules Support
Exception Handling
FAQ (for JavaScript developers)
Google Closure Library
Google Closure
Google Summer of Code 2015
Home
JavaScript Library Preprocessing
JavaScript Module Support (Alpha)
Launch Plan
Light Table
Optional Self hosting
Packaging Foreign Dependencies
Patches
Providing IO utilities
Quick Start
REPL Options
REPL stack traces
Rationale
Reader
Release plans
Remote REPL
Reporting Bootstrap Issues
Reporting Issues
Road Map
Running REPLs
Running the tests
Singleton Pattern Externs Inference Support
Source maps
Sublime Text 2
Testing
The REPL and Evaluation Environments
Underpinnings
Using cljc
Vim
Windows Setup
Working with Javascript classes
_Sidebar.md
lein cljsbuild
No results
3
Singleton Pattern Externs Inference Support
David Nolen edited this page 2017-02-10 16:23:30 -05:00
Table of Contents
The Problem
Currently externs inference is well suited for interop patterns that involve foreign JS instances, for example a function that takes a instance of React.Element. However, the feature is poorly suited for the popular singleton pattern employed by libraries like jQuery and D3 where all the interesting operations are provided through a single instance. In this case, the user will see many warnings about generated externs on Object but this is exactly what the user wants.
Proposed Solution
Support additional metadata to support the singleton pattern and suppress undesirable warnings.
(def ^:singleton $ (js/require "jQuery"))
Alternative name - :js/singleton.