gpt4 book ai didi

angular - 类型 'MonoTypeOperatorFunction' 不可分配给类型为“OperatorFunction”的参数

转载 作者:行者123 更新时间:2023-12-02 02:46:34 25 4
gpt4 key购买 nike

我正在尝试进行剑道聊天示例:https://www.telerik.com/kendo-angular-ui/components/conversationalui/
我使用 Visual Studio 代码和 angular 6,我在谷歌搜索但找不到解决方案
但我收到了这个错误:

ERROR in src/app/app.component.ts(68,7): error TS2345: Argument of type 'MonoTypeOperatorFunction' is not assignable to parameter of type 'OperatorFunction'. Types of parameters 'source' and 'source' are incompatible. Type 'Observable' is not assignable to type 'Observable'. Type 'Message' is not assignable to type 'any[]'. Property 'length' is missing in type 'Message'.



我的组件是:
import { Component } from '@angular/core';    
import { Subject } from 'rxjs/Subject';
import { switchMap } from 'rxjs/operators/switchMap';
import { map } from 'rxjs/operators/map';
import { windowCount } from 'rxjs/operators/windowCount';
import { scan } from 'rxjs/operators/scan';
import { take } from 'rxjs/operators/take';
import { tap } from 'rxjs/operators/tap';
import { from } from 'rxjs/observable/from';
import { merge } from 'rxjs/observable/merge';

import { ChatModule, Message, User, Action, ExecuteActionEvent, SendMessageEvent } from '@progress/kendo-angular-conversational-ui';
import { Observable } from 'rxjs/Observable';
import { ChatService } from './chat.service';

@Component({
providers: [ ChatService ],
selector: 'my-app',
template: `
<kendo-chat
[messages]="feed | async"
[user]="user"
(sendMessage)="sendMessage($event)"
>
</kendo-chat>
`
})
export class AppComponent {
public feed: Observable<Message[]>;

public readonly user: User = {
id: 1
};

public readonly bot: User = {
id: 0
};

private local: Subject<Message> = new Subject<Message>();

constructor(private svc: ChatService) {
const hello: Message = {
author: this.bot,
suggestedActions: [{
type: 'reply',
value: 'Neat!'
}, {
type: 'reply',
value: 'Thanks, but this is boring.'
}],
timestamp: new Date(),
text: 'Hello, this is a demo bot. I don\t do much, but I can count symbols!'
};

// Merge local and remote messages into a single stream
this.feed = merge(
from([ hello ]),
this.local,
this.svc.responses.pipe(
map((response): Message => ({
author: this.bot,
text: response
})
))
).pipe(
// ... and emit an array of all messages
scan((acc, x) => [...acc, x], [])
);
}

public sendMessage(e: SendMessageEvent): void {
this.local.next(e.message);

this.local.next({
author: this.bot,
typing: true
});

this.svc.submit(e.message.text);
}
}

我收到错误的行代码是:
scan((acc, x) => [...acc, x], [])

最佳答案

我也遇到了具体问题。尝试以下修复:

scan((acc:any, x) => acc.concat(x), [])

另见: https://github.com/ReactiveX/rxjs/pull/2897#issuecomment-334654459

关于angular - 类型 'MonoTypeOperatorFunction<any[]>' 不可分配给类型为“OperatorFunction<Message, any[]>”的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54406225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com