Code Monkey home page Code Monkey logo

redux-orm-types's People

Contributors

dependabot[bot] avatar tomasz-zablocki avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

redux-orm-types's Issues

Adding stateSelector to ORMOpts Type

Is it possible we can add stateSelector to ORMOpts? Even if it is of any type, this will stop the compiler from complaining.
Currently, when we add stateSelector while initializing a new ORM object, below is what the compiler complains.

Argument of type '{ stateSelector: (state: any) => any; }' is not assignable to parameter of type 'ORMOpts'.

To produce this, create an ORM instance on a Typescript project with a stateSelector as below.

const orm = new ORM({
    stateSelector: state => state.orm
});

Call selectors with passing arguments explicitly

Hi @tomasz-zablocki ,
For @types/redux-orm version 0.13.6. How to use selectors with passing an argument. In the example listed at
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/redux-orm/redux-orm-tests.ts . All the filtering of data seems to be done from the parameters which are a part of the state.

How do i create a selector by explicitly passing an argument to it ?

The selector that i am trying is posted here :
redux-orm/redux-orm#328

Thanks .

Entire QuerySet API incorrectly exposed by ModelType

ModelType should only expose methods from sharedMethod array:

QuerySet.sharedMethods = [
    'count',
    'at',
    'all',
    'last',
    'first',
    'filter',
    'exclude',
    'orderBy',
    'update',
    'delete',
];

toRefArray and toModelArray are accessible thru QS only

Refresh of DefinitelyTyped

Tomasz,

Forgive me if I got this wrong, but it appears as though the mirror of this repo under DefinitelyTyped is stale. I tried including it in my project via DefinitelyTyped and noticed that ModelFields is outdated and resulted in compile errors.

New variant....
export type ModelFields = M['__fields'];

Stale in
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/redux-orm/Model.d.ts

Fixed in
https://github.com/tomasz-zablocki/redux-orm-types/blob/master/types/redux-orm/Model.d.ts

I spent a lot of time trying to fix it myself before realizing that you already had a fix in place. Learned a lot along the way. Writing declaration files is a tough business, thanks for all your hard work!

How to migrate from version 0.9

Hi Tomasz,

Can you please write a guide how to migrate from old typescript definitions?

I tried but it was not something simple.

Types appear to be broken as of redux-orm v0.14.0

See this issue here for a summary of what I am hitting: redux-orm/redux-orm#331

Basically PR #257 in the redux-orm repo introduced the idea of a stateSelector as an option to the ORM constructor + additional breaking changes to the createSelector api. These type definitions then fell behind.

It seems like a relatively simple fix, but I just downloaded this library today to play with it (the core concept is amazing), and so am not totally familiar with what the change would require.

Model instance fields not readable from model instance methods

The fields of a model are not available to methods defined on that model.

For example, in the following snippet, reading the title field from an instance method reports a TypeScript error:

interface BookFields {
  title: string
}

class Book extends Model<typeof Book, BookFields> {
  ...

  getTitle() {
    // Property 'title' does not exist on type 'Book'. ts(2339) 
    return this.title;
  }
}

Unable to run on react typescript template

Tried running the playground project and it works fine . However when i integrate the new syntax with reactjs typescript template with fields still get the "Maximum stack error". Can you please help me with running the playground code with the attached template react ? I am quite clueless as to what needs to be done to get this to working.

I have tried with changing tsconfig values with no luck. Thanks in advance.

exp-app - Copy.zip

Optimize mapped types

Optimize mapped types, focus on:

  • recursive types
  • mapped types

Resources

Current playground diagnostics:

Metric Value
Files 66
Lines 12574
Nodes 38223
Identifiers 13284
Symbols 16197
Types 13419
Memory used 50178K
I/O read 0.04s
I/O write 0.00s
Parse time 0.46s
Bind time 0.18s
Check time 0.84s
Emit time 0.00s
Total time 1.47s

Repo grooming on master

  • dependency cleanup
  • cherry pick scripts from experimental branch for streamlined npm installation using github urls
  • playground-source should go out

`session` static property missing from Model

The session static property is missing from the Model class, which causes the following code to raise a TS error - Property 'session' does not exist on type 'typeof Node'.

  /**
   * Clones the node.
   */
  public clone(): Node {
    const {id, ...attributes} = this.ref;

    return this.getClass().session.Node.create({
      ...attributes,
    });
  }

The session getter is implemented here:
https://github.com/redux-orm/redux-orm/blob/3efec435039a56476da6872f623972021bd94703/src/Model.js#L207

Redux-ORM typescript example

Hi,

first, thank you for fantastic job)

I'm using right now the old version of @types/redux-orm.

Can you please add a few examples how to use latest version of it?

Dennis

`Model.exists` has invalid signature

Model.exists signature is identical to QuerySet.exists

In library source Model.exists accepts a lookup obj as argument

/**
     * Returns a boolean indicating if an entity
     * with the given props exists in the state.
     *
     * @param  {*}  props - a key-value that {@link Model} instances should have to be considered as existing.
     * @return {Boolean} a boolean indicating if entity with `props` exists in the state
     */
    static exists(lookupObj) {
        if (typeof this.session === 'undefined') {
            throw new Error([
                `Tried to check if a ${this.modelName} model instance exists without a session. `,
                'Create a session using `session = orm.session()` and call ',
                `\`session["${this.modelName}"].exists\` instead.`,
            ].join(''));
        }

        return Boolean(
            this._findDatabaseRows(lookupObj).length
        );
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.