Skip to content

Commit

Permalink
fix(types): more un-exported types
Browse files Browse the repository at this point in the history
  • Loading branch information
UberMouse committed Jul 16, 2022
1 parent 6224030 commit 720fd4a
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 26 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export {
type Routing404Event,
type StyledLink,
type ArgumentsForRoute,
type Options,
type Params,
type Query,
type Meta,
type SharedMeta,
type RouteArgumentFunctions,
buildCreateRoute,
matchRoute,
} from "./routing";
Expand Down
32 changes: 27 additions & 5 deletions src/routing/createRoute/createRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type EmptyRouteArguments<TParams, TQuery> = IsEmptyObject<
: false
: false;

/**
* @public
*/
export type RouteArgumentFunctions<
TReturn,
TParams,
Expand Down Expand Up @@ -148,7 +151,10 @@ export type AnyRoute = {
querySchema?: Z.ZodObject<any>;
};

type Options<
/**
* @public
*/
export type Options<
TParamsSchema extends Z.ZodObject<any>,
TQuerySchema extends Z.ZodObject<any>,
TMetaSchema
Expand All @@ -158,7 +164,10 @@ type Options<
meta?: TMetaSchema;
};

type SharedMeta = {
/**
* @public
*/
export type SharedMeta = {
/**
* Suppresses this routing change event from being picked up by react-router
*/
Expand All @@ -173,9 +182,22 @@ type SharedMeta = {
replace?: boolean;
};

type Params<T> = T extends { params: infer TParams } ? TParams : undefined;
type Query<T> = T extends { query: infer TQuery } ? TQuery : undefined;
type Meta<T> = T extends { meta: infer TMeta } ? TMeta : undefined;
/**
* @public
*/
export type Params<T> = T extends { params: infer TParams }
? TParams
: undefined;

/**
* @public
*/
export type Query<T> = T extends { query: infer TQuery } ? TQuery : undefined;

/**
* @public
*/
export type Meta<T> = T extends { meta: infer TMeta } ? TMeta : undefined;

/**
* @public
Expand Down
6 changes: 6 additions & 0 deletions src/routing/createRoute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ export {
type RouteParams,
type RouteMeta,
type ArgumentsForRoute,
type Options,
type Params,
type Query,
type Meta,
type SharedMeta,
type RouteArgumentFunctions,
} from "./createRoute";
6 changes: 6 additions & 0 deletions src/routing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export {
type RouteMeta,
type RouteArguments,
type ArgumentsForRoute,
type Options,
type Params,
type Query,
type Meta,
type SharedMeta,
type RouteArgumentFunctions,
buildCreateRoute,
} from "./createRoute";
export { joinRoutes } from "./joinRoutes";
Expand Down
17 changes: 13 additions & 4 deletions src/slots/slots.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
enum SlotType {
/**
* @public
*/
export enum SlotType {
SingleSlot,
MultiSlot,
}

type SingleSlot<T> = {
/**
* @public
*/
export type SingleSlot<T> = {
type: SlotType.SingleSlot;
name: T;
getId(): string;
};

type MultiSlot<T> = {
/**
* @public
*/
export type MultiSlot<T> = {
type: SlotType.MultiSlot;
name: T;
getId(id: string): string;
Expand Down Expand Up @@ -43,7 +52,7 @@ export function multiSlot<T extends string>(name: T): MultiSlot<T> {
}

/**
* @internal
* @public
*/
export type GetSlotNames<TSlots extends readonly Slot[]> =
TSlots[number]["name"];
76 changes: 59 additions & 17 deletions xstate-tree.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ export function buildXStateTreeMachine<TContext, TEvent extends EventObject, TTy
// @public (undocumented)
export const genericSlotsTestingDummy: any;

// Warning: (ae-internal-missing-underscore) The name "GetSlotNames" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
// @public (undocumented)
export type GetSlotNames<TSlots extends readonly Slot[]> = TSlots[number]["name"];

// @public
Expand Down Expand Up @@ -180,21 +178,48 @@ export function loggingMetaOptions<TEvents extends EventObject, TContext>(ignore
// @public (undocumented)
export function matchRoute<TRoutes extends Route<any, any, any, any>[]>(routes: TRoutes, basePath: string, path: string, search: string): Return;

// Warning: (ae-forgotten-export) The symbol "MultiSlot" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type Meta<T> = T extends {
meta: infer TMeta;
} ? TMeta : undefined;

// @public (undocumented)
export type MultiSlot<T> = {
type: SlotType.MultiSlot;
name: T;
getId(id: string): string;
};

// @public (undocumented)
export function multiSlot<T extends string>(name: T): MultiSlot<T>;

// @public (undocumented)
export function onBroadcast(handler: (event: GlobalEvents) => void): () => void;

// @public (undocumented)
export type Options<TParamsSchema extends Z.ZodObject<any>, TQuerySchema extends Z.ZodObject<any>, TMetaSchema> = {
params?: TParamsSchema;
query?: TQuerySchema;
meta?: TMetaSchema;
};

// @public (undocumented)
export type Params<T> = T extends {
params: infer TParams;
} ? TParams : undefined;

// @public
export type PickEvent<T extends Extract<GlobalEvents, {
type: string;
}>["type"]> = Extract<GlobalEvents, {
type: T;
}>;

// @public (undocumented)
export type Query<T> = T extends {
query: infer TQuery;
} ? TQuery : undefined;

// @public (undocumented)
export type Route<TParams, TQuery, TEvent, TMeta> = {
matches: (url: string, search: string) => ({
Expand All @@ -215,6 +240,13 @@ export type Route<TParams, TQuery, TEvent, TMeta> = {
querySchema?: Z.ZodObject<any>;
};

// Warning: (ae-forgotten-export) The symbol "IsEmptyObject" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "EmptyRouteArguments" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "MakeEmptyObjectPropertiesOptional" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type RouteArgumentFunctions<TReturn, TParams, TQuery, TMeta, TArgs = RouteArguments<TParams, TQuery, TMeta>> = IsEmptyObject<TArgs> extends true ? () => TReturn : keyof TArgs extends "meta" ? (args?: TArgs) => TReturn : EmptyRouteArguments<TParams, TQuery> extends true ? (args?: Partial<TArgs>) => TReturn : (args: MakeEmptyObjectPropertiesOptional<TArgs>) => TReturn;

// @public (undocumented)
export type RouteArguments<TParams, TQuery, TMeta> = TParams extends undefined ? TQuery extends undefined ? TMeta extends undefined ? {} : {
meta?: TMeta;
Expand Down Expand Up @@ -258,8 +290,20 @@ export type RoutingEvent<T> = T extends Route<infer TParams, infer TQuery, infer
meta: TMeta;
} : never;

// Warning: (ae-forgotten-export) The symbol "SingleSlot" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type SharedMeta = {
doNotNotifyReactRouter?: boolean;
indexEvent?: boolean;
replace?: boolean;
};

// @public (undocumented)
export type SingleSlot<T> = {
type: SlotType.SingleSlot;
name: T;
getId(): string;
};

// @public (undocumented)
export function singleSlot<T extends string>(name: T): SingleSlot<T>;

Expand All @@ -278,6 +322,14 @@ context: unknown;
context: unknown;
}, any, any, any>;

// @public (undocumented)
export enum SlotType {
// (undocumented)
MultiSlot = 1,
// (undocumented)
SingleSlot = 0
}

// @public (undocumented)
export type StyledLink<TStyleProps = {}> = <TRoute extends AnyRoute>(props: LinkProps<TRoute> & TStyleProps) => JSX.Element;

Expand Down Expand Up @@ -309,16 +361,6 @@ export type XstateTreeMachineStateSchema<TContext, TEvent extends EventObject, T
meta: XStateTreeMachineMeta<TContext, TEvent, TTypestate, TSelectors, TActions, TInterpreter, TSlots>;
};

// Warnings were encountered during analysis:
//
// src/routing/createRoute/createRoute.ts:231:5 - (ae-forgotten-export) The symbol "Options" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:231:5 - (ae-forgotten-export) The symbol "Params" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:231:5 - (ae-forgotten-export) The symbol "Query" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:231:5 - (ae-forgotten-export) The symbol "Meta" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:231:5 - (ae-forgotten-export) The symbol "SharedMeta" needs to be exported by the entry point index.d.ts
// src/routing/createRoute/createRoute.ts:254:37 - (ae-forgotten-export) The symbol "RouteArgumentFunctions" needs to be exported by the entry point index.d.ts
// src/types.ts:76:3 - (ae-incompatible-release-tags) The symbol "slots" is marked as @public, but its signature references "GetSlotNames" which is marked as @internal

// (No @packageDocumentation comment for this package)

```

0 comments on commit 720fd4a

Please sign in to comment.