From: Eduardo San Martin Morote Date: Fri, 18 Feb 2022 22:06:40 +0000 (+0100) Subject: fix(types): exclude internal properties from store X-Git-Tag: @pinia/testing@0.0.10~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f8f944fcdd4411c2f84297786955c4c157fbeebe;p=thirdparty%2Fvuejs%2Fpinia.git fix(types): exclude internal properties from store Fix #1013 --- diff --git a/packages/pinia/api-extractor.json b/packages/pinia/api-extractor.json index d3486484..759c87e8 100644 --- a/packages/pinia/api-extractor.json +++ b/packages/pinia/api-extractor.json @@ -14,7 +14,7 @@ "dtsRollup": { "enabled": true, - "untrimmedFilePath": "./dist/.d.ts" + "publicTrimmedFilePath": "./dist/.d.ts" }, "tsdocMetadata": { diff --git a/packages/pinia/src/globalExtensions.ts b/packages/pinia/src/globalExtensions.ts index 432ff15d..9575fa3d 100644 --- a/packages/pinia/src/globalExtensions.ts +++ b/packages/pinia/src/globalExtensions.ts @@ -15,7 +15,7 @@ declare module 'vue/types/vue' { /** * Cache of stores instantiated by the current instance. Used by map - * helpers. + * helpers. Used internally by Pinia. * * @internal */ @@ -44,7 +44,7 @@ declare module '@vue/runtime-core' { /** * Cache of stores instantiated by the current instance. Used by devtools to - * list currently used stores. + * list currently used stores. Used internally by Pinia. * * @internal */ diff --git a/packages/pinia/src/mapHelpers.ts b/packages/pinia/src/mapHelpers.ts index 2b97ebdd..b69fc5ce 100644 --- a/packages/pinia/src/mapHelpers.ts +++ b/packages/pinia/src/mapHelpers.ts @@ -20,7 +20,7 @@ export interface MapStoresCustomization { } /** - * @internal + * For internal use **only**. */ export type _StoreObject = S extends StoreDefinition< infer Ids, @@ -48,7 +48,7 @@ export type _StoreObject = S extends StoreDefinition< : {} /** - * @internal + * For internal use **only**. */ export type _Spread = A extends [infer L, ...infer R] ? _StoreObject & _Spread @@ -120,7 +120,7 @@ export function mapStores( } /** - * @internal + * For internal use **only** */ export type _MapStateReturn< S extends StateTree, @@ -136,7 +136,7 @@ export type _MapStateReturn< } /** - * @internal + * For internal use **only** */ export type _MapStateObjectReturn< Id extends string, @@ -285,14 +285,14 @@ export function mapState< export const mapGetters = mapState /** - * @internal + * For internal use **only** */ export type _MapActionsReturn = { [key in keyof A]: A[key] } /** - * @internal + * For internal use **only** */ export type _MapActionsObjectReturn> = { [key in keyof T]: A[T[key]] @@ -407,7 +407,7 @@ export function mapActions< } /** - * @internal + * For internal use **only** */ export type _MapWritableStateReturn = { [key in keyof S]: { @@ -417,7 +417,7 @@ export type _MapWritableStateReturn = { } /** - * @internal + * For internal use **only** */ export type _MapWritableStateObjectReturn< S extends StateTree, diff --git a/packages/pinia/src/types.ts b/packages/pinia/src/types.ts index 78983cb0..5471281e 100644 --- a/packages/pinia/src/types.ts +++ b/packages/pinia/src/types.ts @@ -30,7 +30,7 @@ export function isPlainObject( /** * Recursive `Partial`. Used by {@link Store.$patch}. * - * @internal + * For internal use **only** */ export type _DeepPartial = { [K in keyof T]?: _DeepPartial } // type DeepReadonly = { readonly [P in keyof T]: DeepReadonly } @@ -172,7 +172,7 @@ export type _Awaited = T extends null | undefined /** * Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring * purposes. For internal use only. - * @internal + * For internal use **only** */ export interface _StoreOnActionListenerContext< Store, @@ -289,8 +289,6 @@ export interface StoreProperties { * Used by devtools plugin to retrieve properties added with plugins. Removed * in production. Can be used by the user to add property keys of the store * that should be displayed in devtools. - * - * @internal */ _customProperties: Set @@ -436,7 +434,7 @@ export interface _StoreWithState< /** * Generic type for a function that can infer arguments and return type * - * @internal + * For internal use **only** */ export type _Method = (...args: any[]) => any @@ -448,7 +446,7 @@ export type _Method = (...args: any[]) => any // in this type we forget about this because otherwise the type is recursive /** * Store augmented for actions. For internal usage only. - * @internal + * For internal use **only** */ export type _StoreWithActions = { [k in keyof A]: A[k] extends (...args: infer P) => infer R @@ -458,7 +456,7 @@ export type _StoreWithActions = { /** * Store augmented with getters. For internal usage only. - * @internal + * For internal use **only** */ export type _StoreWithGetters = { readonly [k in keyof G]: G[k] extends (...args: any[]) => infer R @@ -542,7 +540,7 @@ export interface PiniaCustomStateProperties {} /** * Type of an object of Getters that infers the argument. For internal usage only. - * @internal + * For internal use **only** */ export type _GettersTree = Record< string, @@ -552,13 +550,13 @@ export type _GettersTree = Record< /** * Type of an object of Actions. For internal usage only. - * @internal + * For internal use **only** */ export type _ActionsTree = Record /** * Type that enables refactoring through IDE. - * @internal + * For internal use **only** */ export type _ExtractStateFromSetupStore_Keys = keyof { [K in keyof SS as SS[K] extends _Method | ComputedRef ? never : K]: any @@ -566,7 +564,7 @@ export type _ExtractStateFromSetupStore_Keys = keyof { /** * Type that enables refactoring through IDE. - * @internal + * For internal use **only** */ export type _ExtractActionsFromSetupStore_Keys = keyof { [K in keyof SS as SS[K] extends _Method ? K : never]: any @@ -574,7 +572,7 @@ export type _ExtractActionsFromSetupStore_Keys = keyof { /** * Type that enables refactoring through IDE. - * @internal + * For internal use **only** */ export type _ExtractGettersFromSetupStore_Keys = keyof { [K in keyof SS as SS[K] extends ComputedRef ? K : never]: any @@ -582,12 +580,12 @@ export type _ExtractGettersFromSetupStore_Keys = keyof { /** * Type that enables refactoring through IDE. - * @internal + * For internal use **only** */ export type _UnwrapAll = { [K in keyof SS]: UnwrapRef } /** - * @internal + * For internal use **only** */ export type _ExtractStateFromSetupStore = SS extends undefined | void ? {} @@ -596,7 +594,7 @@ export type _ExtractStateFromSetupStore = SS extends undefined | void : never /** - * @internal + * For internal use **only** */ export type _ExtractActionsFromSetupStore = SS extends undefined | void ? {} @@ -605,7 +603,7 @@ export type _ExtractActionsFromSetupStore = SS extends undefined | void : never /** - * @internal + * For internal use **only** */ export type _ExtractGettersFromSetupStore = SS extends undefined | void ? {}