我有一个TypeScript类文件: class SomeClass {
public load(): void {
console.log('loaded');
}
} 另一个ts文件,主要是函数,想要使用这个类: // declare it
declare var SomeClass;
function useIt() {
const c = new SomeClass();
c.load();
} 在Visual Studio2019中,它告诉我SomeClass是重复的(例如,在declare var SomeClass行)。仍会生成.js,
我很可能做了一些非常错误的事情,但我不知道是什么。
在我的自定义规则中,我检查节点的SyntaxKind来控制我的流,如下所示:
import * as ts from "typescript"
function processPropertyName(pn: ts.PropertyName) {
switch (pn.kind) {
case ts.SyntaxKind.Identifier:
case ts.SyntaxKind.StringLiteral:
//doX
break