Skip to content

Cannot use Point with TypeScript #426

Closed
@sseppola

Description

@sseppola

I'm using this driver in a typescript-node project and came across this issue where TS prevents me from using the Point because the type is missing a signature for new.

Cannot use 'new' with an expression whose type lacks a call or construct signature.
screen shot 2018-11-08 at 18 51 00

It's like it doesn't understand that it is a class. I solved the type issue, although hacky, by extending the Point type myself:

import { v1 as neo4j } from 'neo4j-driver';
import { Point as PointT } from 'neo4j-driver/types/v1/spatial-types';

const Point = neo4j.types.Point as PointT & {
  new (srid: number, x: number, y: number, z?: number): PointT;
};

screen shot 2018-11-08 at 19 01 52

This works and I'm now able to create Points. However, if I try to replicate the fix into spatial-types.d.ts with new(srid: T, x: number, y: number, z?: number): Point; it does not work. Would love to figure out how this can be fixed for everyone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions