Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Refactor ts declaration for context in luigi-client #3418

Open
JohannesDoberer opened this issue Aug 30, 2023 · 3 comments
Open

Refactor ts declaration for context in luigi-client #3418

JohannesDoberer opened this issue Aug 30, 2023 · 3 comments
Assignees
Labels
3.0 breaking Breaking change

Comments

@JohannesDoberer
Copy link
Contributor

Currently we have a context ts declaration where everything is stored.
It makes more sense to split it up like:

export declare interface Context{
nodeParams?: NodeParams;
  pathParams?: PathParams;
...
}
export declare interface MetaContext{
internal?: {
    userSettings?: getUserSettings;
  };
...
}

Also update client-support-angular lib.

@JohannesDoberer
Copy link
Contributor Author

JohannesDoberer commented Jun 3, 2024

After discussion with PO the interfaces should look like this:

export declare interface Context {
   parentNavigationContext?: string[];
  [key: string]: any;
}

export declare interface InternalContext {
  authData?: AuthData;
  context?: Context;
  internal?: {
    userSettings?: getUserSettings;
  };
  nodeParams?: NodeParams;
  pathParams?: PathParams;
  anchor?: string;
}

That means, internally where we have previously developed against Context, then use InternalContext
AND: leave public interface functions on Context, e.g. addInitListener, addContextListener, getEventData, getContext

@walmazacn
Copy link
Contributor

walmazacn commented Jun 5, 2024

I did some tests for case when you expect original 'Context' ('InternalContext' after changes), but new 'Context' is provided. As long as you try to get a value from not existing property you will get undefined - like here:
currentContext.internal

But in case you want to get some nested property then "Uncaught TypeError" will occur. Even if index signature is added to new 'Context' interface ("[key: string]: any") - like here:
currentContext.internal.userSettings

That's why we may think of introducing separate contexts as a breaking change

@walmazacn
Copy link
Contributor

Btw, why do we extend internal property with non existing props for current context in 'lifecycleManager'?

  • this.currentContext.internal.isNavigateBack
  • this.currentContext.internal.activeFeatureToggleList
  • this.currentContext.internal.clientPermissions
  • this.currentContext.internal.anchor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 breaking Breaking change
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants