Skip to content

Commit 092f169

Browse files
committed
fix: loose TS type for StateTree
Fix #47
1 parent 7a2de23 commit 092f169

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

.vscode/settings.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
"eslint.validate": [
1010
"javascript",
1111
{ "language": "typescript", "autoFix": true }
12-
]
12+
],
13+
"editor.codeActionsOnSave": {
14+
"source.fixAll.eslint": true
15+
}
1316
}

__tests__/pinia/stores/user.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createStore } from '../../../src'
22

33
export const useUserStore = createStore('user', () => ({
44
name: 'Eduardo',
5-
isAdmin: true as boolean,
5+
isAdmin: true,
66
}))
77

88
export function logout() {

src/types.ts

+1-29
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
import { Ref } from '@vue/composition-api'
22

3-
interface JSONSerializable {
4-
toJSON(): string
5-
}
6-
7-
export type StateTreeValue =
8-
| string
9-
| symbol
10-
| number
11-
| boolean
12-
| null
13-
| void
14-
| Function
15-
| StateTree
16-
| StateTreeArray
17-
| JSONSerializable
18-
19-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
20-
export interface StateTree
21-
extends Record<string | number | symbol, StateTreeValue> {}
3+
export type StateTree = Record<string | number | symbol, any>
224

235
export function isPlainObject(
246
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -32,16 +14,6 @@ export function isPlainObject(
3214
)
3315
}
3416

35-
// symbol is not allowed yet https://github.com/Microsoft/TypeScript/issues/1863
36-
// export interface StateTree {
37-
// [x: number]: StateTreeValue
38-
// [x: symbol]: StateTreeValue
39-
// [x: string]: StateTreeValue
40-
// }
41-
42-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
43-
interface StateTreeArray extends Array<StateTreeValue> {}
44-
4517
export interface StoreGetter<S extends StateTree, T = any> {
4618
(state: S): T
4719
}

0 commit comments

Comments
 (0)