我現在遇到的問題與ES6模塊默認導入:打字稿1.5:CommonJS的「出口=」(?.d.ts唯一的問題)
import moment from 'moment';
moment
本身就是一個功能是默認CommonJS的出口,這裏編碼https://github.com/borisyankov/DefinitelyTyped/blob/master/moment/moment.d.ts:
interface MomentStatic {
(): Moment;
(date: number): Moment;
...
}
declare var moment: moment.MomentStatic;
declare module 'moment' {
export = moment;
}
下似乎不工作:
import * from 'moment';
// error TS1005: 'as' expected.
// error TS1005: 'from' expected.
import moment from 'moment';
// error TS1192: External module ''moment'' has no default export.
import {default as moment} from 'moment';
// error TS2305: Module ''moment'' has no exported member 'default'.
require語法仍然有效......但我試圖避免這種情況。
import moment = require('moment');
想法?
鏈接複製的語法? –