Commit Graph

93 Commits

Author SHA1 Message Date
Evan You 20a361541c fix(types): fix ref unwrapping type inference for nested shallowReactive & shallowRef
fix #4771
2021-10-09 17:51:15 -04:00
Che Guevara 925bc346fe
fix(types): make `toRef` return correct type(fix #4732) (#4734)
* fix(types): make `toRef` return correct type(fix #4732)

* chore: use correct test

Co-authored-by: Evan You <yyx990803@gmail.com>
2021-10-08 11:57:49 -04:00
zhangenming 52e4ea732d
refactor(reactivity): reuse toReactive helper (#4641) 2021-09-22 10:11:54 -04:00
Evan You 815bfcffae fix(types): fix ref macro types
fix #4499
2021-09-04 16:42:46 -04:00
zhangenming a6e6253319
types(reactivity): adjust type exports (#4407) 2021-09-01 16:49:12 -04:00
zhangenming 9043d0dca7
refactor(reactivity): use explicit assignments. (#4401) 2021-08-23 18:32:58 -04:00
zhangenming d8da4214fc
refactor(reactivity): reduce variable access (#4366) 2021-08-17 12:11:52 -04:00
Pick da6c055b19
types(reactivity): simplify UnwrapNestedRefs (#4194) 2021-07-28 11:15:08 -04:00
Pick b79e4ca717
types(reactivity): Simplify the SymbolExtract (#4162) 2021-07-28 11:12:46 -04:00
Evan You 2581cfb707 fix(types): fix types for readonly ref
fix #4180
2021-07-23 15:24:58 -04:00
Evan You 47f488350c chore: run updated prettier 2021-07-19 18:24:18 -04:00
Evan You 979a841946 chore: use consistent file naming 2021-07-16 14:30:49 -04:00
Bas van Meurs 6cf2377cd4 perf(reactivity): use bitwise dep markers to optimize re-tracking (#4017) 2021-07-16 14:30:49 -04:00
Evan You b2554aefba refactor: small bundle size / readability optimization 2021-07-16 14:30:49 -04:00
Bas van Meurs 64310405ac perf(reactivity): ref-specific track/trigger and miscellaneous optimizations (#3995) 2021-07-16 14:30:49 -04:00
Yang Mingshan 08f504c1b7
fix(ref): should not trigger when setting value to same proxy (#3658) 2021-07-15 16:28:01 -04:00
Carlos Rodrigues f6a5f09a3a
types(defineComponent): fix unwrap when returning `Ref<T>|undefined` from `setup` (#4100) 2021-07-15 15:58:20 -04:00
Evan You 127ed1b969 fix(types): improve type of unref()
fix #3954
2021-07-01 15:20:49 -04:00
zhangenming 960ef1691f
chore(reactivity): remove unnecessary RefImpl _shallow default value (#3895) 2021-06-08 09:58:02 -04:00
Lo Leon 90aa835812
fix(types/reactivity): error TS4058 caused by `RefSymbol` (#2548) 2021-05-24 16:36:08 -04:00
07akioni 4ca4666d58
fix(toRef): ref created from union typed prop can't be used in watch (#3048) 2021-02-03 19:12:51 +01:00
Evan You e315d84936 fix(types): fix ToRefs type on union value types
fix #2687
2020-12-02 14:58:03 -05:00
Evan You 8e20375372 fix(types): ensure correct type for toRef and toRefs on existing refs 2020-10-27 18:50:34 -04:00
Evan You 390589ec6d fix(reactivity): should not trigger watch on computed ref when value is unchanged
fix #2231
2020-10-06 18:16:20 -04:00
Carlos Rodrigues d4bf9bcbb4
fix(reactivity): `toRef` should not wrap a `ref` (#2103) 2020-09-15 10:29:38 -04:00
Robbin Baauw 07919e0065
perf(reactivity): improve ref performance by using class-based implementation (#1900) 2020-08-21 13:47:41 -04:00
Carlos Rodrigues c86e7ad11b
types(reactivity): improve typings for `shallowRef` (#1780) 2020-08-18 23:34:29 -04:00
Jordan Pittman 4172fdb90c
feat(reactivity): return array when calling `toRefs` on array (#1768)
close #1764
2020-08-18 12:11:13 -04:00
Evan You aa06b1034d
feat(reactivity): `proxyRefs` method and `ShallowUnwrapRefs` type (#1682)
* feat(reactivity): `proxyRefs` method and `ShallowUnwrapRefs` type

BREAKING CHANGE: template auto ref unwrapping are now applied shallowly,
i.e. only at the root level. See https://github.com/vuejs/vue-next/pull/1682 for
more details.
2020-07-28 16:30:56 -04:00
Evan You b7ef38b773 fix(reactivity): fix ref mutation debugger event values 2020-07-28 12:01:34 -04:00
Felix Rilling 829b35e426
chore: typo fixes (#1546)
* chore: fix typos in comments/JSDoc.

* chore: fix typo in internal function name.

* chore: fix typos in test comments/descriptions/variable names.
2020-07-08 12:32:42 +02:00
Pick c69ca88c04
refactor(types): simplify UnwrapRefSimple (#1466) 2020-06-30 12:02:21 -04:00
Evan You 82b28a5ecb fix(types): should unwrap array -> object -> ref 2020-06-29 12:26:28 -04:00
Pick f54be6a462
refactor(types): simplify UnwrapRef + specify iterable method return type (#1444) 2020-06-25 12:04:14 -04:00
Pick 8899a90fc4
refactor(types): simplified UnwrapRef (#1390) 2020-06-17 16:06:55 -04:00
Evan You c6217b4d46 refactor(types): use pure type symbol 2020-05-04 09:38:32 -04:00
Evan You bc1f097e29 fix(types/reactivity): fix ref type inference on nested reactive properties with .value
fix #1111
2020-05-04 08:51:17 -04:00
Evan You d901b6bea8 refactor(reactivity): use more efficient reactive checks
WeakSets and WeakMaps shows degrading performance as the amount of
observed objects increases. Using hidden keys result in better
performance especially when repeatedly creating large amounts of
reactive proxies.

This also makes it possible to more efficiently declare non-reactive
objects in userland.
2020-05-02 16:58:17 -04:00
Evan You b40fcbc4c6 fix(types): augment ref unwrap bail types in appropriate packages
Packages can now augment the ref unwrap bail types in their own `d.ts`.
Also updated the build script to auto concat any files in a package's
`types` directory to the final generated `d.ts`.

- `@vue/reactivity` should no longer require `libs: ["DOM"]` in tsconfig
- Properly bail on `VNode` and `ComponentPublicInstance` in runtime-core
2020-05-01 16:14:30 -04:00
Carlos Rodrigues 28b4c317b4
feat(types): expose `ToRefs` type (#1037) 2020-04-24 13:10:16 -04:00
Evan You 2acf3e84b9 feat(reactivity): add triggerRef API
Also make shallowRef assignment behavior consistent with normal ref
2020-04-22 18:00:10 -04:00
Evan You b0d4df9743 perf(reactivity): ref should not trigger if value did not change
Note: shallowRef will always trigger on assignment because it does not
account for deep mutations

close #1012
2020-04-22 15:11:01 -04:00
Carlos Rodrigues 0bdd889156
fix(types): fix ref(false) type to Ref<boolean> (#1028) 2020-04-22 11:54:54 -04:00
Cédric Exbrayat 4d014dc3d3
fix(reactivity): remove Symbol.observable (#968)
* chore: add @types/node as an explicit dependency

As `tsconfig.json` references it, it should be listed in the dependencies.
It currently uses an older version: this commit also bumps to the latest v12 version, and fixes a typing issue.

* fix(reactivity): remove Symbol.observable

`Symbol.observable` is brought by `@types/node@12` and is not a "well-known" typescript symbol https://www.typescriptlang.org/docs/handbook/symbols.html that can be find in lib.es20xx like the others. It has been removed in `@types/node@v13`.
It means that an application using vue@3.0.0-alpha.13 does not compile unless it explicitely adds `@types/node@v12` as a dependency and `node` in its own tsconfig types.
2020-04-16 09:33:30 -04:00
Evan You 09b4202a22 refactor(reactivity): adjust APIs
BREAKING CHANGE: Reactivity APIs adjustments:

- `readonly` is now non-tracking if called on plain objects.
  `lock` and `unlock` have been removed. A `readonly` proxy can no
  longer be directly mutated. However, it can still wrap an already
  reactive object and track changes to the source reactive object.

- `isReactive` now only returns true for proxies created by `reactive`,
   or a `readonly` proxy that wraps a `reactive` proxy.

- A new utility `isProxy` is introduced, which returns true for both
  reactive or readonly proxies.

- `markNonReactive` has been renamed to `markRaw`.
2020-04-15 16:45:20 -04:00
pikax 8a74260b70 types: remove tuple check and add type check for tuple 2020-04-15 16:22:44 +01:00
Carlos Rodrigues 70b55d797f
Apply suggestions from code review
Co-Authored-By: Evan You <yyx990803@gmail.com>
2020-04-15 16:07:07 +01:00
pikax dcb5985c00 Merge remote-tracking branch 'github/master' into changing_unwrap_ref 2020-04-15 15:54:26 +01:00
Evan You 486dc188fe feat(reactivity): add support for `toRef` API 2020-04-14 20:49:18 -04:00
Evan You b83c580131 feat(reactivity): add support for `customRef` API 2020-04-14 20:45:46 -04:00