物业“阿贾克斯”的类型不存在“的typeof茉莉花”

问题描述 投票:3回答:1

我试图安装茉莉在角CLI项目插件“茉莉花AJAX”。该指令似乎很标准,但我保留收到​​此错误:

“ERROR在SRC /应用/ app.component.spec.ts(8,13):错误TS2339:属性 '阿贾克斯' 的类型 '的typeof茉莉花' 不存在”

我一直在jasmine.Ajax.install看到错误()

在我karma.conf.js文件,我有这样的:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine-ajax', 'jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma'),
      require('karma-jasmine-ajax')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

我也尝试添加使用在jasmine.json佣工部分插件。这就是我的jasmine.json文件的样子:

{
    "spec_dir": "spec",
    "spec_files": [
        "**/*[sS]pec.js"
    ],
    "helpers": [
        "helpers/**/*.js",
        "../../../node_modules/jasmine-ajax/lib/mock-ajax.js"
    ],
    "stopSpecOnExpectationFailure": false,
    "random": true
}

有没有人安装了茉莉花AJAX插件成功了吗?

难道是茉莉花AJAX的版本?

jasmine jasmine-ajax
1个回答
0
投票

你是在正确的道路上。您需要安装的类型定义为打字稿:

npm i @types/jasmine-ajax

并且它们包括在E2E / tsconfig.e2e.json:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/e2e",
    "baseUrl": "./",
    "module": "commonjs",
    "target": "es5",
    "types": [
      "jasmine",
      "jasminewd2",
      "node",
      "jasmine-ajax"
    ]
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.