与TypeScript结合使用ES6 + system.js来创建声明性类.d.ts,其中描述的类可以用于扩展自定义类吗?
或者解释一下这个问题,如何使这段代码有效?
some.d.ts
declare module SOME {
export class SomeSuperClass{
constructor();
execute();
}
export class SomeSubClass{
constructor();
execute();
}
}
declare module 'some.js' {
export = SOME;
}
main.ts
export class Main {
constructor() {
console.log('typescript main ');
new Test();
}
}
test.ts
import SOME from 'some.js';
export default class Test extends SOME.SomeSuperClass{
constructor() {
super();
}
}
答案 0 :(得分:1)
您的文件存在一些问题:
以下是应该写的文件:
some.d.ts
export module SOME {
export class SomeSuperClass{
constructor();
execute();
}
export class SomeSubClass{
constructor();
execute();
}
}
main.ts
import Test from 'test';
export class Main {
constructor() {
console.log('typescript main ');
new Test();
}
}
test.ts
import {SOME} from 'some';
export default class Test extends SOME.SomeSuperClass{
constructor() {
super();
}
}