Skip to content

Commit

Permalink
fix: loose TS type for StateTree
Browse files Browse the repository at this point in the history
Fix #47
  • Loading branch information
posva committed Jan 9, 2020
1 parent 7a2de23 commit 092f169
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Expand Up @@ -9,5 +9,8 @@
"eslint.validate": [
"javascript",
{ "language": "typescript", "autoFix": true }
]
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
2 changes: 1 addition & 1 deletion __tests__/pinia/stores/user.ts
Expand Up @@ -2,7 +2,7 @@ import { createStore } from '../../../src'

export const useUserStore = createStore('user', () => ({
name: 'Eduardo',
isAdmin: true as boolean,
isAdmin: true,
}))

export function logout() {
Expand Down
30 changes: 1 addition & 29 deletions src/types.ts
@@ -1,24 +1,6 @@
import { Ref } from '@vue/composition-api'

interface JSONSerializable {
toJSON(): string
}

export type StateTreeValue =
| string
| symbol
| number
| boolean
| null
| void
| Function
| StateTree
| StateTreeArray
| JSONSerializable

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface StateTree
extends Record<string | number | symbol, StateTreeValue> {}
export type StateTree = Record<string | number | symbol, any>

export function isPlainObject(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -32,16 +14,6 @@ export function isPlainObject(
)
}

// symbol is not allowed yet https://github.com/Microsoft/TypeScript/issues/1863
// export interface StateTree {
// [x: number]: StateTreeValue
// [x: symbol]: StateTreeValue
// [x: string]: StateTreeValue
// }

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface StateTreeArray extends Array<StateTreeValue> {}

export interface StoreGetter<S extends StateTree, T = any> {
(state: S): T
}
Expand Down

0 comments on commit 092f169

Please sign in to comment.