Trouble running ISOXML creation usage example
tvoirand opened this issue · comments
Hi,
I am trying to reproduce the usage example "Create manually and save ISOXML" from the readme, but I am having trouble running this example. I apologize in advance if my issue is not caused by isoxml-js, but by my limited knowledge of JavaScript and TypeScript (which is very probable).
I am using a Linux VM (Ubuntu 20.04) and a Windows host machine, on which I installed NodeJS, npm and node-typescript.
I first initiated a NodeJS project, and installed isoxml-js and typescript:
npm init
npm install isoxml --save
npm install -D typescript
npm install --save-dev @types/node
I then followed these steps, iteratively after adding each line of the usage example:
- Write contents of usage example from readme line after line in
index.ts
file - Compile TypeScript file into JavaScript file:
tsc index.ts
- Run usage example:
node index.js
The first line of code returned this error: index.ts:1:8 - error TS1192: Module '"fs"' has no default export.
, which I fixed by changing in the usage example import fs from 'fs'
to import * as fs from 'fs'
(based on this SO question).
Line 5 (declaring isoxmlManager
instance) did not return any error.
After adding lines 7-10 (creating an instance of Task entity), step 2 (compilation) returns the following errors:
index.ts:8:55 - error TS2304: Cannot find name 'TAGS'.
index.ts:9:17 - error TS2304: Cannot find name 'TaskTaskStatusEnum'.
index.ts:10:7 - error TS2304: Cannot find name 'ExtendedTask'.
I have tried creating a tsconfig.json file using tsc --init
, but this doesn't fix my issue.
Is there something missing in my method to install and run the library?
If needed I can give more details, for example on my version of NodeJS and npm.
Many thanks in advance for your help,
Thibaut
Hi @tvoirand . Thank you very much for reporting this problem! I confirm that the example doesn't work properly if you copy-paste it to a file. I'll update README and create a folder with the correct examples this weekend.
Thanks a lot @aparshin for this quick reply. Looking forward to your update!
Hi @tvoirand, I fixed the examples in README and added them as TS scripts in the new folder examples
. Please try it out and let me know if you can run them locally!
Many thanks for this update.
However I'm sorry but I still haven't managed to run the example.
I tried the instruction described in the example of building locally (npm run build
), and got the following error:
```
thibaut@thibaut-VirtualBox:~/thibaut/isoxml-js/isoxml-js$ npm run build
> isoxml@1.6.1 build
> tsc
src/entities/TimeLog/BufferReader.ts:15:30 - error TS1005: ']' expected.
15 [t in keyof typeof types as `next${t}`]: () => number
~~
src/entities/TimeLog/BufferReader.ts:15:43 - error TS1005: ';' expected.
15 [t in keyof typeof types as `next${t}`]: () => number
~
src/entities/TimeLog/BufferReader.ts:15:44 - error TS1128: Declaration or statement expected.
15 [t in keyof typeof types as `next${t}`]: () => number
~
src/entities/TimeLog/BufferReader.ts:16:1 - error TS1128: Declaration or statement expected.
16 } & {
~
src/entities/TimeLog/BufferReader.ts:16:3 - error TS1109: Expression expected.
16 } & {
~
src/entities/TimeLog/BufferReader.ts:18:5 - error TS1005: ',' expected.
18 seek: (pos: number) => void
~~~~
src/entities/TimeLog/BufferReader.ts:19:9 - error TS1005: ',' expected.
19 move: (diff: number) => void
~
src/entities/TimeLog/BufferReader.ts:19:11 - error TS1136: Property assignment expected.
19 move: (diff: number) => void
~
src/entities/TimeLog/BufferReader.ts:19:16 - error TS1005: ',' expected.
19 move: (diff: number) => void
~
src/entities/TimeLog/BufferReader.ts:19:26 - error TS1005: ';' expected.
19 move: (diff: number) => void
~~
src/entities/TimeLog/BufferReader.ts:20:1 - error TS1109: Expression expected.
20 }
~
Found 11 errors.
```
I suspected that something might be wrong with my TypeScript install. So I ran sudo npm install -g typescript
and tried again to build locally. I then got these other errors:
```
thibaut@thibaut-VirtualBox:~/thibaut/isoxml-js/isoxml-js$ npm run build
> isoxml@1.6.1 build
> tsc
src/ISOXMLManager.spec.ts:1:30 - error TS2307: Cannot find module 'fs' or its corresponding type declarations.
1 import { readFileSync } from 'fs'
~~~~
src/ISOXMLManager.spec.ts:2:19 - error TS2307: Cannot find module 'jszip' or its corresponding type declarations.
2 import JSZip from 'jszip'
~~~~~~~
src/ISOXMLManager.spec.ts:8:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
8 describe('ISOXML Manager', () => {
~~~~~~~~
src/ISOXMLManager.spec.ts:10:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
10 it('should parse ISOXML as ZIP', async () => {
~~
src/ISOXMLManager.spec.ts:14:9 - error TS2304: Cannot find name 'expect'.
14 expect(isoxmlManager.rootElement).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:15:9 - error TS2304: Cannot find name 'expect'.
15 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:18:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
18 it('should parse TASKDATA.XML as string', async () => {
~~
src/ISOXMLManager.spec.ts:24:9 - error TS2304: Cannot find name 'expect'.
24 expect(isoxmlManager.rootElement).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:25:9 - error TS2304: Cannot find name 'expect'.
25 expect(isoxmlManager.rootElement.attributes.Task).toHaveLength(2)
~~~~~~
src/ISOXMLManager.spec.ts:26:9 - error TS2304: Cannot find name 'expect'.
26 expect(isoxmlManager.options.rootFolder).toBe('')
~~~~~~
src/ISOXMLManager.spec.ts:29:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
29 it('should parse ISOXML with external files', async () => {
~~
src/ISOXMLManager.spec.ts:33:9 - error TS2304: Cannot find name 'expect'.
33 expect(isoxmlManager.rootElement.attributes.Task).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:34:9 - error TS2304: Cannot find name 'expect'.
34 expect(isoxmlManager.getReferenceByXmlId('TSK-1').entity).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:35:9 - error TS2304: Cannot find name 'expect'.
35 expect(isoxmlManager.rootElement.attributes.ExternalFileReference).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:36:9 - error TS2304: Cannot find name 'expect'.
36 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:41:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
41 it('should parse and save grid files', async () => {
~~
src/ISOXMLManager.spec.ts:45:9 - error TS2304: Cannot find name 'expect'.
45 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:48:9 - error TS2304: Cannot find name 'expect'.
48 expect(data.length).toBe(14065)
~~~~~~
src/ISOXMLManager.spec.ts:51:9 - error TS2304: Cannot find name 'expect'.
51 expect(zip.file("TASKDATA/GRD00001.BIN")).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:54:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
54 it('should parse and save timelog files', async () => {
~~
src/ISOXMLManager.spec.ts:58:9 - error TS2304: Cannot find name 'expect'.
58 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:63:9 - error TS2304: Cannot find name 'expect'.
63 expect(zip.file("TASKDATA/TLG00001.XML")).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:64:9 - error TS2304: Cannot find name 'expect'.
64 expect(zip.file("TASKDATA/TLG00001.BIN")).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:67:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
67 it('should preserve attached files', async () => {
~~
src/ISOXMLManager.spec.ts:71:9 - error TS2304: Cannot find name 'expect'.
71 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:76:9 - error TS2304: Cannot find name 'expect'.
76 expect(zip.file("TASKDATA/TEST1234.BIN")).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:79:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
79 it('should preserve proprietary attributes and elements', async () => {
~~
src/ISOXMLManager.spec.ts:83:9 - error TS2304: Cannot find name 'expect'.
83 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:89:9 - error TS2304: Cannot find name 'expect'.
89 expect(isoxmlManager2.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:90:9 - error TS2304: Cannot find name 'expect'.
90 expect(isoxmlManager2.rootElement.attributes.ProprietaryTags).toHaveProperty('P1234_Area')
~~~~~~
src/ISOXMLManager.spec.ts:91:9 - error TS2304: Cannot find name 'expect'.
91 expect(
~~~~~~
src/ISOXMLManager.spec.ts:96:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
96 it('should parse and save ISOXML', async () => {
~~
src/ISOXMLManager.spec.ts:100:9 - error TS2304: Cannot find name 'expect'.
100 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:103:9 - error TS2304: Cannot find name 'expect'.
103 expect(data.length).toBe(4044)
~~~~~~
src/ISOXMLManager.spec.ts:106:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
106 it('should manually create ISOXML', async () => {
~~
src/ISOXMLManager.spec.ts:117:9 - error TS2304: Cannot find name 'expect'.
117 expect(data.length).toBe(470)
~~~~~~
src/ISOXMLManager.spec.ts:119:9 - error TS2304: Cannot find name 'expect'.
119 expect(zip.file("TASKDATA/TASKDATA.XML")).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:122:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
122 it('should handle strings with special characters properly', async () => {
~~
src/ISOXMLManager.spec.ts:138:9 - error TS2304: Cannot find name 'expect'.
138 expect(isoxmlManager2.options.fmisTitle).toBe(`&<>'"`)
~~~~~~
src/ISOXMLManager.spec.ts:141:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
141 it('should preserve FMIS IDs', async () => {
~~
src/ISOXMLManager.spec.ts:156:9 - error TS2304: Cannot find name 'expect'.
156 expect(parsedRef.fmisId).toBe('777')
~~~~~~
src/ISOXMLManager.spec.ts:159:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
159 it('should support "rootFolder" option', async () => {
~~
src/ISOXMLManager.spec.ts:171:9 - error TS2304: Cannot find name 'expect'.
171 expect(zip.file("testFolder/TASKDATA.XML")).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:174:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
174 it('should generate unique filenames', async () => {
~~
src/ISOXMLManager.spec.ts:177:9 - error TS2304: Cannot find name 'expect'.
177 expect(firstName).toBe('GRD00001')
~~~~~~
src/ISOXMLManager.spec.ts:180:9 - error TS2304: Cannot find name 'expect'.
180 expect(secondName).toBe('GRD00002')
~~~~~~
src/ISOXMLManager.spec.ts:183:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
183 it('should not save V4Only elements in V3', async () => {
~~
src/ISOXMLManager.spec.ts:187:9 - error TS2304: Cannot find name 'expect'.
187 expect(isoxmlManager.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:194:9 - error TS2304: Cannot find name 'expect'.
194 expect(isoxmlManager2.getWarnings()).toHaveLength(0)
~~~~~~
src/ISOXMLManager.spec.ts:195:9 - error TS2304: Cannot find name 'expect'.
195 expect(isoxmlManager2.options.version).toBe(3)
~~~~~~
src/ISOXMLManager.spec.ts:196:9 - error TS2304: Cannot find name 'expect'.
196 expect(isoxmlManager2.rootElement.attributes).not.toHaveProperty('BaseStation')
~~~~~~
src/ISOXMLManager.spec.ts:197:9 - error TS2304: Cannot find name 'expect'.
197 expect(isoxmlManager2.rootElement.attributes.CropType[0].attributes).not.toHaveProperty('ProductGroupIdRef')
~~~~~~
src/ISOXMLManager.spec.ts:200:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
200 it('should add warnings', async () => {
~~
src/ISOXMLManager.spec.ts:205:9 - error TS2304: Cannot find name 'expect'.
205 expect(warnings).toHaveLength(3)
~~~~~~
src/ISOXMLManager.spec.ts:206:9 - error TS2304: Cannot find name 'expect'.
206 expect(warnings.find(warn => warn.startsWith('[TSK1->TZN[1]]'))).toBeTruthy()
~~~~~~
src/ISOXMLManager.spec.ts:207:9 - error TS2304: Cannot find name 'expect'.
207 expect(warnings.find(warn => warn.startsWith('[TSK1]'))).toBeTruthy()
~~~~~~
src/ISOXMLManager.ts:1:36 - error TS2307: Cannot find module 'jszip' or its corresponding type declarations.
1 import JSZip, { JSZipObject } from 'jszip'
~~~~~~~
src/ISOXMLManager.ts:93:46 - error TS2550: Property 'values' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later.
93 const existingReference = Object.values(this.xmlReferences)
~~~~~~
src/ISOXMLManager.ts:202:23 - error TS2550: Property 'values' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later.
202 return Object.values(this.xmlReferences).find(ref => ref.entity === entity)
~~~~~~
src/ISOXMLManager.ts:216:23 - error TS2550: Property 'values' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later.
216 return Object.values(this.xmlReferences)
~~~~~~
src/entities/Grid/CellCenterBasedGridGenerator.ts:1:82 - error TS2307: Cannot find module '@turf/turf' or its corresponding type declarations.
1 import { bbox as turfBbox, Feature, FeatureCollection, Geometry, Position } from '@turf/turf'
~~~~~~~~~~~~
src/entities/Grid/CellCenterBasedGridGenerator.ts:2:19 - error TS2307: Cannot find module 'rbush' or its corresponding type declarations.
2 import RBush from 'rbush'
~~~~~~~
src/entities/Grid/DefaultGridParamsGenerator.ts:1:69 - error TS2307: Cannot find module '@turf/turf' or its corresponding type declarations.
1 import { bbox as turfBbox, degreesToRadians, lengthToDegrees } from '@turf/turf'
~~~~~~~~~~~~
src/entities/Grid/Grid.spec.ts:1:28 - error TS2307: Cannot find module 'fs' or its corresponding type declarations.
1 import {readFileSync} from 'fs'
~~~~
src/entities/Grid/Grid.spec.ts:6:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
6 describe('Grid Entity', () => {
~~~~~~~~
src/entities/Grid/Grid.spec.ts:7:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
7 it('should create instance from GeoJSON', async () => {
~~
src/entities/Grid/Grid.spec.ts:11:5 - error TS2304: Cannot find name 'expect'.
11 expect(grid.attributes.Filelength).toBe(22896)
~~~~~~
src/entities/Grid/Grid.spec.ts:13:5 - error TS2304: Cannot find name 'expect'.
13 expect(grid.attributes.GridMinimumNorthPosition).toBe(55.82481700900832)
~~~~~~
src/entities/Grid/Grid.spec.ts:14:5 - error TS2304: Cannot find name 'expect'.
14 expect(grid.attributes.GridMinimumEastPosition).toBe(39.138728173503324)
~~~~~~
src/entities/Grid/Grid.spec.ts:15:5 - error TS2304: Cannot find name 'expect'.
15 expect(grid.attributes.Filename).toBe('GRD00001')
~~~~~~
src/entities/Grid/Grid.spec.ts:19:5 - error TS2304: Cannot find name 'expect'.
19 expect(xml).toBeTruthy()
~~~~~~
src/entities/Grid/Grid.spec.ts:20:5 - error TS2304: Cannot find name 'expect'.
20 expect(Object.keys(isoxmlManager.filesToSave)).toHaveLength(1)
~~~~~~
src/entities/Grid/Grid.spec.ts:23:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
23 it('should convert Grid to GeoJSON', async () => {
~~
src/entities/Grid/Grid.spec.ts:30:5 - error TS2304: Cannot find name 'expect'.
30 expect(geoJSON).toBeTruthy()
~~~~~~
src/entities/Grid/Grid.spec.ts:31:5 - error TS2304: Cannot find name 'expect'.
31 expect(geoJSON.features[0].properties.DOSE).toBe(16) // 15.7 should be rounded to 16
~~~~~~
src/entities/Grid/Grid.ts:1:34 - error TS2307: Cannot find module '@turf/turf' or its corresponding type declarations.
1 import {FeatureCollection } from '@turf/turf'
~~~~~~~~~~~~
src/entities/Grid/IntersectionBasedGridGenerator.ts:1:59 - error TS2307: Cannot find module '@turf/turf' or its corresponding type declarations.
1 import { area, bbox as turfBbox, FeatureCollection } from "@turf/turf"
~~~~~~~~~~~~
src/entities/Grid/IntersectionBasedGridGenerator.ts:2:39 - error TS2307: Cannot find module 'polygon-clipping' or its corresponding type declarations.
2 import { intersection, Polygon } from 'polygon-clipping'
~~~~~~~~~~~~~~~~~~
src/entities/Grid/IntersectionBasedGridGenerator.ts:3:19 - error TS2307: Cannot find module 'rbush' or its corresponding type declarations.
3 import RBush from "rbush"
~~~~~~~
src/entities/ISO11783LinkListFile.ts:45:34 - error TS2550: Property 'values' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later.
45 const links = Object.values(this.isoxmlManager.xmlReferences)
~~~~~~
src/entities/Partfield.spec.ts:2:30 - error TS2307: Cannot find module '@turf/helpers' or its corresponding type declarations.
2 import { MultiPolygon } from '@turf/helpers'
~~~~~~~~~~~~~~~
src/entities/Partfield.spec.ts:7:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
7 describe('Partfield Entity', () => {
~~~~~~~~
src/entities/Partfield.spec.ts:8:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
8 it('should add geometry from GeoJSON', () => {
~~
src/entities/Partfield.spec.ts:17:9 - error TS2304: Cannot find name 'expect'.
17 expect(partfield.attributes.PartfieldArea).toBe(2026305612)
~~~~~~
src/entities/Partfield.spec.ts:18:9 - error TS2304: Cannot find name 'expect'.
18 expect(partfield.attributes.PolygonnonTreatmentZoneonly).toHaveLength(2)
~~~~~~
src/entities/Partfield.spec.ts:21:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
21 it('should normalize boundary from v4 to v3', () => {
~~
src/entities/Partfield.spec.ts:33:9 - error TS2304: Cannot find name 'expect'.
33 expect(xml[TAGS.Polygon]).toHaveLength(1)
~~~~~~
src/entities/Partfield.spec.ts:36:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
36 it('should normalize boundary from v3 to v4', () => {
~~
src/entities/Partfield.spec.ts:48:9 - error TS2304: Cannot find name 'expect'.
48 expect(xml[TAGS.Polygon]).toHaveLength(2)
~~~~~~
src/entities/Partfield.spec.ts:51:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
51 it('should return GeoJSON', () => {
~~
src/entities/Partfield.spec.ts:61:9 - error TS2304: Cannot find name 'expect'.
61 expect(geoJSON.type).toBe('MultiPolygon')
~~~~~~
src/entities/Partfield.spec.ts:62:9 - error TS2304: Cannot find name 'expect'.
62 expect(geoJSON.coordinates).toHaveLength(2)
~~~~~~
src/entities/Partfield.spec.ts:63:9 - error TS2304: Cannot find name 'expect'.
63 expect(geoJSON.coordinates[0]).toHaveLength(2)
~~~~~~
src/entities/Partfield.spec.ts:64:9 - error TS2304: Cannot find name 'expect'.
64 expect(geoJSON.coordinates[1]).toHaveLength(2)
~~~~~~
src/entities/Partfield.ts:1:79 - error TS2307: Cannot find module '@turf/turf' or its corresponding type declarations.
1 import { area, MultiPolygon as TurfMultiPolygon, Polygon as TurfPolygon} from "@turf/turf"
~~~~~~~~~~~~
src/entities/Polygon.spec.ts:4:30 - error TS2307: Cannot find module '@turf/helpers' or its corresponding type declarations.
4 import { MultiPolygon } from '@turf/helpers'
~~~~~~~~~~~~~~~
src/entities/Polygon.spec.ts:21:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
21 describe('Polygon Entity', () => {
~~~~~~~~
src/entities/Polygon.spec.ts:22:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
22 it('should be constructed from GeoJSON - version 3', async () => {
~~
src/entities/Polygon.spec.ts:29:9 - error TS2304: Cannot find name 'expect'.
29 expect(polygons).toHaveLength(1)
~~~~~~
src/entities/Polygon.spec.ts:30:9 - error TS2304: Cannot find name 'expect'.
30 expect(stat(polygons[0])).toEqual({inner: 2, outer: 2})
~~~~~~
src/entities/Polygon.spec.ts:33:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
33 it('should be constructed from GeoJSON - version 4', async () => {
~~
src/entities/Polygon.spec.ts:40:9 - error TS2304: Cannot find name 'expect'.
40 expect(polygons).toHaveLength(2)
~~~~~~
src/entities/Polygon.spec.ts:41:9 - error TS2304: Cannot find name 'expect'.
41 expect(stat(polygons[0])).toEqual({inner: 1, outer: 1})
~~~~~~
src/entities/Polygon.spec.ts:44:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
44 it('should normalize polygons from v4 to v3', async () => {
~~
src/entities/Polygon.spec.ts:56:9 - error TS2304: Cannot find name 'expect'.
56 expect(normalizedPolygons).toHaveLength(1)
~~~~~~
src/entities/Polygon.spec.ts:57:9 - error TS2304: Cannot find name 'expect'.
57 expect(stat(normalizedPolygons[0])).toEqual({inner: 2, outer: 2})
~~~~~~
src/entities/Polygon.spec.ts:60:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
60 it('should normalize polygons from v3 to v4', async () => {
~~
src/entities/Polygon.spec.ts:72:9 - error TS2304: Cannot find name 'expect'.
72 expect(normalizedPolygons).toHaveLength(2)
~~~~~~
src/entities/Polygon.spec.ts:73:9 - error TS2304: Cannot find name 'expect'.
73 expect(stat(normalizedPolygons[0])).toEqual({inner: 1, outer: 1})
~~~~~~
src/entities/Polygon.spec.ts:76:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
76 it('should normalize polygons with undefined argument', async () => {
~~
src/entities/Polygon.spec.ts:79:9 - error TS2304: Cannot find name 'expect'.
79 expect(normalizedPolygons).toHaveLength(0)
~~~~~~
src/entities/Polygon.spec.ts:82:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
82 it('should convert to GeoJSON', async () => {
~~
src/entities/Polygon.spec.ts:94:9 - error TS2304: Cannot find name 'expect'.
94 expect(geoJSON.type).toBe('MultiPolygon')
~~~~~~
src/entities/Polygon.spec.ts:95:9 - error TS2304: Cannot find name 'expect'.
95 expect(geoJSON.coordinates).toHaveLength(2)
~~~~~~
src/entities/Polygon.spec.ts:96:9 - error TS2304: Cannot find name 'expect'.
96 expect(geoJSON.coordinates[0]).toHaveLength(2)
~~~~~~
src/entities/Polygon.spec.ts:97:9 - error TS2304: Cannot find name 'expect'.
97 expect(geoJSON.coordinates[1]).toHaveLength(2)
~~~~~~
src/entities/Polygon.spec.ts:98:9 - error TS2304: Cannot find name 'expect'.
98 expect(geoJSON.bbox).toEqual([
~~~~~~
src/entities/Polygon.ts:6:8 - error TS2307: Cannot find module '@turf/turf' or its corresponding type declarations.
6 } from "@turf/turf"
~~~~~~~~~~~~
src/entities/Polygon.ts:7:30 - error TS2307: Cannot find module 'polygon-clipping' or its corresponding type declarations.
7 import { intersection } from "polygon-clipping"
~~~~~~~~~~~~~~~~~~
src/entities/Task.spec.ts:1:30 - error TS2307: Cannot find module 'fs' or its corresponding type declarations.
1 import { readFileSync } from 'fs'
~~~~
src/entities/Task.spec.ts:6:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
6 describe('Task Entity', () => {
~~~~~~~~
src/entities/Task.spec.ts:7:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
7 it('should add Grid from GeoJSON', async () => {
~~
src/entities/Task.spec.ts:17:9 - error TS2304: Cannot find name 'expect'.
17 expect(task.attributes.TreatmentZone).toHaveLength(2)
~~~~~~
src/entities/Task.spec.ts:18:9 - error TS2304: Cannot find name 'expect'.
18 expect(task.attributes.Grid).toHaveLength(1)
~~~~~~
src/entities/Task.spec.ts:21:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
21 it('should return Grid as GeoJSON', async () => {
~~
src/entities/Task.spec.ts:33:9 - error TS2304: Cannot find name 'expect'.
33 expect(geoJSON).toBeTruthy()
~~~~~~
src/entities/Task.spec.ts:34:9 - error TS2304: Cannot find name 'expect'.
34 expect(geoJSON.features[0].properties.DOSE).toBe(16) // 15.7 should be rounded to 16
~~~~~~
src/entities/Task.spec.ts:37:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
37 it('should return grid values description', async () => {
~~
src/entities/Task.spec.ts:47:9 - error TS2304: Cannot find name 'expect'.
47 expect(descriptionBefore).toHaveLength(0)
~~~~~~
src/entities/Task.spec.ts:53:9 - error TS2304: Cannot find name 'expect'.
53 expect(descriptionAfter).toHaveLength(1)
~~~~~~
src/entities/Task.spec.ts:54:9 - error TS2304: Cannot find name 'expect'.
54 expect(descriptionAfter[0].DDINumber).toBe(1)
~~~~~~
src/entities/Task.spec.ts:55:9 - error TS2304: Cannot find name 'expect'.
55 expect(descriptionAfter[0].scale).toBe(0.01)
~~~~~~
src/entities/Task.spec.ts:56:9 - error TS2304: Cannot find name 'expect'.
56 expect(descriptionAfter[0].offset).toBe(0)
~~~~~~
src/entities/Task.spec.ts:68:9 - error TS2304: Cannot find name 'expect'.
68 expect(descriptionAfterWithVPN).toHaveLength(1)
~~~~~~
src/entities/Task.spec.ts:69:9 - error TS2304: Cannot find name 'expect'.
69 expect(descriptionAfterWithVPN[0].DDINumber).toBe(1)
~~~~~~
src/entities/Task.spec.ts:70:9 - error TS2304: Cannot find name 'expect'.
70 expect(descriptionAfterWithVPN[0].scale).toBe(2)
~~~~~~
src/entities/Task.spec.ts:71:9 - error TS2304: Cannot find name 'expect'.
71 expect(descriptionAfterWithVPN[0].offset).toBe(20)
~~~~~~
src/entities/Task.spec.ts:72:9 - error TS2304: Cannot find name 'expect'.
72 expect(descriptionAfterWithVPN[0].unit).toBe('custom-unit')
~~~~~~
src/entities/Task.ts:8:35 - error TS2307: Cannot find module '@turf/helpers' or its corresponding type declarations.
8 import { FeatureCollection } from '@turf/helpers'
~~~~~~~~~~~~~~~
src/entities/TimeLog/TimeLog.spec.ts:1:30 - error TS2307: Cannot find module 'fs' or its corresponding type declarations.
1 import { readFileSync } from "fs"
~~~~
src/entities/TimeLog/TimeLog.spec.ts:5:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
5 describe('TimeLog Entity', () => {
~~~~~~~~
src/entities/TimeLog/TimeLog.spec.ts:6:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
6 it('should parse binary TimeLog files', async () => {
~~
src/entities/TimeLog/TimeLog.spec.ts:16:9 - error TS2304: Cannot find name 'expect'.
16 expect(parsedTimeLog.timeLogs).toHaveLength(207)
~~~~~~
src/entities/TimeLog/TimeLog.spec.ts:17:9 - error TS2304: Cannot find name 'expect'.
17 expect(parsedTimeLog.valuesInfo).toHaveLength(4)
~~~~~~
src/entities/TimeLog/TimeLog.spec.ts:18:9 - error TS2304: Cannot find name 'expect'.
18 expect(parsedTimeLog.bbox).toEqual([9.5777866, 45.5277534, 9.5779409, 45.5278066])
~~~~~~
src/entities/TimeLog/TimeLog.spec.ts:21:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
21 it('should detect outliers', async () => {
~~
src/entities/TimeLog/TimeLog.spec.ts:31:9 - error TS2304: Cannot find name 'expect'.
31 expect(ranges[2].minValue).toBe(-2231)
~~~~~~
src/entities/TimeLog/TimeLog.spec.ts:32:9 - error TS2304: Cannot find name 'expect'.
32 expect(ranges[2].maxValue).toBe(334)
~~~~~~
src/entities/TreatmentZone.spec.ts:4:30 - error TS2307: Cannot find module '@turf/helpers' or its corresponding type declarations.
4 import { MultiPolygon } from '@turf/helpers'
~~~~~~~~~~~~~~~
src/entities/TreatmentZone.spec.ts:9:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
9 describe('TreatmentZone Entity', () => {
~~~~~~~~
src/entities/TreatmentZone.spec.ts:10:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
10 it('should normalize boundary from v4 to v3', async () => {
~~
src/entities/TreatmentZone.spec.ts:25:9 - error TS2304: Cannot find name 'expect'.
25 expect(xml[TAGS.Polygon]).toHaveLength(1)
~~~~~~
src/entities/TreatmentZone.spec.ts:28:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
28 it('should normalize boundary from v3 to v4', async () => {
~~
src/entities/TreatmentZone.spec.ts:43:9 - error TS2304: Cannot find name 'expect'.
43 expect(xml[TAGS.Polygon]).toHaveLength(2)
~~~~~~
src/index.ts:7:35 - error TS2307: Cannot find module '@turf/helpers' or its corresponding type declarations.
7 export { FeatureCollection } from '@turf/helpers'
~~~~~~~~~~~~~~~
src/utils.spec.ts:6:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
6 describe('Utils', () => {
~~~~~~~~
src/utils.spec.ts:7:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
7 it('constructValueInformation', async () => {
~~
src/utils.spec.ts:11:9 - error TS2304: Cannot find name 'expect'.
11 expect(valueInfo.DDIString).toBe('0001')
~~~~~~
src/utils.spec.ts:12:9 - error TS2304: Cannot find name 'expect'.
12 expect(valueInfo.DDINumber).toBe(1)
~~~~~~
src/utils.spec.ts:13:9 - error TS2304: Cannot find name 'expect'.
13 expect(valueInfo.DDEntityName).toBe('Setpoint Volume Per Area Application Rate as [mm³/m²]')
~~~~~~
src/utils.spec.ts:14:9 - error TS2304: Cannot find name 'expect'.
14 expect(valueInfo.unit).toBe('mm³/m²')
~~~~~~
src/utils.spec.ts:15:9 - error TS2304: Cannot find name 'expect'.
15 expect(valueInfo.numberOfDecimals).toBe(2)
~~~~~~
src/utils.spec.ts:16:9 - error TS2304: Cannot find name 'expect'.
16 expect(valueInfo.offset).toBe(0)
~~~~~~
src/utils.spec.ts:17:9 - error TS2304: Cannot find name 'expect'.
17 expect(valueInfo.scale).toBe(0.01)
~~~~~~
src/utils.spec.ts:20:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
20 it('constructValueInformation with ValuePresentation', async () => {
~~
src/utils.spec.ts:33:9 - error TS2304: Cannot find name 'expect'.
33 expect(valueInfo.DDIString).toBe('0001')
~~~~~~
src/utils.spec.ts:34:9 - error TS2304: Cannot find name 'expect'.
34 expect(valueInfo.DDINumber).toBe(1)
~~~~~~
src/utils.spec.ts:35:9 - error TS2304: Cannot find name 'expect'.
35 expect(valueInfo.DDEntityName).toBe('Setpoint Volume Per Area Application Rate as [mm³/m²]')
~~~~~~
src/utils.spec.ts:36:9 - error TS2304: Cannot find name 'expect'.
36 expect(valueInfo.unit).toBe('l/h')
~~~~~~
src/utils.spec.ts:37:9 - error TS2304: Cannot find name 'expect'.
37 expect(valueInfo.numberOfDecimals).toBe(1)
~~~~~~
src/utils.spec.ts:38:9 - error TS2304: Cannot find name 'expect'.
38 expect(valueInfo.offset).toBe(0)
~~~~~~
src/utils.spec.ts:39:9 - error TS2304: Cannot find name 'expect'.
39 expect(valueInfo.scale).toBe(0.0001)
~~~~~~
src/utils.spec.ts:42:5 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
42 it('constructValueInformation - unknown DDEntity', async () => {
~~
src/utils.spec.ts:46:9 - error TS2304: Cannot find name 'expect'.
46 expect(valueInfo.DDIString).toBe('FFFF')
~~~~~~
src/utils.spec.ts:47:9 - error TS2304: Cannot find name 'expect'.
47 expect(valueInfo.DDINumber).toBe(65535)
~~~~~~
src/utils.spec.ts:48:9 - error TS2304: Cannot find name 'expect'.
48 expect(valueInfo.DDEntityName).toBe('')
~~~~~~
src/utils.spec.ts:49:9 - error TS2304: Cannot find name 'expect'.
49 expect(valueInfo.unit).toBe('')
~~~~~~
src/utils.spec.ts:50:9 - error TS2304: Cannot find name 'expect'.
50 expect(valueInfo.numberOfDecimals).toBe(-0)
~~~~~~
src/utils.spec.ts:51:9 - error TS2304: Cannot find name 'expect'.
51 expect(valueInfo.offset).toBe(0)
~~~~~~
src/utils.spec.ts:52:9 - error TS2304: Cannot find name 'expect'.
52 expect(valueInfo.scale).toBe(1)
~~~~~~
src/xmlManager.ts:1:84 - error TS2307: Cannot find module 'fast-xml-parser' or its corresponding type declarations.
1 import {XMLBuilder, XmlBuilderOptionsOptional, XMLParser, X2jOptionsOptional} from 'fast-xml-parser'
~~~~~~~~~~~~~~~~~
Found 181 errors in 19 files.
Errors Files
56 src/ISOXMLManager.spec.ts:1
4 src/ISOXMLManager.ts:1
2 src/entities/Grid/CellCenterBasedGridGenerator.ts:1
1 src/entities/Grid/DefaultGridParamsGenerator.ts:1
12 src/entities/Grid/Grid.spec.ts:1
1 src/entities/Grid/Grid.ts:1
3 src/entities/Grid/IntersectionBasedGridGenerator.ts:1
1 src/entities/ISO11783LinkListFile.ts:45
14 src/entities/Partfield.spec.ts:2
1 src/entities/Partfield.ts:1
22 src/entities/Polygon.spec.ts:4
2 src/entities/Polygon.ts:6
19 src/entities/Task.spec.ts:1
1 src/entities/Task.ts:8
9 src/entities/TimeLog/TimeLog.spec.ts:1
6 src/entities/TreatmentZone.spec.ts:4
1 src/index.ts:7
25 src/utils.spec.ts:6
1 src/xmlManager.ts:1
```
Am I missing requirements to run the library?
For information, when trying with the same method I tried before (install isoxml with npm install isoxml --save
), I get the following error:
thibaut@thibaut-VirtualBox:~/thibaut/pulverisation/ga_isoxml$ tsc index.ts
index.ts:3:25 - error TS2305: Module '"./node_modules/isoxml/dist"' has no exported member 'TAGS'.
3 import { ISOXMLManager, TAGS, TaskTaskStatusEnum, ExtendedTask } from 'isoxml'
~~~~
Found 1 error.
But I guess this is not surprising since I understand only the source code on this repo (and not the npm released version of isoxml-js) was modified since my last try.
Something is wrong with your local typescript installation. Could you please try the following:
- Make sure that you don't have any local modifications in
package.json
andpackage-lock.json
files - Run
npm ci
(it will install all the dependencies from scratch) - Check the version of the installed typescript compiler:
./node_modules/.bin/.tsc --version
. It's expected to returnVersion 4.4.2
. - Run
npm run buld
again
For information, when trying with the same method I tried before (install isoxml with npm install isoxml --save), I get the following error:
Yes, this is my fault - I updated the export of the library but forgot to publish the new version. I'm going to do that when you confirm that the examples work for you.
Great, npm ci
fixed my install, and I ran npm run build
as well as both examples successfully.
I will look forward to the new published version and use the source code in the meantime.
Thanks again for your help and for your work on this project !