Skip to content

compiler error, undefined is not assignable to number #43

@carwe

Description

@carwe

points[i] = new Coordinates(point.lat2, point.lon2);

ERROR in /home/user/Projekte/map/src/components/coordinates.ts
./src/components/coordinates.ts 437:44-54
[tsl] ERROR in /home/user/Projekte/map/src/components/coordinates.ts(437,45)
      TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.

A possible workaround (to quickly get a working build) is to assert them as not-undefined (see https://stackoverflow.com/questions/52838335/ts2345-argument-of-type-number-undefined-is-not-assignable-to-parameter-of) like so:
points[i] = new Coordinates(point.lat2!, point.lon2!);

... or to globally disable the compiler-check for that (strictNullChecks) (nope).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions