这可能是我的一个误解。在Typescript 1.4中,我们使用导出类,但是当我将代码更新为typescript 1.5时,行为发生了变化。
以下是它在TS 1.4中的工作原理
LanguageForm.ts
import AbstractForm = require('../components/AbstractForm');
class LanguageForm extends AbstractForm {
buildPanel(){
}
}
export = LanguageForm;
根据我对TS 1.5的理解,语法需要修改为:
import AbstractForm from '../components/AbstractForm';
export default class LanguageForm extends AbstractForm {
buildPanel(){
}
}
使用TS1.4我只需在new
上拨打电话就可以在动态设置中工作:
require(["LanguageForm"], (Form) => {
new Form()
});
现在在TS 1.5我需要做:
require(["LanguageForm"], (Form) => {
new Form.default()
});
我的问题
在所有示例中,我发现文档是导出/导入模块。这是导出/导入类的方法吗?我可以摆脱.default
吗?
答案 0 :(得分:10)
In all the example I found the documentation was exporting/importing modules. Is that the way to export/import classes
Don't use SUM(CONVERT(DECIMAL(8,2),[can]/1.2)) + SUM(CONVERT(DECIMAL(8,2),[carton]/1.2)) AS [N],
(SUM(CONVERT(DECIMAL(8,2),[can]/1.2)) + SUM(CONVERT(DECIMAL(8,2),[carton]/1.2)))*0.2 AS [V]
. Instead export:
export =
And import:
export class LanguageForm extends AbstractForm {
buildPanel(){
}
}