framework/js
David Wheatley cab2e797eb
Rewrite ItemList; update ItemList typings (#3005)
* Improve typings for ItemList

* Add new `.replace()` syntax

* Update JSDoc

* Add missing `T` type

* Fix typo

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>

* Allow choice to not set `itemName` property when calling `toArray`

* Make `ItemList.items` read-only

* Modify `.replace()`; add `.changePriority()`

* Complete rename

* Update JSDoc

* Add `.toObject()` method; deprecate `.items`

* Rewrite `.toArray()` to use Proxy instead of modifying the item content

- Fixes #3030
- Fixes issue where setting `itemName` property could result in errors depending on the object type (e.g. proxies)
- Fixes unneeded duplication of item list
- Add option to disable setting `itemName` property on primitives

* Simplify condition

* Remove debug code

* Make proxying function protected instead of private

* Update a usage of ItemList as an example

* Make `itemName` property read-only

* Use correct capitalisation of `object`

* Invert `toArray` parameter function

* Simplify isEmpty check

* Update ItemList.ts

* Fix `merge()`

* Remove extra JSDoc comment

* Use `._items` directly for merging

* Rename methods: `replace` -> `set`; `changePriority` -> `setPriority`

This more closely matches our existing method names (`get()`)

* Change `items` getter

* Simplify proxying

* Update URL to source function

* Update compat

* Various changes to toObject

* Remove `Item.key`

* Make item content proxy method private

* Enforce merge typings

* Update TSDoc comments to use `{@link}` for references to methods

* Correct references to deprecated `.replace` method

* Throw error when setting content/priority of non-existent items

* Remove intermediary variable

* Update TSDoc block

* Update js/src/@types/global.d.ts

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-11-11 20:01:10 +00:00
..
.yarn/releases chore: migrate fully to Yarn (#3155) 2021-11-10 20:10:25 +00:00
dist Bundled output for commit bac0e594ee 2021-11-11 19:21:56 +00:00
dist-typings Bundled output for commit bac0e594ee 2021-11-11 19:21:56 +00:00
src Rewrite ItemList; update ItemList typings (#3005) 2021-11-11 20:01:10 +00:00
.bundlewatch.config.json Add bundlewatch to track bundle size changes in PRs (#2695) 2021-03-17 14:54:42 +00:00
.gitignore chore: migrate fully to Yarn (#3155) 2021-11-10 20:10:25 +00:00
.yarnrc.yml chore: migrate fully to Yarn (#3155) 2021-11-10 20:10:25 +00:00
admin.js Drop JS copyright blocks 2021-05-15 20:11:38 -04:00
forum.js Drop JS copyright blocks 2021-05-15 20:11:38 -04:00
package.json Add typechecks, typescript coverage GH action, fix many type errors (#3136) 2021-11-11 14:17:22 -05:00
tsconfig.json Update core to use new Webpack config, flarum-tsconfig, and build action (#2856) 2021-05-13 00:28:17 +01:00
webpack.config.js chore: migrate fully to Yarn (#3155) 2021-11-10 20:10:25 +00:00
yarn.lock Add typechecks, typescript coverage GH action, fix many type errors (#3136) 2021-11-11 14:17:22 -05:00