Skip to content

Commit

Permalink
fix(types): implemented a workaround to be TS 4.9.x compatible (#1818)
Browse files Browse the repository at this point in the history
  • Loading branch information
jxn-30 authored Nov 21, 2022
1 parent 3e4e63c commit c42a54c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/pinia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
],
"license": "MIT",
"devDependencies": {
"@microsoft/api-extractor": "7.28.6",
"@microsoft/api-extractor": "7.33.6",
"@vue/test-utils": "^2.2.3"
},
"dependencies": {
Expand Down
18 changes: 12 additions & 6 deletions packages/pinia/src/mapHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ export type _StoreObject<S> = S extends StoreDefinition<
infer Actions
>
? {
[Id in `${Ids}${MapStoresCustomization extends Record<'suffix', string>
? MapStoresCustomization['suffix']
[Id in `${Ids}${MapStoresCustomization extends Record<
'suffix',
infer Suffix extends string
>
? Suffix
: 'Store'}`]: () => Store<
Id extends `${infer RealId}${MapStoresCustomization extends Record<
'suffix',
string
infer Suffix extends string
>
? MapStoresCustomization['suffix']
? Suffix
: 'Store'}`
? RealId
: string,
Expand Down Expand Up @@ -64,8 +67,11 @@ export let mapStoreSuffix = 'Store'
* @param suffix - new suffix
*/
export function setMapStoreSuffix(
suffix: MapStoresCustomization extends Record<'suffix', string>
? MapStoresCustomization['suffix']
suffix: MapStoresCustomization extends Record<
'suffix',
infer Suffix extends string
>
? Suffix
: string // could be 'Store' but that would be annoying for JS
): void {
mapStoreSuffix = suffix
Expand Down
67 changes: 26 additions & 41 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c42a54c

Please sign in to comment.