How to get Typescript to compile custom GraphQL Scalars

How to get Typescript to compile custom GraphQL Scalars


-1

This very simple GraphQL Custom Scalar fails with the typescript error:

TS2351: This expression is not constructable.
Type ‘typeof import("…/graphql/node_modules/graphql/index")’ has no construct signatures.

import GraphQLScalarType, { GraphQLInt } from 'graphql';

export const CustomScalar = new GraphQLScalarType({
    ...GraphQLInt,
    name: "CustomScalar"
})

what needs to be changed to get Typescript to compile it?

3

  • Please edit your question title to describe the problem you're having or question you're asking. Your current title is the useless repeating of the tag information (which shouldn't be in the title at all in most cases) with and Scalers as the only other words. Your title should be clear and descriptive enough that a future site user who is skimming a list of search results will know that it contains. For suggestions on writing a good title, see How to Ask.

    – Ken White

    1 hour ago

  • Any ideas on why it does not compile?

    – jmc42

    1 hour ago

  • There should be a second part of this error that points to a variable that has no construct signatures – please include the full error message.

    – Michel Floyd

    12 mins ago


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *