Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 另一个TS7006:参数;X";隐式地有一个";任何;类型–;但不完全如此_Typescript_Typescript Typings_Webdriver Io - Fatal编程技术网

Typescript 另一个TS7006:参数;X";隐式地有一个";任何;类型–;但不完全如此

Typescript 另一个TS7006:参数;X";隐式地有一个";任何;类型–;但不完全如此,typescript,typescript-typings,webdriver-io,Typescript,Typescript Typings,Webdriver Io,我知道有很多关于这个问题的问题/答案,据我所知,我理解它的本质,但我不明白为什么它会发生在我显式设置和控制的类型上 我特意将noImplicitAny设置为true内部tsconfig.json;我知道如果我将其设置为false这个问题就会消失——但我不想这样做……现在:) 代码如下: # ./src/page/base.page.ts export default class BasePage { public open(path: string) { browser.url(pa

我知道有很多关于这个问题的问题/答案,据我所知,我理解它的本质,但我不明白为什么它会发生在我显式设置和控制的类型上

我特意将
noImplicitAny
设置为
true
内部
tsconfig.json
;我知道如果我将其设置为
false
这个问题就会消失——但我不想这样做……现在:)

代码如下:

# ./src/page/base.page.ts
export default class BasePage {
  public open(path: string) {
    browser.url(path);
  }
}


…最后,我的
tsconfig.json
(位于项目的根目录下):

通过该设置,我总是会收到相同的错误消息:

[0-0] RUNNING in chrome - /test/spec/search.engine.spec.ts
0-0 worker error { name: 'TSError',
  message:
   '⨯ Unable to compile TypeScript:\nsrc/page/home-search.page.ts(5,14): error TS7006: Parameter \'term\' implicitly has an \'any\' type.\n',
  stack:
   'TSError: ⨯ Unable to compile TypeScript:\nsrc/page/home-search.page.ts(5,14): error TS7006: Parameter \'term\' implicitly has an \'any\' type.\n\n    at createTSError
...
at Module.load (internal/modules/cjs/loader.js:653:32)' }
[0-0] FAILED in chrome - /test/spec/search.engine.spec.ts

此错误来自
ts节点
。在
wdio.conf.js
中,将
before:function()
更改为:

之前:功能(功能、规格){
require(“ts节点”).register({files:true,transpileOnly:true});
},

还提到了一个与您所经历的非常类似的问题。我在本地删除了您的repo,并成功运行了测试。

该类没有问题,即使错误指向我可以看到的类。是的,这里也一样。这个错误对我来说毫无意义,但肯定有什么问题……IDE中的文件有错误吗?因为我怀疑这与你的测试是如何编译这些文件有关;如果IDE中没有错误,那么无论您的测试通过什么管道运行这些文件,都会出现编译问题
# ./test/spec/search.engine.spec.ts
import HomeSearchPage from "@page/home-search.page";
import { expect } from "chai";

describe("DuckDuckGo (DDG) Search Engine", () => {
  it("Verify search result(s) for given term", () => {
    const expected: string = "WebdriverIO · Next-gen WebDriver test framework for Node.js";
    const input: string = "webdriverio";

    HomeSearchPage.open();
    HomeSearchPage.fillForm(input);
    HomeSearchPage.submit();

    expect($("div#r1-0 h2.result__title a.result__a").getText()).to.contain(expected);
  });
});
{
  "compilerOptions": {
    "alwaysStrict": true,
    "baseUrl": ".",
    "module": "commonjs",
    "paths": {
      "*": ["./*"],
      "@page/*": ["./src/page/*"]
    },
    "removeComments": true,
    "strict": true,
    "target": "es2018",
    "types": [
      "@wdio/mocha-framework",
      "@wdio/sync",
      "@types/chai",
      "@types/mocha",
      "node"
    ],

    //---------------------------------------------------------------------------------------------
    //  Experimental Settings
    //---------------------------------------------------------------------------------------------
    "noImplicitAny": true
  },
  "exclude": ["node_modules/"],
  "include": ["./src/**/*", "./test/**/*"]
}
[0-0] RUNNING in chrome - /test/spec/search.engine.spec.ts
0-0 worker error { name: 'TSError',
  message:
   '⨯ Unable to compile TypeScript:\nsrc/page/home-search.page.ts(5,14): error TS7006: Parameter \'term\' implicitly has an \'any\' type.\n',
  stack:
   'TSError: ⨯ Unable to compile TypeScript:\nsrc/page/home-search.page.ts(5,14): error TS7006: Parameter \'term\' implicitly has an \'any\' type.\n\n    at createTSError
...
at Module.load (internal/modules/cjs/loader.js:653:32)' }
[0-0] FAILED in chrome - /test/spec/search.engine.spec.ts