Skip to content

Commit

Permalink
union type for patterns (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
lolopinto authored Apr 13, 2024
1 parent 29a78dc commit 4adcfb9
Show file tree
Hide file tree
Showing 43 changed files with 321 additions and 150 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/simple/src/ent/generated/holiday_base.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/simple/src/ent/generated/hours_of_operation_base.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/simple/src/ent/generated/loaders.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/simple/src/ent/generated/mixins/contact_info_base.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/simple/src/ent/generated/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/simple/src/ent/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
export * from "./generated/loaders";
export * from "./generated/loadAny";
export * from "./mixins/contact_info";
export * from "./mixins/day_of_week";
export * from "./mixins/feedback";
export * from "./mixins/with_day_of_week";
export * from "./generated/address_base";
export * from "./generated/auth_code_base";
export * from "./generated/comment_base";
Expand Down
38 changes: 0 additions & 38 deletions examples/simple/src/ent/mixins/day_of_week.ts

This file was deleted.

40 changes: 40 additions & 0 deletions examples/simple/src/ent/mixins/with_day_of_week.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright whaa whaa
* Generated by github.com/lolopinto/ent/ent, DO NOT EDIT.
*/

import {
IWithDayOfWeekBase,
WithDayOfWeekBaseMixin,
} from "../generated/mixins/with_day_of_week_base";
import { ExampleViewer as ExampleViewerAlias } from "../../viewer/viewer";

export interface IWithDayOfWeek<
TViewer extends ExampleViewerAlias = ExampleViewerAlias,
> extends IWithDayOfWeekBase<TViewer> {
isWithDayOfWeek(): boolean;

// add custom fields
}

type Constructor<T extends IWithDayOfWeek = IWithDayOfWeek> = new (
...args: any[]
) => T;

export function isWithDayOfWeek(ent: unknown): ent is IWithDayOfWeek {
const o = ent as IWithDayOfWeek;
return (o.isWithDayOfWeek && o.isWithDayOfWeek()) ?? false;
}

export function WithDayOfWeekMixin<T extends Constructor>(BaseClass: T) {
return class WithDayOfWeekMixin
extends WithDayOfWeekBaseMixin(BaseClass)
implements IWithDayOfWeek
{
isWithDayOfWeek() {
return true;
}

// add custom fields implementation
};
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4adcfb9

Please sign in to comment.