c# - 带有角度错误的 web api
问题描述
import { browser, element, by } from 'protractor';
describe('QuickStart E2E Tests', function () {
let expectedMsg = 'Hello Angular';
beforeEach(function () {
browser.get('');
});
it('should display: ' + expectedMsg, function () {
expect(element(by.css('h1')).getText()).toEqual(expectedMsg);
});
});
import { Operator } from './Operator';
import { Observer } from './Observer';
import { Observable } from './Observable';
import { Subscriber } from './Subscriber';
import { ISubscription, Subscription } from './Subscription';
/**
* @class SubjectSubscriber<T>
*/
export declare class SubjectSubscriber<T> extends Subscriber<T> {
protected destination: Subject<T>;
constructor(destination: Subject<T>);
}
/**
* @class Subject<T>
*/
export declare class Subject<T> extends Observable<T> implements ISubscription {
observers: Observer<T>[];
closed: boolean;
isStopped: boolean;
hasError: boolean;
thrownError: any;
constructor();
static create: Function;
lift<R>(operator: Operator<T, R>): Observable<T>;
next(value?: T): void;
error(err: any): void;
complete(): void;
unsubscribe(): void;
protected _subscribe(subscriber: Subscriber<T>): Subscription;
asObservable(): Observable<T>;
}
/**
* @class AnonymousSubject<T>
*/
export declare class AnonymousSubject<T> extends Subject<T> {
protected destination: Observer<T>;
constructor(destination?: Observer<T>, source?: Observable<T>);
next(value: T): void;
error(err: any): void;
complete(): void;
protected _subscribe(subscriber: Subscriber<T>): Subscription;
}
我刚刚使用 Angular 打开了一个新的 web api 项目。这是我第一次使用 Angular。我按照本指南工作:https ://angular.io/guide/visual-studio-2015 但我遇到了错误。有谁知道如何解决这个问题?谢谢!
错误1:
严重性代码 描述 项目文件行抑制状态错误 TS2416 (TS) 类型“主题”中的属性“提升”不能分配给基本类型“可观察”中的相同属性。类型 '(operator: Operator) => Observable' 不可分配给类型 '(operator: Operator) => Observable'。类型“Observable”不可分配给类型“Observable”。类型“T”不能分配给类型“R”。C:\Users\איתי\source\repos\Ctaxi - WeWorkShop\Ctaxi - WeWorkShop\src(tsconfig 或 jsconfig 项目) C:\Users\איתי\source\repos\Ctaxi - WeWorkShop\Ctaxi - WeWorkShop\node_modules\rxjs\Subject .d.ts 24 活动
错误2:
严重性代码 描述 项目文件行抑制状态错误 TS2559 (TS) 类型“By”与类型“Locator”没有共同的属性。C:\Users\איתי\source\repos\Ctaxi - WeWorkShop\Ctaxi - WeWorkShop\e2e(tsconfig 或 jsconfig 项目) C:\Users\איתי\source\repos\Ctaxi - WeWorkShop\Ctaxi - WeWorkShop\e2e\app.e2e -spec.ts 12 活动
解决方案
对于错误 2:需要对“by.css('h1'))”进行强制转换并导入定位器
import { browser, element, by } from 'protractor';
import { By } from 'selenium-webdriver';
import { Locator } from 'protractor/built/locators';
describe('QuickStart E2E Tests', function () {
let expectedMsg = 'Hello Angular';
beforeEach(function () {
browser.get('');
});
it('should display: ' + expectedMsg, function () {
expect(element(<Locator>by.css('h1')).getText()).toEqual(expectedMsg);
});
});
推荐阅读
- c++ - 如何使用 Modbus TCP 连接观察器
- docker - 镜像构建问题 docker meteor
- docker - WSL2 Dockerfile 未构建 - DNS 问题
- c++ - 如何在 C++ 中访问命名空间中的类成员函数
- arrays - 需要帮助解决 C 中的 0/1 背包问题,具有最高“价值”解决方案,但最少“重量”相同(最高)“价值”
- c# - 如何在 C# 中的 httpclient 中设置响应标头?
- google-admin-sdk - Google Workspaces 用户 Drives API 用于查看文件活动
- python - 如何获取具有特定标签和属性的子元素的xml元素
- python - ModuleNoFound 错误,同时使用 num2words
- javascript - 无法使用 ejs 路由某些站点