1
0
Fork
You've already forked stricter-script
0
(WIP) Opinionated typed JavaScript dialect for those who hate the loosey-goosey nature of TypeScript (and JavaScript)
  • Rust 100%
Find a file
2026年01月03日 15:27:32 +08:00
src everything 2025年12月30日 16:08:26 +08:00
.gitignore everything 2025年12月30日 16:08:26 +08:00
Cargo.lock everything 2025年12月30日 16:08:26 +08:00
Cargo.toml everything 2025年12月30日 16:08:26 +08:00
README.md this is opt in now 2026年01月03日 15:27:32 +08:00

StricterScript

Disclaimer: Nothing is implemented yet.

Opinionated typed JavaScript dialect for those who hate the loosey-goosey nature of TypeScript (and JavaScript).

  • Stricter typing system: No unchecked assertions; No surprises.
    • Object types are exactly as is unlike in TypeScript where objects may contain extra fields. If you need it for whatever reason, add ... at the end of the object type.
  • Language modifications that removes historical baggages of JavaScript.
    • Operator overloading
    • Prototype extension without pollution
  • Use JavaScript and TypeScript libraries like you never left the ecosystem.

Goals

  • Use TypeScript syntax as much as possible
  • While it's not a superset of JavaScript, it is still nice to closely follow JavaScript for the sake of familiarity. use opt-in option for incompatible changes.
  • Unlike TypeScript, StricterScript isn't purely a type-deleted language, it adds to the runtime.
  • as and ! inserts runtime assertion
  • is operator for checking a value against a type
  • Stricter row polymorphism for object types instead of subtyping
  • Exhaustive destructuring, add ... at the end for non-exhaustive destructuring
  • Thrown exceptions are typed
  • All unions are discriminated
  • Classes are nominally typed: Duck typed for inheritance, I guess subtyping isn't avoidable
    • exactly Class for the exact class and not the inheriting class
    • internal for fields accessible only in the module
  • Interface implementation are required to be explicit, fields are named Interface.method in the implementing class. No implements keyword needed.
    • This for type of this with exactly This
    • private field implementation to avoid name clashing. For access, this[method of Interface], Interface.method(this, ...), Interface.value.get(this), or Interface.value.set(this, value) are used instead.
    • Implementation to third-party classes without prototype pollution, requires private implementation. These are named and then exported. Modules that import it will use the implementation.
  • Opt-in prototype extension with no actual prototype pollution. These are named and then exported. Modules that import it will use the extension.
  • Operator overloading via interfaces
  • Prelude system: Interface implementation to third-party classes and prototype extension are opt-in per module. The prelude system makes opt-ins implicit for all modules in a project.
  • All of Stage 3 proposals

Opt-in Language Modification

  • Use == for strict reference equality and === for deep equality
  • typeof null is "null"
  • Treat null and undefined as the same type, preferring null
  • Enable pattern matching on switch case
  • Proposals

Interoperability with TypeScript and JavaScript

There are incompatible types between TypeScript and StricterScript. Interoperability is limited. When using opt-in language modification, be careful as those doesn't apply in TypeScript and JavaScript.

  • There is no gradual typing within StricterScript, it is always strongly typed
  • Interoperability with TypeScript and JavaScript typed with JSDoc
    • Optional automatic assertion for untrusted typed imports
  • Interoperability with untyped JavaScript
    • JavaScript to StricterScript will have assertion enforced
    • StricterScript to JavaScript:
      • Assertions are automatically added
      • private and other similar fields will be unexported for extra privacy
      • Convenience methods are exported such as Type.is and Type.as