Skip to content

Commit b01f50b

Browse files
wadetandyrichmolj
authored andcommitted
Move the Omit utility type to a .ts file (#56)
* Move the Omit utility type to a .ts file Ran into an issue with a consuming application that had a config that tried to validate the types of dependent libraries. In this case the types were failing because things from `types/index.d.ts` weren't available externally. Moving them to actual module with exports fixes it. Shouldn't be necessary in most cases, but fixes the problems for a few edge-case configurations. * Add build
1 parent 011bad6 commit b01f50b

File tree

17 files changed

+106
-9
lines changed

17 files changed

+106
-9
lines changed

lib-esm/model.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Scope, WhereClause, SortScope, FieldScope, StatsScope, IncludeScope } f
55
import { JsonapiTypeRegistry } from "./jsonapi-type-registry";
66
import { ILogger } from "./logger";
77
import { MiddlewareStack, BeforeFilter, AfterFilter } from "./middleware-stack";
8+
import { Omit } from "./util/omit";
89
import { JsonapiResource, JsonapiResponseDoc, JsonapiResourceIdentifier } from "./jsonapi-spec";
910
import { IncludeScopeHash } from "./util/include-directive";
1011
export interface ModelConfiguration {

lib-esm/model.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib-esm/model.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib-esm/util/dirty-check.d.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,40 @@ declare class DirtyChecker<T extends JSORMBase> {
3737
resetRelationTracking: never;
3838
} & {
3939
[x: string]: never;
40-
})[keyof T]]?: Omit<T, "destroy" | "fromJsonapi" | "id" | "temp_id" | "relationships" | "klass" | "isType" | "isPersisted" | "isMarkedForDestruction" | "isMarkedForDisassociation" | "attributes" | "typedAttributes" | "relationship" | "assignAttributes" | "setMeta" | "relationshipResourceIdentifiers" | "resourceIdentifier" | "errors" | "hasError" | "clearErrors" | "isDirty" | "changes" | "hasDirtyRelation" | "dup" | "save" | "resetRelationTracking">[P][] | undefined;
40+
})[keyof T]]?: {
41+
[P in ({
42+
[P in keyof T]: P;
43+
} & {
44+
destroy: never;
45+
fromJsonapi: never;
46+
id: never;
47+
temp_id: never;
48+
relationships: never;
49+
klass: never;
50+
isType: never;
51+
isPersisted: never;
52+
isMarkedForDestruction: never;
53+
isMarkedForDisassociation: never;
54+
attributes: never;
55+
typedAttributes: never;
56+
relationship: never;
57+
assignAttributes: never;
58+
setMeta: never;
59+
relationshipResourceIdentifiers: never;
60+
resourceIdentifier: never;
61+
errors: never;
62+
hasError: never;
63+
clearErrors: never;
64+
isDirty: never;
65+
changes: never;
66+
hasDirtyRelation: never;
67+
dup: never;
68+
save: never;
69+
resetRelationTracking: never;
70+
} & {
71+
[x: string]: never;
72+
})[keyof T]]: T[P];
73+
}[P][] | undefined;
4174
} & Partial<Record<"id" | "temp_id", string[]>>;
4275
private _isUnpersisted();
4376
private _hasDirtyAttributes();

lib-esm/util/omit.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export declare type Diff<T extends string, U extends string> = ({
2+
[P in T]: P;
3+
} & {
4+
[P in U]: never;
5+
} & {
6+
[x: string]: never;
7+
})[T];
8+
export declare type Omit<T, K extends keyof T> = {
9+
[P in Diff<keyof T, K>]: T[P];
10+
};

lib-esm/util/omit.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib-esm/util/omit.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/model.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Scope, WhereClause, SortScope, FieldScope, StatsScope, IncludeScope } f
55
import { JsonapiTypeRegistry } from "./jsonapi-type-registry";
66
import { ILogger } from "./logger";
77
import { MiddlewareStack, BeforeFilter, AfterFilter } from "./middleware-stack";
8+
import { Omit } from "./util/omit";
89
import { JsonapiResource, JsonapiResponseDoc, JsonapiResourceIdentifier } from "./jsonapi-spec";
910
import { IncludeScopeHash } from "./util/include-directive";
1011
export interface ModelConfiguration {

lib/model.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/model.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)