ビジュアルスタジオコードでnpmテストを使用して分度器テストを実行しているときにエラーが発生しましたが、node_modules/@types/jasmine/index.d.ts
の問題のようですが、続きnpmテストでは分度器タイプスクリプトを実行中にエラーがスローされる
C:\MyFiles\NewTechonologies\Protractor\TypeScript\Test>npm test
> [email protected] pretest C:\MyFiles\NewTechonologies\Protractor\TypeScript\Test
> npm run tsc
> [email protected] tsc C:\MyFiles\NewTechonologies\Protractor\TypeScript\Test
> tsc
node_modules/@types/jasmine/index.d.ts(26,41): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(27,39): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(152,24): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(334,14): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(435,24): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(448,30): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(448,30): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasminewd2/index.d.ts(23,13): error TS2428: All declarations of 'Matchers' must have identical ty
pe parameters.
node_modules/@types/jasminewd2/index.d.ts(47,13): error TS2430: Interface 'ArrayLikeMatchers<T>' incorrectly extends
interface 'Matchers<ArrayLike<T>>'.
Types of property 'toBe' are incompatible.
Type '(expected: any, expectationFailOutput?: any) => Promise<void>' is not assignable to type '{ (expected: any,
expectationFailOutput?: any): boolean; (expected: any, expectationFailOutput?: ...'.
Type 'Promise<void>' is not assignable to type 'boolean'.
node_modules/@types/jasminewd2/index.d.ts(48,20): error TS2304: Cannot find name 'Expected'.
node_modules/@types/jasminewd2/index.d.ts(49,23): error TS2304: Cannot find name 'Expected'.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "
run" "tsc"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] tsc: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] tsc script 'tsc'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the example-typescript package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs example-typescript
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls example-typescript
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\MyFiles\NewTechonologies\Protractor\TypeScript\Test\npm-debug.log
npm ERR! Test failed. See above for more details.
C:\MyFiles\NewTechonologies\Protractor\TypeScript\Test>
は、私はVisual Studioのコードで
package.json
{
"name": "example-typescript",
"version": "1.0.0",
"description": "a typescript example",
"author": "",
"license": "MIT",
"scripts": {
"tsc": "tsc",
"pretest": "npm run tsc",
"test": "C:/Users/skp/AppData/Roaming/npm/node_modules/protractor/bin/protractor tmp/conf.js",
"debug": "node --inspect --debug-brk C:/Users/skp/AppData/Roaming/npm/node_modules/protractor/bin/protractor asyncAwait/conf.js"
},
"dependencies": {
"@types/jasmine": "2.5.41",
"@types/jasminewd2": "^2.0.0",
"jasmine": "^2.4.1",
"protractor": "C:/Users/skp/AppData/Roaming/npm/node_modules/protractor/bin/protractor",
"typescript": "~2.0.0"
},
"devDependencies": {
"@types/jasminewd2": "^2.0.0",
"ts-node": "^3.0.2"
}
}
spec.ts
をtypescriptですし、ジャスミンフレームワークと分度器を実行するために使用しているファイルですimport {browser, element, by, By, $, $$, ExpectedConditions} from 'protractor';
describe('protractor with typescript typings',() => {
beforeEach(() => {
browser.get('http://www.angularjs.org');
});
it('should greet the named user',() => {
element(by.model('yourName')).sendKeys('Julie');
let greeting = element(by.binding('yourName'));
expect(greeting.getText()).toEqual('Hello Julie!');
});
it('should list todos', function() {
let todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(2);
expect(todoList.get(1).getText()).toEqual('build an angular app');
});
});
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"inlineSourceMap": true,
"declaration": false,
"noImplicitAny": false,
"outDir": "tmp"
},
"exclude": [
"node_modules",
"asyncAwait",
"plugins.ts"
]
}
nodejsバージョンは使用していますか? '@ types/jasminewd2'モジュールを複数持っています –
ノードバージョン - 6.10.3、 @node_modules/@ types/jasmine_フォルダしかないことを確認したので、複数の' @ types/jasminewd2'については考えません。 – sunpat
あなたが投稿したpackage.jsonに複数の '@ types/jasminewd2'があります。最新のジャスミンタイプをインストールしてください - ' npm install -S @ types/jasmine @ latest' –