]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix: loose TS type for StateTree
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 9 Jan 2020 17:20:15 +0000 (18:20 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 9 Jan 2020 17:20:34 +0000 (18:20 +0100)
Fix #47

.vscode/settings.json
__tests__/pinia/stores/user.ts
src/types.ts

index 52d6a46d33d3e228faa60110103f7851f20c7b6b..1a316121823e6458040a2d9c31488012b3642b6c 100644 (file)
@@ -9,5 +9,8 @@
   "eslint.validate": [
     "javascript",
     { "language": "typescript", "autoFix": true }
-  ]
+  ],
+  "editor.codeActionsOnSave": {
+    "source.fixAll.eslint": true
+  }
 }
index 67ca840fc3eb0129471d68bb8e84097a8d8c4b41..4697483a9d008baa8facf8af23418b6e9ce63451 100644 (file)
@@ -2,7 +2,7 @@ import { createStore } from '../../../src'
 
 export const useUserStore = createStore('user', () => ({
   name: 'Eduardo',
-  isAdmin: true as boolean,
+  isAdmin: true,
 }))
 
 export function logout() {
index 58052fb97c828f8a8a8afbd31e3c0553ac7aedbc..ea88e470e047c714313deff66dec6937bc54a6b1 100644 (file)
@@ -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
@@ -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
 }