[@types/redux-orm] correct throughFields property on many() object parameter (#37326)

fixes #37293
This commit is contained in:
Tomasz Zabłocki 2019-08-03 01:03:36 +02:00 committed by Jesse Trinity
parent db59d133e5
commit a24d647874
2 changed files with 12 additions and 10 deletions

View File

@ -8,6 +8,7 @@ export interface AttributeOpts {
export class Attribute extends Field {
constructor(opts?: AttributeOpts);
['type']: 'attr';
}
export interface AttributeWithDefault extends Attribute {
@ -18,10 +19,7 @@ export interface RelationalFieldOpts {
to: string;
relatedName?: string;
through?: string;
throughFields?: {
to: string;
from: string;
};
throughFields?: [string, string];
as?: string;
}
@ -30,14 +28,18 @@ export class RelationalField extends Field {
constructor(opts: RelationalFieldOpts);
}
export class OneToOne extends RelationalField {}
export class OneToOne extends RelationalField {
['type']: 'oneToOne';
}
export class ForeignKey extends RelationalField {
readonly index: true;
['type']: 'fk';
}
export class ManyToMany extends RelationalField {
readonly index: false;
['type']: 'many';
}
export interface AttrCreator {

View File

@ -44,6 +44,7 @@ class Book extends Model<typeof Book, BookFields> {
static options = {
idAttribute: 'title' as const
};
static reducer(action: RootAction, Book: ModelType<Book>) {
switch (action.type) {
case 'CREATE_BOOK':
@ -380,11 +381,7 @@ const sessionFixture = () => {
type TestSelector = (state: RootState) => Ref<Book>;
const selector0 = createOrmSelector(
orm,
s => s.db,
session => session.Book.first()!.ref
) as TestSelector;
const selector0 = createOrmSelector(orm, s => s.db, session => session.Book.first()!.ref) as TestSelector;
const selector1 = createOrmSelector(
orm,
@ -504,3 +501,6 @@ const sessionFixture = () => {
Book.create({ title: 'foo', publisher: 'error' }); // $ExpectError
Book.create({ title: 'foo', publisher, coverArt: 'bar', authors: [3, author] }); // $ExpectError
})();
// redux-orm-types#18
(() => many({ to: 'Bar', relatedName: 'foos', through: 'FooBar', throughFields: ['foo', 'bar'] }))();