Skip to content

Commit 4b8a5fe

Browse files
authored
Removed jsdoc types (#1181)
* removed jsdoc types from typescript files in favor of typescript types * format
1 parent 048e4d9 commit 4b8a5fe

8 files changed

Lines changed: 6 additions & 67 deletions

File tree

src/react.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ import type { Snapshot } from './vanilla.ts'
2020
*
2121
* This internal hook collects the paths that were accessed during render
2222
* and displays them in React DevTools to help with debugging render optimizations.
23-
*
24-
* @param {object} state - The state object being tracked
25-
* @param {WeakMap<object, unknown>} affected - WeakMap of accessed properties
26-
* @private
2723
*/
2824
const useAffectedDebugValue = (
2925
state: object,

src/react/utils/useProxy.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const DUMMY_SYMBOL = Symbol()
1212
* For the best ergonomics, you can export a custom hook from your store, so you
1313
* don't have to figure out a separate name for the hook reference. E.g.:
1414
*
15+
* @example
1516
* export const store = proxy(initialState)
1617
* export const useStore = () => useProxy(store)
1718
* // in the component file:
@@ -20,9 +21,6 @@ const DUMMY_SYMBOL = Symbol()
2021
* return <button onClick={() => {store.count++}}>{store.count}</button>
2122
* }
2223
*
23-
* @param proxy
24-
* @param options
25-
* @returns A new proxy which you can use in the render as well as in callbacks.
2624
*/
2725
export function useProxy<T extends object>(
2826
proxy: T,

src/vanilla.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ type SnapshotIgnore =
4343

4444
/**
4545
* Snapshot type that converts objects to readonly versions recursively
46-
*
47-
* @template T - Type to convert to a snapshot
4846
*/
4947
export type Snapshot<T> = T extends { $$valtioSnapshot: infer S }
5048
? S
@@ -176,11 +174,6 @@ let createHandler: typeof createHandlerDefault = createHandlerDefault
176174

177175
/**
178176
* Creates a reactive proxy object that can be tracked for changes
179-
*
180-
* @template T - Type of the object to be proxied
181-
* @param {T} baseObject - The object to create a proxy for
182-
* @returns {T} A proxied version of the input object
183-
* @throws {Error} If the input is not an object
184177
*/
185178
export function proxy<T extends object>(baseObject: T = {} as T): T {
186179
if (!isObject(baseObject)) {
@@ -294,9 +287,6 @@ export function proxy<T extends object>(baseObject: T = {} as T): T {
294287

295288
/**
296289
* Gets the current version number of a proxy object
297-
*
298-
* @param {unknown} proxyObject - The proxy object to get the version of
299-
* @returns {number | undefined} The current version number, or undefined if not a proxy
300290
*/
301291
export function getVersion(proxyObject: unknown): number | undefined {
302292
const proxyState = proxyStateMap.get(proxyObject as object)
@@ -305,12 +295,6 @@ export function getVersion(proxyObject: unknown): number | undefined {
305295

306296
/**
307297
* Subscribes to changes in a proxy object
308-
*
309-
* @template T - Type of the proxy object
310-
* @param {T} proxyObject - The proxy object to subscribe to
311-
* @param {Function} callback - Function called when the proxy object changes
312-
* @param {boolean} [notifyInSync] - If true, notifications happen synchronously
313-
* @returns {Function} Unsubscribe function to stop listening for changes
314298
*/
315299
export function subscribe<T extends object>(
316300
proxyObject: T,
@@ -350,10 +334,6 @@ export function subscribe<T extends object>(
350334

351335
/**
352336
* Creates an immutable snapshot of the current state of a proxy object
353-
*
354-
* @template T - Type of the proxy object
355-
* @param {T} proxyObject - The proxy object to create a snapshot from
356-
* @returns {Snapshot<T>} An immutable snapshot of the current state
357337
*/
358338
export function snapshot<T extends object>(proxyObject: T): Snapshot<T> {
359339
const proxyState = proxyStateMap.get(proxyObject as object)
@@ -369,10 +349,6 @@ export function snapshot<T extends object>(proxyObject: T): Snapshot<T> {
369349
*
370350
* Objects marked with ref will be kept as references in snapshots
371351
* instead of being deeply copied.
372-
*
373-
* @template T - Type of the object to mark as a reference
374-
* @param {T} obj - The object to mark as a reference
375-
* @returns {T & { $$valtioSnapshot: T }} The same object with a type marker
376352
*/
377353
export function ref<T extends object>(obj: T) {
378354
refSet.add(obj)

src/vanilla/utils/deepClone.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ const getDefaultRefSet = (): WeakSet<object> => {
1313

1414
/**
1515
* Creates a deep clone of an object, maintaining proxy behavior for Maps and Sets
16-
*
17-
* @template T - Type of the object to clone
18-
* @param {T} obj - The object to clone
19-
* @param {Function} [getRefSet=getDefaultRefSet] - Function to get the set of reference objects
20-
* @returns {T} A deep clone of the input object
2116
*/
2217
export function deepClone<T>(
2318
obj: T,

src/vanilla/utils/devtools.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ type Options = {
2929
*
3030
* Limitation: Only plain objects/values are supported.
3131
*
32-
* @template T - Type of the proxy object
33-
* @param {T} proxyObject - The proxy object to connect to DevTools
34-
* @param {Options} [options] - Configuration options for the DevTools connection
35-
* @param {boolean} [options.enabled] - Explicitly enable or disable the connection
36-
* @param {string} [options.name=''] - Name to display in DevTools
37-
* @returns {Function|undefined} Unsubscribe function to disconnect from DevTools, or undefined if connection failed
38-
*
3932
* @example
4033
* import { devtools } from 'valtio/utils'
4134
* const state = proxy({ count: 0, text: 'hello' })

src/vanilla/utils/proxyMap.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ type InternalProxyObject<K, V> = Map<K, V> & {
1212

1313
/**
1414
* Determines if an object is a proxy Map created with proxyMap
15-
*
16-
* @param {object} obj - The object to check
17-
* @returns {boolean} True if the object is a proxy Map, false otherwise
1815
*/
1916
export const isProxyMap = (obj: object): boolean => {
2017
return (
@@ -31,24 +28,20 @@ export const isProxyMap = (obj: object): boolean => {
3128
* allowing you to track changes to the Map in the same way as regular proxy objects.
3229
* The API is the same as the standard JavaScript Map.
3330
*
34-
* @template K - Type of the Map keys
35-
* @template V - Type of the Map values
36-
* @param {Iterable<[K, V]>} [entries] - Initial key-value pairs to populate the Map
37-
* @returns {Map<K, V>} A proxy Map object that tracks changes
38-
* @throws {TypeError} If entries is not iterable
39-
*
4031
* @example
4132
* import { proxyMap } from 'valtio/utils'
4233
* const state = proxyMap([["key", "value"]])
4334
*
44-
* // can be used inside a proxy as well
35+
* This can be used inside a proxy as well
36+
*
4537
* const state = proxy({
4638
* count: 1,
4739
* map: proxyMap()
4840
* })
4941
*
50-
* // When using an object as a key, you can wrap it with `ref` so it's not proxied
51-
* // this is useful if you want to preserve the key equality
42+
* When using an object as a key, you can wrap it with `ref` so it's not proxied
43+
* this is useful if you want to preserve the key equality
44+
*
5245
* import { ref } from 'valtio'
5346
*
5447
* const key = ref({})

src/vanilla/utils/proxySet.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ type InternalProxySet<T> = Set<T> & {
2626

2727
/**
2828
* Determines if an object is a proxy Set created with proxySet
29-
*
30-
* @param {object} obj - The object to check
31-
* @returns {boolean} True if the object is a proxy Set, false otherwise
3229
*/
3330
export const isProxySet = (obj: object): boolean => {
3431
return (
@@ -46,11 +43,6 @@ export const isProxySet = (obj: object): boolean => {
4643
* The API extends the standard JavaScript Set with additional set operations like
4744
* union, intersection, difference, etc.
4845
*
49-
* @template T - Type of the Set elements
50-
* @param {Iterable<T>} [initialValues] - Initial values to populate the Set
51-
* @returns {Set<T>} A reactive proxy Set with extended methods
52-
* @throws {TypeError} If initialValues is not iterable
53-
*
5446
* @example
5547
* import { proxySet } from 'valtio/utils'
5648
* const state = proxySet([1,2,3])

src/vanilla/utils/watch.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ let currentCleanups: Set<Cleanup> | undefined
2929
*
3030
* `watch` calls inside `watch` are also automatically tracked and cleaned up
3131
* whenever the parent `watch` reevaluates.
32-
*
33-
* @param callback
34-
* @returns A cleanup function that stops the callback from reevaluating and
35-
* also performs cleanups registered into `watch`.
3632
*/
3733
export function watch(
3834
callback: WatchCallback,

0 commit comments

Comments
 (0)