question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript issues when reusing definitions in ObjectDefinition and InputDefinition

See original GitHub issue

In 1.0.0 version, I was able to reuse definitions for both objectType and inputObjectType like so:

const experienceFieldsDefinition = (t: ObjectDefinitionBlock<any> | InputDefinitionBlock<any>) => {
  t.nonNull.string("position");
  // Next line produces compilation error in `1.1.0`
  t.field("employmentType", {
    type: EmploymentTypeEnumType
  });
});

const ExperienceType = objectType({
  name: "Experience",
  definition(t) {
    t.nonNull.objectId("_id");
    experienceFieldsDefinition(t);
  }
});

const ExperienceInput = inputObjectType({
  name: "ExperienceInput",
  definition(t) {
    experienceFieldsDefinition(t);
  }
});

After upgrading to 1.1.0, t.field(...) gives the following error:

This expression is not callable.
  Each member of the union type '{ <FieldName extends string>(name: FieldName, config: FieldOutConfig<any, FieldName>): void; <FieldName extends string>(config: FieldOutConfigWi
thName<any, FieldName>): void; } | { ...; }' has signatures, but none of those signatures are compatible with each other.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MarkAPhillipscommented, Sep 14, 2022

Any workaround or update on this and seeing this myself still in the latest version ?

1reaction
jasonkuhrtcommented, Jul 7, 2021

Yep probably, will try to check this out tomorrow or Friday.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reuse a function type's argument definition - Stack Overflow
In typescript is there a way to reuse parameter types as follows: interface Box { create: (paramToReuse: (value: any) => void) => void ......
Read more >
has signatures, but none of those signatures are compatible ...
Your problem is that the type of desc is ABC[] | DEF[] . ... issues when reusing definitions in ObjectDefinition and InputDefinition#943.
Read more >
TypeScript - Objects - Tutorialspoint
An object is an instance which contains set of key value pairs. The values can be scalar values or functions or even array...
Read more >
How to reuse object types on variables in TypeScript?
To understand it better, let's see a problem we might face while working with TypeScript. For example, let's say we have a variable...
Read more >
Technology and Human Issues in Reusing Learning Objects
The reuse of digital learning material has been an issue for more than two decades (Collis, ... For example in terms of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found