Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript errors in turf 6 (TS2304 and TS2312) #2017

Closed
everhardt opened this issue Jan 22, 2021 · 12 comments
Closed

TypeScript errors in turf 6 (TS2304 and TS2312) #2017

everhardt opened this issue Jan 22, 2021 · 12 comments

Comments

@everhardt
Copy link

I've updated @turf/turf from 5.1.6 to 6.3.0 and now TypeScript is complaining about the following when I transpile my project:

node_modules/@turf/center-median/dist/js/index.d.ts:59:29 - error TS2304: Cannot find name 'Position'.

59     medianCandidates: Array<Position>;
                               ~~~~~~~~

node_modules/@turf/clusters-dbscan/dist/js/index.d.ts:3:38 - error TS2312: An interface can only extend an object type or intersection of object types with statically known members.

3 export interface DbscanProps extends Properties {
                                       ~~~~~~~~~~

node_modules/@turf/clusters-kmeans/dist/js/index.d.ts:2:38 - error TS2312: An interface can only extend an object type or intersection of object types with statically known members.

2 export interface KmeansProps extends Properties {
                                       ~~~~~~~~~~

My tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "allowJs": false,
    "allowSyntheticDefaultImports": true,
    "target": "es2019",
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "moduleResolution": "node",
    "preserveSymlinks": true,
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": ".",
    "paths": {
      "*": [
        "node_modules/*",
        "src/types/*",
      ]
    },
    "typeRoots": [
      "./node_modules/@types",
      "./src/types"
    ]
  },
  "include": [
    "src/**/*",
    "test/**/*"
  ]
}

I just tried with 6.2.0 and that gives the same issue. For now, I've reverted back to 5.1.6

@mfedderly
Copy link
Collaborator

Your typescript settings are likely more strict than Turf's. I'm hoping to enable all the strictness but in the meantime you might want to look into the skipLibCheck option.

https://www.typescriptlang.org/docs/handbook/compiler-options.html

@everhardt
Copy link
Author

Thanks for the quick response. I looked into that but I have some custom declaration files in the project as well, that I do like to get checked. I'm not in a hurry, so I'll just hold off on updating for now.

@antonazaides
Copy link

Hi @mfedderly, I have a similar issue.

I also upgraded to 6.3 from 5.1, and I started to get ts 2322 (type assignment) erros.
Those errors happen for assignment of a feature to another feature. It seems null was added as an option somewhere, and I can't figure out where.

Could you please take a look? Thanks a lot for your time and effort!

An example for those two types :

selectedUnion: Feature <Polygon | MultiPolygon>
coveredAreaPolygon: Feature <Geometry>

image

Type 'Feature<Polygon | MultiPolygon, Properties>' is not assignable to type 'Feature<Geometry, Properties>'.
  Types of property 'geometry' are incompatible.
    Type 'Polygon | MultiPolygon | null' is not assignable to type 'Geometry'.
      Type 'null' is not assignable to type 'Geometry'.ts(2322)

I tried to change the coveredAreaPolygon to Feature, I get the same error but but for Geometry object:

Type 'import("c:/Users/AtonZaides/Documents/TaranisRepos/pilot-mission-tool/node_modules/@turf/center/node_modules/@turf/helpers/lib/geojson").Feature<import("c:/Users/AtonZaides/Documents/TaranisRepos/pilot-mission-tool/node_modules/@turf/center/node_modules/@turf/helpers/lib/geojson").Geometry, import("c:/Users/AtonZaid...' is not assignable to type 'import("c:/Users/AtonZaides/Documents/TaranisRepos/pilot-mission-tool/node_modules/@turf/helpers/dist/js/lib/geojson").Feature<import("c:/Users/AtonZaides/Documents/TaranisRepos/pilot-mission-tool/node_modules/@turf/helpers/dist/js/lib/geojson").Geometry, import("c:/Users/AtonZaides/Documents/TaranisRepos/pilot-miss...'.
  Types of property 'geometry' are incompatible.
    Type 'Geometry | null' is not assignable to type 'Geometry'.
      Type 'null' is not assignable to type 'Geometry'.ts(2322)

The same thing happens in other places, while trying to assign Feature<Polygon | MultiPolygon> to another Feature<Polygon | MultiPolygon>, and Feature to Feature.

Types of property 'geometry' are incompatible.
    Type 'Polygon | MultiPolygon | null' is not assignable to type 'Polygon | MultiPolygon'.
      Type 'null' is not assignable to type 'Polygon | MultiPolygon'

@Seairth
Copy link
Contributor

Seairth commented Feb 24, 2021

Submitted PR (#2044).

@Pesonet1
Copy link

This is not fully resolved, since centerMedian method still misses Position type import (@turf/center-median/dist/js/index.d.ts). Tested with newest 6.3. version. @Seairth PR only partly resolves the problem.

@Seairth
Copy link
Contributor

Seairth commented Mar 29, 2021

This is not fully resolved, since centerMedian method still misses Position type import (@turf/center-median/dist/js/index.d.ts). Tested with newest 6.3. version. @Seairth PR only partly resolves the problem.

Have you tested with the Master branch? The PR was submitted after 6.3. A version including that PR has not yet been published to npm.

@Pesonet1
Copy link

My bad. I thought that that was already published (should have investigated further).

@Naitik333
Copy link

@mfedderly When this fix will be released? Its blocking so many people to upgrade to latest version 6.3.0.
Please release this fix as soon as possible.

Naitik333 added a commit to heremaps/here-cli that referenced this issue May 9, 2021
…urf#2017 issue is not resolved

Signed-off-by: Nisar, Naitik <naitik.nisar@here.com>
Naitik333 added a commit to heremaps/here-cli that referenced this issue May 11, 2021
…urf#2017 issue is not resolved

Signed-off-by: Nisar, Naitik <naitik.nisar@here.com>
@karl-axel-linstrom
Copy link

when is this fix getting released? and until that what how far back does one have to go to find a version without this bug?

@sagewall
Copy link

I'm also anxiously awaiting a new release to NPM due to the typescript errors preventing the build in @angular/cli 12

@everhardt
Copy link
Author

I just updated to turf 6.4, but I still get one of them:

node_modules/@turf/clusters-dbscan/dist/js/index.d.ts:3:38 - error TS2312: An interface can only extend an object type or intersection of object types with statically known members.

3 export interface DbscanProps extends Properties {
                                       ~~~~~~~~~~

@mfedderly
Copy link
Collaborator

Yep still working on it. There's 5 packages that still need fixes. polygonize, clusters-kmeans, clusters-dbscan, boolean-equal, and boolean-overlap. Waiting on:
DefinitelyTyped/DefinitelyTyped#53899
DefinitelyTyped/DefinitelyTyped#53900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants