Skip to content

Releases: jc-verse/ts-klass

v0.5.0

19 May 04:31
d3c513b
Compare
Choose a tag to compare
v0.5.0 Pre-release
Pre-release

Features:

  • Accessors. Previously we used Object.entries to map the klass body, which means accessors are flattened to data properties. We now use Object.getOwnPropertyDescriptors, which helps to preserve the accessors' nature. Non-enumerable properties are still ignored as before.
  • klass.configure. We added a new top-level API that allows you to configure certain behaviors of klasses. Currently, we offer two options:
    • constructWithNеw: a linter-like feature that requires every klass construction to go through nеw instead of being called directly.
    • UNSAFE_disableNoThisBeforeSuperCheck: as the name implies, do not use this unless you know what you are doing. This allows you to access this before calling super.constructor in the klass constructor. This means you can access the uninitialized klass instance. The accessors/methods will still be present, though, because they are statically defined on the prototype.

v0.4.0

25 Apr 11:52
c343e64
Compare
Choose a tag to compare
v0.4.0 Pre-release
Pre-release

Features:

  • In the last release (v0.3.0), we added the extends API. At that time, it was neither documented nor actually functional. In this release, it is fully functional.
  • You can use extends to bind prototypes, and even call super.constructor, super.method, etc.
  • Accessing this is disallowed before super. We even offer better error messages than v8 (because we have to use a proxy anyways). However, we may not be able to catch all usage to this, particularly those that don't trigger proxy traps.

Bug fixes:

  • We fixed an ECMAScript conformance failure where const K = klass({ field: 1 }) would have field defined on K.prototype instead of every instance of K. field should be seen as a class field.
    • Our heuristic for "class field vs. class method" is currently typeof value === "function". This is not ideal because const K = klass({ field: () => {} }) should still be a class field. If you have a better algorithm to differentiate methods from function properties (testing for construtibility won't work, because arrow functions aren't constructible either), contributions welcome.

We added a lot of ES conformance tests to ensure that we are maximally compatible with ES semantics, especially in terms of prototype assignment.

v0.3.0

24 Apr 09:05
7ef150f
Compare
Choose a tag to compare
v0.3.0 Pre-release
Pre-release

Features:

  • Better toString behavior: returns [object <KlassName>] instead of [object Object] (ECMAScript conformance)
  • Klass.length returns the length of the constructor function (ECMAScript conformance)
  • New klass branded check method: Klass instanceof klass

The internal code is also structured in a much better way now.

v0.2.0

24 Apr 08:57
9b0248a
Compare
Choose a tag to compare
v0.2.0 Pre-release
Pre-release

Features:

  • TypeScript typings

v0.1.0

13 Apr 10:06
36d0789
Compare
Choose a tag to compare
v0.1.0 Pre-release
Pre-release

Features:

  • Static fields
  • Name-bound klass creators
  • Throw if attempting to new a klass
  • Allow getting klass from instance.constructor (reflection)