stencil-community / stencil-app-starter

Minimal starter project for building web components with Stencil
https://github.com/ionic-team/stencil
MIT License
320 stars 102 forks source link

An index signature parameter type must be either 'string' or 'number'. #92

Open crgardner opened 9 months ago

crgardner commented 9 months ago

Receiving the above error message after running npm start. Specifically, doesn't like ./node_modules/@types/babel__traverse/index.d.ts:

// this is good enough for non-visitor traverse options e.g. noScope

  | [k: ${string}\|${string}]: VisitNode<S, Node>;   | };

Environment

Reproduce

  1. npm init stencil
  2. Choose app [community]. Project is created.
  3. Change directory to project.
  4. npm install
  5. npm start. Browser starts. Transpile and other activity status displayed. Then error message "An index signature parameter type must be either 'string' or 'number'" along with the babel details shown above are displayed. Alos, see the same error message in the console as well as "build failed, watching for changes"
bitomic commented 8 months ago

You can use npm overrides or yarn resolutions to enforce an older version of @types/babel__traverse instead of latest.

Using yarn, you add this to your package.json:

{
    "resolutions": {
        "@types/babel__traverse": "7.0.6"
    }
}

Run yarn to install the dependencies, and yarn start should work now.

robMolloy commented 7 months ago

Just to rewrite the previous (excellent) answer more explicitly,

You may want to add both of the following within package.json to give more flexibility (resolutions works with yarn, overrides works with npm, feel free to delete as it suits you)

{
  "resolutions": {
    "@types/babel__traverse": "7.0.6"
  },
  "overrides": {
    "@types/babel__traverse": "7.0.6"
  }
}

If using yarn, run yarn then yarn start If using npm, run npm i then npm run start