3
我要聲明一個類型是這樣的:如何在typescript中聲明一個Map類型?
interface DependData {[key: string]: string};
但錯誤是這樣的:
Statements are not allowed in ambient contexts
我要聲明一個類型是這樣的:如何在typescript中聲明一個Map類型?
interface DependData {[key: string]: string};
但錯誤是這樣的:
Statements are not allowed in ambient contexts
你所描述的錯誤消息的定義文件發生。
爲了使這項工作,你需要使用正確的語法,並在您的接口聲明的末尾刪除分號:
interface DependData {
[key: string]: string;
}