0
我有2個打字稿文件。一個實現SourceContext類:只有默認的構造函數接受打字稿類
export class SourceContext {
constuctor(sourceId: string) {
this._sourceId = sourceId;
}
...
}
,並在其他文件我想用這個出口類(這兩個文件是在我的NodeJS模塊相同的文件夾):
import { SourceContext } from './SourceContext';
export class Service {
public load(file: string) {
var context = new SourceContext(file);
}
}
但是我得到的錯誤:
file: 'file:///...../src/index.ts' severity: 'Fehler' message: 'Supplied parameters do not match any signature of call target.'
當我刪除file
參數,則不會出現錯誤。爲什麼它不識別我定義的構造函數,我該如何解決它?
您的代碼看起來不錯,但你不應該得到這個錯誤。這是你想要準確編譯的嗎?另外,你如何建立這個?這個錯誤信息是什麼?什麼是「嚴重性:'費勒'」? –
此錯誤消息實際上來自vscode,它被設置爲德語本地化。這個服務器在這裏不相關。在我的nodejs模塊的根目錄下運行'tsc'時,我也得到了完全相同的錯誤。 –