mobx 6.11.0-pre → 6.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +2 -2
- package/dist/mobx.cjs.development.js +8 -11
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +8 -11
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +8 -11
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.umd.development.js +8 -11
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/dist/types/observableobject.d.ts +0 -1
- package/package.json +1 -1
- package/src/api/decorators.ts +5 -1
- package/src/api/observable.ts +1 -0
- package/src/types/observableannotation.ts +12 -12
- package/src/types/observableobject.ts +0 -16
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
}
|
|
423
423
|
function assert20223DecoratorType(context, types) {
|
|
424
424
|
if ( !types.includes(context.kind)) {
|
|
425
|
-
die("
|
|
425
|
+
die("The decorator applied to '" + String(context.name) + "' cannot be used on a " + context.kind + " element");
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
|
|
@@ -920,24 +920,21 @@
|
|
|
920
920
|
}
|
|
921
921
|
function decorate_20223_$4(desc, context) {
|
|
922
922
|
{
|
|
923
|
-
|
|
923
|
+
if (context.kind === "field") {
|
|
924
|
+
throw die("Please use `@observable accessor " + String(context.name) + "` instead of `@observable " + String(context.name) + "`");
|
|
925
|
+
}
|
|
926
|
+
assert20223DecoratorType(context, ["accessor"]);
|
|
924
927
|
}
|
|
925
928
|
var ann = this;
|
|
926
929
|
var kind = context.kind,
|
|
927
|
-
name = context.name
|
|
928
|
-
addInitializer = context.addInitializer;
|
|
929
|
-
// Backwards/Legacy behavior, expects makeObservable(this)
|
|
930
|
-
if (kind == "field") {
|
|
931
|
-
addInitializer(function () {
|
|
932
|
-
storeAnnotation(this, name, ann);
|
|
933
|
-
});
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
930
|
+
name = context.name;
|
|
936
931
|
// The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:
|
|
937
932
|
// `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).
|
|
938
933
|
// This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot
|
|
939
934
|
// before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member
|
|
940
935
|
// from an object whose class did not declare it` error.
|
|
936
|
+
// TODO: it seems that this will not be required anymore in the final version of the spec
|
|
937
|
+
// See TODO: link
|
|
941
938
|
var initializedObjects = new WeakSet();
|
|
942
939
|
function initializeObservable(target, value) {
|
|
943
940
|
var _ann$options_$enhance, _ann$options_;
|