2016-12-28 115 views
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参数,则不会出现错误。为什么它不识别我定义的构造函数,我该如何解决它?

+0

您的代码看起来不错,但你不应该得到这个错误。这是你想要准确编译的吗?另外,你如何建立这个?这个错误信息是什么?什么是“严重性:'费勒'”? –

+0

此错误消息实际上来自vscode,它被设置为德语本地化。这个服务器在这里不相关。在我的nodejs模块的根目录下运行'tsc'时,我也得到了完全相同的错误。 –

回答

3

您的代码中有DO'H。

export class SourceContext { 
    constuctor(sourceId: string) { 
     this._sourceId = sourceId; 
    } 
... 
} 

变化constuctor构造

+0

O M G,,。 o O(该死的js) –