簡體   English   中英

預期 0 個類型參數,但得到 1 個

[英]Expected 0 type arguments, but got 1

我在 type.ts 中有一個接口 ConfState,我在 app.ts 中導入了接口 ConfState,當我嘗試使用它時,出現此錯誤。 預期 0 類型參數,但得到 1。

**type.ts


 export interface ConfState { }

**app.ts


 import {BotFrameworkAdapter,MemoryStorage,ConversationState} from "botbuilder"; import * as restify from "restify"; import {ConfState} from "./types"; let server = restify.createServer(); server.listen(process.env.port || process.env.PORT || 3978,() => { console.log("${server.name} listening on {server.url}"); }); const adapter = new BotFrameworkAdapter({ appId:process.env.MICROSOFT_APP_ID, appPassword:process.env.MICROSOFT_APP_PASSWORD }); const conversationState = new ConversationState<ConfState>(new MemoryStorage()); adapter.use(conversationState) server.post("/api/message",(req, res) => { adapter.processActivity(req,res, async (context) => { if(context.activity.type === "message") { const state = conversationState.get(context); await context.sendActivity("You said ${context.activity.text}"); } else { await context.sendActivity("${context.activity.type} event detected"); } }); });

刪除通用 . 庫的更新不再需要 ConversationState 來獲取泛型。

而是使用這個:

let conversationState;

const memoryStorage = new MemoryStorage();
conversationState = new ConversationState(memoryStorage);

由於您沒有將類型參數傳遞給其他類型,因此ConversationState必須沒有類型參數,因此會出現錯誤。

new ConversationState<ConfState>
// should be changed to 
new ConversationState

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM