Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't use extended StateDeclaration as a generic to StateObject #990

Open
jpike88 opened this issue May 28, 2024 · 0 comments
Open

Can't use extended StateDeclaration as a generic to StateObject #990

jpike88 opened this issue May 28, 2024 · 0 comments

Comments

@jpike88
Copy link
Contributor

jpike88 commented May 28, 2024

Why are StateObject and StateDeclaration so decoupled? Wouldn't it make sense for StateObject to have StateDeclaration as a generic, so I can cast types properly?

example:


type RouteDefinition = Readonly<
	Ng2StateDeclaration & {
		menuContent?: {
			component: new (..._: any[]) => {};
		};
		data?: {
			title: string;
			presentationType?: string;
			tabs?: {
				label: string;
				value: string;
				component: new (..._: any[]) => {};
				data?: {
					title: string;
				};
				visible?: () => boolean;
				permissionsRequired?: PermissionKey[];
				params?: {
					[s: string]: any;
				};
			}[];
		};
		squash?: boolean;
		permissionKey?: PermissionKey;
		visible?: () => boolean;
		url?: string;
		resolve?: any;
		params?: { [s: string]: any };
	}
>;

The below errors because RouteDefinition isn't compatible with StateObject, which I understand... but that's where I get stuck.

const requiresPermissionCriteria: HookMatchCriteria = {
		to: (state: RouteDefinition) => {
			targetState = state.name;
			permissionKey = state.data?.permissionKey;
			return state.data?.permissionKey;
		},
	};
@jpike88 jpike88 changed the title Typing weitrdness Can't use extended StateDeclaration as a generic to StateObject May 28, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant