Skip to content

Commit

Permalink
Fix more types
Browse files Browse the repository at this point in the history
  • Loading branch information
allanhortle committed Oct 17, 2023
1 parent 54de947 commit e0537ff
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/react-enty/src/EntityReducerFactory.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {ObjectSchema, Schema} from 'enty';
import {Schema} from 'enty';
import {State, Action} from './util/definitions';
import {REMOVED_ENTITY} from 'enty';
import RequestState from './data/RequestState';

export default function EntityReducerFactory(config: {schema?: Schema | ObjectSchema<any>}) {
export default function EntityReducerFactory(config: {schema?: Schema<any>}) {
return function EntityReducer(
previousState: State | null,
{type, payload, meta = {responseKey: '', name: 'unknown'}}: Action
Expand Down
2 changes: 1 addition & 1 deletion packages/react-enty/src/ProviderFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {State, Action, ProviderContextType} from './util/definitions';
import {Schema} from 'enty';

export type ProviderConfig = {
schema?: Schema;
schema?: Schema<any>;
results?: Array<{
responseKey: string;
payload: any;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-enty/src/RequestHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Hash from './util/Hash';
type RequestHookConfig = {
name: string;
requestAction: Function;
schema?: Schema;
schema?: Schema<any>;
};

type Config = {
Expand Down
17 changes: 11 additions & 6 deletions packages/react-enty/src/__tests__/EntityReducerFactory-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,25 @@ const baseState = {
responseCount: 0
}
};
type Listing = {
name: string;
fullnameId: string;
};

var author = new EntitySchema('author', {
id: (ii) => ii?.fullnameId,
shape: new ObjectSchema({})
});
type Subreddit = {
name: string;
fullnameId: string;
topListings: Array<Listing>;
};

var topListings = new EntitySchema('topListings', {
id: (ii) => ii?.fullnameId,
shape: new ObjectSchema({author})
shape: new ObjectSchema<Listing>({})
});

var subreddit = new EntitySchema('subreddit', {
id: (ii) => ii?.fullnameId,
shape: new ObjectSchema({
shape: new ObjectSchema<Subreddit>({
topListings: new ArraySchema(topListings)
})
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-enty/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"target": "es5",
"strict": true
},
"include": ["./src/**/*", "types/jest.d.ts"]
"include": ["./src/**/*", "types/jest.d.ts", "../enty/src/"]
}
8 changes: 4 additions & 4 deletions packages/react-enty/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3825,10 +3825,10 @@ entities@^2.0.0:
resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55"
integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==

enty@^3.0.0-alpha.0:
version "3.0.0-alpha.0"
resolved "https://registry.yarnpkg.com/enty/-/enty-3.0.0-alpha.0.tgz#6ce616e78710ef94a7230e3acd8ea0228b4d194a"
integrity sha512-CbaqeobK/vHqfbKJBzgtlEkysctDGdDTMD1BMqDieOMtotVDMmx7kKTTo2iy/Sdi9aOPkrihL6GfLc68XfZ4yA==
enty@^3.0.0-alpha.1:
version "3.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/enty/-/enty-3.0.0-alpha.1.tgz#48642c1ab1bac5d319b261928f5b1dcf9fb626cc"
integrity sha512-GgK+i4NkknIRB3SKPIUXKhZ6StV2LGxFLy/BHV3Hkoa6mzHSRAZkjZbotS9zv6EV179ZaM6mYQkyl/I+l3WSjA==

enzyme-matchers@^7.1.2:
version "7.1.2"
Expand Down

0 comments on commit e0537ff

Please sign in to comment.