web-dev-qa-db-fra.com

Impossible de trouver le module './app.svelte' ou ses déclarations de type correspondantes

J'ai une configuration qui intègre l'électron avec Svelte ainsi que le support dossier.

lorsque j'exécute le script rollup pour compiler svelte application, je ne peux pas trouver le module ./App.svelte erreur comme indiqué ci-dessous.

Plugin TypeScript: @rollup/plugin-TypeScript TS2307: Cannot find module './App.svelte' or its corresponding type declarations.

Voici mon package.json configuration :

{
  "name": "tapwire-electron-first",
  "productName": "tapwire-electron-first",
  "version": "1.0.0",
  "description": "My Electron application description",
  "main": "dist/index.js",
  "scripts": {
    "electron-start": "tsc && electron-forge start",
    "electron-package": "electron-forge package",
    "electron-make": "electron-forge make",
    "electron-publish": "electron-forge publish",
    "electron-lint": "eslint --ext .ts .",
    "svelte-build": "rollup -c",
    "svelte-dev": "rollup -c -w",
    "svelte-start": "sirv public",
    "svelte-validate": "svelte-check",
    "start": "run-p svelte-dev electron-start"
  },
  "keywords": [],
  "author": {
    "name": "nateshmbhat",
  },
  "license": "MIT",
  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "tapwire_electron_first"
          }
        },
        {
          "name": "@electron-forge/maker-Zip",
          "platforms": [
            "darwin"
          ]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {}
        }
      ]
    }
  },
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.53",
    "@electron-forge/maker-deb": "^6.0.0-beta.53",
    "@electron-forge/maker-rpm": "^6.0.0-beta.53",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.53",
    "@electron-forge/maker-Zip": "^6.0.0-beta.53",
    "@rollup/plugin-commonjs": "^15.1.0",
    "@rollup/plugin-node-resolve": "^9.0.0",
    "@rollup/plugin-TypeScript": "^6.0.0",
    "@types/node": "^14.11.2",
    "@TypeScript-eslint/eslint-plugin": "^2.34.0",
    "@TypeScript-eslint/parser": "^2.34.0",
    "cross-env": "^7.0.2",
    "electron": "10.1.3",
    "eslint": "^7.10.0",
    "eslint-plugin-import": "^2.22.1",
    "npm-run-all": "^4.1.5",
    "rollup": "^2.28.2",
    "rollup-plugin-livereload": "^2.0.0",
    "rollup-plugin-svelte": "^6.0.1",
    "rollup-plugin-terser": "^7.0.2",
    "svelte": "^3.29.0",
    "svelte-check": "^1.0.55",
    "svelte-preprocess": "^4.3.2",
    "TypeScript": "^4.0.3"
  },
  "dependencies": {
    "concurrently": "^5.3.0",
    "electron-reload": "^1.5.0",
    "electron-squirrel-startup": "^1.0.0",
    "sirv-cli": "^1.0.6"
  }
}
3
Natesh bhat

S'avère que je devais installer @tsconfig/svelte comme une dépendance de devir, puis prolongez-la avec mon tsconfig.json comme indiqué ci-dessous :

Installer @ tsconfig/svelte

npm i --save-dev @tsconfig/svelte

Ajoutez ce TSConfig en tant que fichier de configuration de base dans votre tsconfig.json:

{
  "extends": "@tsconfig/svelte/tsconfig.json",
}
3
Natesh bhat