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

@parcel/transformer-typescript-types: Cannot find module 'esri/geometry' or its corresponding type declarations. #8171

Closed
webmapLee opened this issue May 30, 2022 · 4 comments

Comments

@webmapLee
Copy link

webmapLee commented May 30, 2022

🐛 bug report

when i run parcel build,throw the errors:
image
image

🎛 Configuration (.babelrc, package.json, cli command)

tsconfig.json

{
    "compilerOptions": {
      "target": "ES2020",
      "module": "ESNext",
      "lib": ["ESNext", "DOM"],
      "moduleResolution": "node",
      "strict": true,
      "sourceMap": true,
      "resolveJsonModule": true,
      "esModuleInterop": true,
      "noUnusedLocals": true,
      "noUnusedParameters": true,
      "noImplicitReturns": true,
      "preserveConstEnums": true,
      "suppressImplicitAnyIndexErrors": true,
      "experimentalDecorators": true,
      "strictPropertyInitialization": false,  
      "noImplicitAny": true,
      "isolatedModules": true
    },
    "include": ["src/**/*"],
    "typedocOptions": {
      "entryPoints": "src/index.ts",
      "out": "docs"
    }
  }

package.json

{
  "name": "@pvgis/services",
  "version": "0.0.2",
  "description": "> TODO: description",
  "author": "liyb <[email protected]>",
  "homepage": "",
  "license": "ISC",
  "source": "src/index.ts",
  "main": "dist/main.js",
  "module": "dist/module.js",
  "types": "dist/types.d.ts",
  "directories": {
    "lib": "dist",
    "doc": "docs",
    "example": "examples"
  },
  "files": [
    "dist"
  ],
  "publishConfig": {
    "registry": "http://127.0.0.1:4873/"
  },
  "repository": {
    "type": "git",
  },
  "scripts": {
    "dev": "parcel examples/index.html --open --dist-dir ./examples/dist -p 3002",
    "build": "parcel build",
    "doc": "typedoc"
  },
  "dependencies": {
    "esri-loader": "^3.5.0"
  },
  "devDependencies": {
    "@parcel/packager-ts": "^2.6.0",
    "@parcel/transformer-typescript-types": "^2.6.0",
    "@types/arcgis-js-api": "^4.23.1",
    "parcel": "^2.6.0",
    "typescript": "^4.7.2"
  }
}

my source code:

import type { Point } from 'esri/geometry'
import type FeatureLayer from 'esri/layers/FeatureLayer'
import type FeatureSet from 'esri/rest/support/FeatureSet'

/**
 * @description: 图层查询类
 * @param {FeatureLayer} layer  图层
 * @param {Point} point  点
 * @return {Promise<FeatureSet>}  查询结果数据
 */
async function LayerQuery(
  layer: FeatureLayer,
  point: Point
): Promise<FeatureSet> {
  const featureSet = await layer.queryFeatures({
    geometry: point,
    // distance and units will be null if basic query selected
    spatialRelationship: 'intersects',
    returnGeometry: false,
    returnQueryGeometry: true,
    outFields: ['*'],
  })
  return featureSet
}
export { LayerQuery }

my source code 2

import { loadModules } from 'esri-loader'
import { getRandomColor } from '@pvgis/utils'

type MapModules = [typeof __esri.Graphic]
import SimpleMarkerSymbolProperties = __esri.SimpleMarkerSymbolProperties
async function createGraphic() {
  const [Graphic] = await (loadModules(['esri/Graphic']).catch((err) => {
    console.error(err)
  }) as Promise<MapModules>)

  const markerSymbol: SimpleMarkerSymbolProperties = {
    type: 'simple-marker', // autocasts as new SimpleMarkerSymbol()
    color: getRandomColor(),
    outline: {
      color: getRandomColor(),
      width: 1.5,
    },
  }

  const pointGraphic = new Graphic({
    symbol: markerSymbol,
  })
  return pointGraphic
}
export { createGraphic }

🤔 Expected Behavior

parcel build succesfully

🌍 Your Environment

Software Version(s)
Parcel 2.6.0
Node 16.14.0
npm/Yarn 8.3.1
Operating System Windows 11
@AshwinTayson
Copy link

Any idea why this is happening. Im facing the same issue

@matthijsgroen
Copy link

matthijsgroen commented Oct 18, 2022

I have this as well, by using 'fs' and 'fs/promises', it always claims it doesn't know them and I should add types, when the types are in the dependencies.

Edit: To clarify, its is a CLI node app, build as a library, not a web-app

Edit2: For me the solution was adding a /// <reference types="node" /> to the top of the file

@github-actions github-actions bot added the Stale Inactive issues label Apr 17, 2023
@parcel-bundler parcel-bundler deleted a comment from github-actions bot Apr 17, 2023
@mischnic mischnic removed the Stale Inactive issues label Apr 17, 2023
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Oct 15, 2023
@Darrenbydesign
Copy link

What was the solution for this? I am still not sure why this happens!?

I am having a similar issue with the parcel default named-pipeline "bundle-text" not being recognized even though I followed the example from the parcel docs on creating a declarations.d.ts file with bundle-text delcared

@github-actions github-actions bot removed the Stale Inactive issues label Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants