Skip to content

Commit f8f944f

Browse files
committed
fix(types): exclude internal properties from store
Fix #1013
1 parent e5f1afd commit f8f944f

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

packages/pinia/api-extractor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"dtsRollup": {
1616
"enabled": true,
17-
"untrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
17+
"publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
1818
},
1919

2020
"tsdocMetadata": {

packages/pinia/src/globalExtensions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare module 'vue/types/vue' {
1515

1616
/**
1717
* Cache of stores instantiated by the current instance. Used by map
18-
* helpers.
18+
* helpers. Used internally by Pinia.
1919
*
2020
* @internal
2121
*/
@@ -44,7 +44,7 @@ declare module '@vue/runtime-core' {
4444

4545
/**
4646
* Cache of stores instantiated by the current instance. Used by devtools to
47-
* list currently used stores.
47+
* list currently used stores. Used internally by Pinia.
4848
*
4949
* @internal
5050
*/

packages/pinia/src/mapHelpers.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface MapStoresCustomization {
2020
}
2121

2222
/**
23-
* @internal
23+
* For internal use **only**.
2424
*/
2525
export type _StoreObject<S> = S extends StoreDefinition<
2626
infer Ids,
@@ -48,7 +48,7 @@ export type _StoreObject<S> = S extends StoreDefinition<
4848
: {}
4949

5050
/**
51-
* @internal
51+
* For internal use **only**.
5252
*/
5353
export type _Spread<A extends readonly any[]> = A extends [infer L, ...infer R]
5454
? _StoreObject<L> & _Spread<R>
@@ -120,7 +120,7 @@ export function mapStores<Stores extends any[]>(
120120
}
121121

122122
/**
123-
* @internal
123+
* For internal use **only**
124124
*/
125125
export type _MapStateReturn<
126126
S extends StateTree,
@@ -136,7 +136,7 @@ export type _MapStateReturn<
136136
}
137137

138138
/**
139-
* @internal
139+
* For internal use **only**
140140
*/
141141
export type _MapStateObjectReturn<
142142
Id extends string,
@@ -285,14 +285,14 @@ export function mapState<
285285
export const mapGetters = mapState
286286

287287
/**
288-
* @internal
288+
* For internal use **only**
289289
*/
290290
export type _MapActionsReturn<A> = {
291291
[key in keyof A]: A[key]
292292
}
293293

294294
/**
295-
* @internal
295+
* For internal use **only**
296296
*/
297297
export type _MapActionsObjectReturn<A, T extends Record<string, keyof A>> = {
298298
[key in keyof T]: A[T[key]]
@@ -407,7 +407,7 @@ export function mapActions<
407407
}
408408

409409
/**
410-
* @internal
410+
* For internal use **only**
411411
*/
412412
export type _MapWritableStateReturn<S extends StateTree> = {
413413
[key in keyof S]: {
@@ -417,7 +417,7 @@ export type _MapWritableStateReturn<S extends StateTree> = {
417417
}
418418

419419
/**
420-
* @internal
420+
* For internal use **only**
421421
*/
422422
export type _MapWritableStateObjectReturn<
423423
S extends StateTree,

packages/pinia/src/types.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function isPlainObject(
3030
/**
3131
* Recursive `Partial<T>`. Used by {@link Store.$patch}.
3232
*
33-
* @internal
33+
* For internal use **only**
3434
*/
3535
export type _DeepPartial<T> = { [K in keyof T]?: _DeepPartial<T[K]> }
3636
// type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> }
@@ -172,7 +172,7 @@ export type _Awaited<T> = T extends null | undefined
172172
/**
173173
* Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring
174174
* purposes. For internal use only.
175-
* @internal
175+
* For internal use **only**
176176
*/
177177
export interface _StoreOnActionListenerContext<
178178
Store,
@@ -289,8 +289,6 @@ export interface StoreProperties<Id extends string> {
289289
* Used by devtools plugin to retrieve properties added with plugins. Removed
290290
* in production. Can be used by the user to add property keys of the store
291291
* that should be displayed in devtools.
292-
*
293-
* @internal
294292
*/
295293
_customProperties: Set<string>
296294

@@ -436,7 +434,7 @@ export interface _StoreWithState<
436434
/**
437435
* Generic type for a function that can infer arguments and return type
438436
*
439-
* @internal
437+
* For internal use **only**
440438
*/
441439
export type _Method = (...args: any[]) => any
442440

@@ -448,7 +446,7 @@ export type _Method = (...args: any[]) => any
448446
// in this type we forget about this because otherwise the type is recursive
449447
/**
450448
* Store augmented for actions. For internal usage only.
451-
* @internal
449+
* For internal use **only**
452450
*/
453451
export type _StoreWithActions<A> = {
454452
[k in keyof A]: A[k] extends (...args: infer P) => infer R
@@ -458,7 +456,7 @@ export type _StoreWithActions<A> = {
458456

459457
/**
460458
* Store augmented with getters. For internal usage only.
461-
* @internal
459+
* For internal use **only**
462460
*/
463461
export type _StoreWithGetters<G> = {
464462
readonly [k in keyof G]: G[k] extends (...args: any[]) => infer R
@@ -542,7 +540,7 @@ export interface PiniaCustomStateProperties<S extends StateTree = StateTree> {}
542540

543541
/**
544542
* Type of an object of Getters that infers the argument. For internal usage only.
545-
* @internal
543+
* For internal use **only**
546544
*/
547545
export type _GettersTree<S extends StateTree> = Record<
548546
string,
@@ -552,42 +550,42 @@ export type _GettersTree<S extends StateTree> = Record<
552550

553551
/**
554552
* Type of an object of Actions. For internal usage only.
555-
* @internal
553+
* For internal use **only**
556554
*/
557555
export type _ActionsTree = Record<string, _Method>
558556

559557
/**
560558
* Type that enables refactoring through IDE.
561-
* @internal
559+
* For internal use **only**
562560
*/
563561
export type _ExtractStateFromSetupStore_Keys<SS> = keyof {
564562
[K in keyof SS as SS[K] extends _Method | ComputedRef ? never : K]: any
565563
}
566564

567565
/**
568566
* Type that enables refactoring through IDE.
569-
* @internal
567+
* For internal use **only**
570568
*/
571569
export type _ExtractActionsFromSetupStore_Keys<SS> = keyof {
572570
[K in keyof SS as SS[K] extends _Method ? K : never]: any
573571
}
574572

575573
/**
576574
* Type that enables refactoring through IDE.
577-
* @internal
575+
* For internal use **only**
578576
*/
579577
export type _ExtractGettersFromSetupStore_Keys<SS> = keyof {
580578
[K in keyof SS as SS[K] extends ComputedRef ? K : never]: any
581579
}
582580

583581
/**
584582
* Type that enables refactoring through IDE.
585-
* @internal
583+
* For internal use **only**
586584
*/
587585
export type _UnwrapAll<SS> = { [K in keyof SS]: UnwrapRef<SS[K]> }
588586

589587
/**
590-
* @internal
588+
* For internal use **only**
591589
*/
592590
export type _ExtractStateFromSetupStore<SS> = SS extends undefined | void
593591
? {}
@@ -596,7 +594,7 @@ export type _ExtractStateFromSetupStore<SS> = SS extends undefined | void
596594
: never
597595

598596
/**
599-
* @internal
597+
* For internal use **only**
600598
*/
601599
export type _ExtractActionsFromSetupStore<SS> = SS extends undefined | void
602600
? {}
@@ -605,7 +603,7 @@ export type _ExtractActionsFromSetupStore<SS> = SS extends undefined | void
605603
: never
606604

607605
/**
608-
* @internal
606+
* For internal use **only**
609607
*/
610608
export type _ExtractGettersFromSetupStore<SS> = SS extends undefined | void
611609
? {}

0 commit comments

Comments
 (0)