ウェブサイト検索

jestjs - jest は有効な TypeScript コードで「セミコロンが不足しているエラー」が発生する


Node.js v16.14.0 npm 8.3.1

私はこのコードをTypeScriptとJestの動作するプロジェクトからコピーしましたが、なぜか設定が悪いようです。すべてのテストでこの行のコロンのところにセミコロンがないというエラーが出ています

let userSvc: UserService;

私は非常に小さなプロジェクト https://github.com/deanhiller/userServiceJs を作成し、単に jest を動作させようとしています。このコマンドは問題なく動作します…

./node_modules/.bin/tsc 

jestを動かすにはどうすればいいですか?

私は次の package.json ファイルを持っています(もちろん、上の GitHub のリンクをクリックすれば見つかります)

   {
        "name": "userservice",
        "version": "1.0.0",
        "description": "typescript interview",
        "main": "index.js",
        "scripts": {
        "test": "test"
        },
        "repository": {
        "type": "git",
        "url": "git+ssh://[email /deanhiller/userServiceJs.git"
        },
        "author": "Dean",
        "license": "ISC",
        "bugs": {
        "url": "https://github.com/deanhiller/userServiceJs/issues"
        },
        "homepage": "https://github.com/deanhiller/userServiceJs#readme",
        "devDependencies": {
        "@babel/core": "7.19.3",
        "@babel/preset-env": "7.19.4",
        "@babel/preset-typescript": "7.18.6",
        "@types/jest": "^29.1.2",
        "babel-jest": "29.2.0",
        "jest": "29.2.0",
        "ts-generic-collections-linq": "1.0.7",
        "ts-jest": "29.0.3",
        "typescript": "4.8.4"
        }
     }

私は次の tsconfig.json を持っています(再び、上の GitHub リンクで見つけました)

           {
           "compilerOptions": {
           "experimentalDecorators": true,
           "target": "es6",
           "outDir": "dist",
           "lib": [
           "dom",
           "dom.iterable",
           "esnext"
           ],
           "sourceMap": true,
           "allowJs": false,
           "noImplicitAny": true,
           "skipLibCheck": true,
           "esModuleInterop": true,
           "allowSyntheticDefaultImports": true,
           "strict": true,
           "forceConsistentCasingInFileNames": true,
           "noFallthroughCasesInSwitch": true,
           "module": "esnext",
           "moduleResolution": "node",
           "resolveJsonModule": true,
           "isolatedModules": true,
           "noEmit": false,
           "jsx": "react-jsx"
           },
           "include": [
           "src"
           ]
      }