A sketch of a non-standard library for javascript and typescript.
-
Comprehensive type safety
-
Prefer immutability
-
Consistency with the actual standard library
-
Leverage typescript's language service
-
Compatibility with foreign packages
- Data structures should conform to standard or broadly-used interfaces
-
Usability from javascript
- Functionality hard to use correctly without a type checker requires special justification
- Where possible, constraints described in type annotations should be enforced at runtime
-
Within the above constraints: power over familiarity
- Compatibility with pre-
latestruntimes - Small bundle size
- Compilation performance
- Consistency with the broader ecosystem
-
Hard prohibition: namespace collision
- Anything added to
globalThisor monkey-patched functionality must have asymbolname
- Anything added to
-
Use magic internally when it improves the experience for callers
- Lie to the type checker
-
Callers should never be encouraged to write their own magic