Skip to content

Issues with typescript generated models #364

@krstns

Description

@krstns

Hello

I have a few issues with generated models by mst-gql 0.15.0. My project fails to compile.

  1. All of the exported types cause circular reference issues. I have to replace:
    export type RootStoreType = Instance<typeof RootStore.Type>;
    with
    export interface RootStoreType extends Instance<typeof RootStore.Type> {}
    and similar.

  2. TS7022: 'RootStore' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. (this one is also fixed by changes made in 1.)

  3. TS2742: The inferred type of 'RootStore' cannot be named without a reference to 'mst-gql/node_modules/graphql'. This is likely not portable. A type annotation is necessary.

  4. Incorrect handling of optional type args in the model selector query. One of my fields is generated like this:
    instances(builder: string | ActionConnectionModelSelector | ((selector: ActionConnectionModelSelector) => ActionConnectionModelSelector) | undefined, args?: { first?: number, last?: number, before?: string, after?: string }) { return this.__child(instances(first: ${JSON.stringify(args['first'])}, last: ${JSON.stringify(args['last'])}, before: ${JSON.stringify(args['before'])}, after: ${JSON.stringify(args['after'])}), ActionConnectionModelSelector, builder) }

Inside the JSON.stringify calls, the args can be undefined.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions