rawItems: [] as string[],
}),
getters: {
- items: state =>
- state.rawItems.reduce((items, item) => {
+ items() {
+ return this.rawItems.reduce((items, item) => {
const existingItem = items.find(it => it.name === item)
if (!existingItem) {
}
return items
- }, [] as { name: string; amount: number }[]),
+ }, [] as { name: string; amount: number }[])
+ },
},
})
const user = useUserStore()
if (!user.state.name) return
- console.log('Purchasing', cart.items.value)
- const n = cart.items.value.length
+ console.log('Purchasing', cart.items)
+ const n = cart.items.length
cart.state.rawItems = []
return n
},
},
getters: {
- test: state => state.name.toUpperCase(),
+ test() {
+ return this.name.toUpperCase()
+ },
},
})
import { createStore, setActiveReq } from '../src'
-import { computed } from '@vue/composition-api'
+import { computed } from 'vue'
describe('State', () => {
const useStore = () => {
-import { createComponent, computed } from '@vue/composition-api'
+import { defineComponent, computed } from 'vue'
import { useStore } from './store'
-export default createComponent({
+export default defineComponent({
setup() {
const store = useStore()
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
"lint": "prettier -c --parser typescript \"{src,__tests__,e2e}/**/*.[jt]s?(x)\"",
"lint:fix": "yarn run lint --write",
+ "test:dts": "tsc -p ./test-dts/tsconfig.json",
"test:types": "tsc --build tsconfig.json",
"test:unit": "jest --coverage",
"dev": "yarn run unit --watchAll",
/**
* Creates a `useStore` function that retrieves the store instance
- * @param options
+ * @param options - options to define the store
*/
export function createStore<
Id extends string,
id: 'name',
state: () => ({ a: 'on' as 'on' | 'off', nested: { counter: 0 } }),
getters: {
- upper: state => state.a.toUpperCase(),
+ upper() {
+ return this.a.toUpperCase()
+ },
},
})
const store = useStore()
+// FIXME: this should not be there anymore
expectType<{ a: 'on' | 'off' }>(store.state)
-// expectType<number>(store.nested.counter)
+expectType<number>(store.nested.counter)
+expectType<'on' | 'off'>(store.a)
-// not yet @ts-expect-error
-// store.nonExistant
+// @ts-expect-error
+store.nonExistant
// @ts-expect-error
store.nonExistant.stuff
--- /dev/null
+{
+ "extends": "../tsconfig.json",
+ "compilerOptions": {
+ "noEmit": true,
+ "declaration": true,
+ "paths": {
+ "vue-router": ["../dist"]
+ },
+ "noImplicitReturns": false
+ },
+ "include": ["./"],
+ "exclude": ["../__tests__", "../src"]
+}
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
- "noImplicitReturns": true,
+ "noImplicitReturns": false,
"strict": true,
"isolatedModules": false,