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

[enhance] Improve normalizr type expressiveness #154

Merged
merged 2 commits into from
Oct 9, 2019
Merged

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Oct 9, 2019

Motivation

Solution

  • Fake nominal typing for schema types (since they have pretty similar signatures).
    • future: should change to tracking return value of normalize as that can encode proper typings. We can use the schema provided and build on that to pretty convincingly manifest the algo. This can replace the giant ResultType and Denormalized block.
  • Add missing readonly member schema
  • Include Array in Schema and SchemaList def
  • Add greedy resolution to Entity in ResultType and Denormalized generics.
    • This means if we only have SchemaDetail or SchemaList it will resolve to T and T[] respectively. While we don't actually know this - it enables a broad base class definition for our REST shapes. In the future a better solution is to simply make those shapes a mixin and encourage more often writing own shapes from scratch.

Open questions

Should we just try to fix the normalize/denormalize algo now?

schemaAttribute?: string | SchemaFunction,
);
export class Array<S extends Schema = Schema<any>> {
private _identifier: 'Array';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faking nominal typing.

@ntucker ntucker merged commit cdba268 into master Oct 9, 2019
@ntucker ntucker deleted the normal-types branch October 9, 2019 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants