Skip to content

Commit ec15a77

Browse files
committed
test(dts): fix
1 parent c85dc50 commit ec15a77

File tree

4 files changed

+26
-33
lines changed

4 files changed

+26
-33
lines changed

src/index.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
import { defineStore } from './store'
21
export {
32
setActiveReq,
43
setStateProvider,
54
getRootState,
65
createPinia,
76
} from './rootStore'
8-
9-
function createStore(options: Parameters<typeof defineStore>[0]) {
10-
console.warn(
11-
'[🍍]: "createStore" has been deprecated and will be removed on the sable release, use "defineStore" instead.'
12-
)
13-
return defineStore(options)
14-
}
15-
16-
export { StateTree, StoreGetter, Store } from './types'
17-
export { createStore, defineStore }
7+
export { defineStore } from './store'
8+
export { createStore } from './deprecated'

src/types.ts

-21
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,3 @@ export type GenericStore = Store<
111111
Record<string, Method>,
112112
Record<string, Method>
113113
>
114-
115-
export interface DevtoolHook {
116-
on(
117-
event: string,
118-
callback: (targetState: Record<string, StateTree>) => void
119-
): void
120-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
121-
emit(event: string, ...payload: any[]): void
122-
}
123-
124-
// add the __VUE_DEVTOOLS_GLOBAL_HOOK__ variable to the global namespace
125-
declare global {
126-
interface Window {
127-
__VUE_DEVTOOLS_GLOBAL_HOOK__?: DevtoolHook
128-
}
129-
namespace NodeJS {
130-
interface Global {
131-
__VUE_DEVTOOLS_GLOBAL_HOOK__?: DevtoolHook
132-
}
133-
}
134-
}

test-dts/deprecated.test-d.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { createStore, expectType } from './'
2+
3+
const useDeprecated = createStore({
4+
id: 'name',
5+
state: () => ({ a: 'on' as 'on' | 'off', nested: { counter: 0 } }),
6+
getters: {
7+
upper() {
8+
return this.a.toUpperCase()
9+
},
10+
},
11+
})
12+
13+
const deprecatedStore = useDeprecated()
14+
15+
expectType<{ a: 'on' | 'off' }>(deprecatedStore.state)
16+
expectType<number>(deprecatedStore.nested.counter)
17+
expectType<'on' | 'off'>(deprecatedStore.a)
18+
19+
// @ts-expect-error
20+
deprecatedStore.nonExistant
21+
22+
// @ts-expect-error
23+
deprecatedStore.nonExistant.stuff

test-dts/store.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const useStore = defineStore({
1010
},
1111
})
1212

13-
const store = useStore()
13+
let store = useStore()
1414

1515
// FIXME: this should not be there anymore
1616
expectType<{ a: 'on' | 'off' }>(store.state)

0 commit comments

Comments
 (0)