Skip to content

Commit 520d5db

Browse files
committed
remove the need for validPlexusTypes
1 parent f56e76b commit 520d5db

File tree

4 files changed

+6
-34
lines changed

4 files changed

+6
-34
lines changed

packages/plexus-core/src/scope.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
} from './instance/instance'
1212
import { PlexusPreActionConfig, _preaction } from './preaction'
1313
import { _state } from './state'
14-
import { Fetcher, PlexusValidStateTypes } from './types'
1514

1615
export interface PlexusScopeConfig {}
1716

@@ -50,10 +49,7 @@ export class Scope {
5049
* @param item The default value to use when we generate the state
5150
* @returns A Plexus State Instance
5251
*/
53-
state<
54-
Override extends PlexusValidStateTypes = never,
55-
Value = Override extends AlmostAnything ? Override : any
56-
>(item: Value) {
52+
state<Override = never, Value = Override>(item: Value) {
5753
return _state(this.instance, item)
5854
}
5955

@@ -62,12 +58,7 @@ export class Scope {
6258
* @param item The default value to use when we generate the state
6359
* @returns A Plexus State Instance
6460
*/
65-
computed<
66-
Override extends PlexusValidStateTypes = never,
67-
Value extends PlexusValidStateTypes = Override extends AlmostAnything
68-
? Override
69-
: any
70-
>(
61+
computed<Override = never, Value = Override>(
7162
item: (value?: Value) => Value,
7263
dependencies: Array<Watchable<any>> | Watchable<any>
7364
) {

packages/plexus-core/src/state.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import {
2-
AlmostAnything,
32
PlexusWatchableValueInterpreter,
43
deepClone,
54
deepMerge,
6-
isEqual,
75
isObject,
86
} from '@plexusjs/utils'
97
import { PlexusInstance, instance } from './instance/instance'
10-
import { Fetcher, PlexusInternalWatcher, PlexusValidStateTypes } from './types'
8+
import { PlexusInternalWatcher } from './types'
119

1210
import { WatchableMutable } from './watchable'
13-
// import { PlexusInstance, PlexStateInternalStore, PlexusStateType, PlexusStateInstance, PlexusWatcher } from "./interfaces"
1411

15-
export type PlexusState = <Value extends PlexusValidStateTypes = any>(
12+
export type PlexusState = <Value = any>(
1613
instance: () => PlexusInstance,
1714
input: Value
1815
) => StateInstance<Value>
@@ -24,8 +21,7 @@ export interface StateStore {
2421
_ready: boolean
2522
_isSetting: boolean
2623
}
27-
export type PlexusStateInstance<Value extends PlexusValidStateTypes = any> =
28-
StateInstance<Value>
24+
export type PlexusStateInstance<Value = any> = StateInstance<Value>
2925
/**
3026
* A trackable State
3127
*/
@@ -308,20 +304,6 @@ export function _state<StateValue>(
308304
return new StateInstance(instance, _init)
309305
}
310306

311-
// export function state<
312-
// Literal extends PlexusStateType = any,
313-
// Value extends PlexusStateType = Literal extends AlmostAnything
314-
// ? Literal
315-
// : TypeOrReturnType<Literal>
316-
// >(item: Fetcher<Value>): TypeOrReturnType<Value>
317-
318-
// export function state<
319-
// Literal extends PlexusStateType = any,
320-
// Value extends PlexusStateType = Literal extends AlmostAnything
321-
// ? Literal
322-
// : TypeOrReturnType<Literal>
323-
// >(item: Value): StateInstance<Value>
324-
325307
/**
326308
* Generate a Plexus State
327309
* @param item The default value to use when we generate the state

packages/plexus-core/src/watchable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
isEqual,
55
PlexusWatchableValueInterpreter,
66
} from '@plexusjs/utils'
7-
import { Fetcher, PlexusValidStateTypes, PlexusWatcher } from './types'
7+
import { Fetcher, PlexusWatcher } from './types'
88

99
const getFetcher = function <ValueType>(
1010
subject: ValueType | (() => ValueType)

tests/scope.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
2-
// import { collection, PlexusCollectionInstance } from '@plexusjs/core'
32
import { appointments, UserLite, usersLite } from './test-utils'
43

54
import { randFirstName, randUuid } from '@ngneat/falso'

0 commit comments

Comments
 (0)