我使用TypeScript 2.5版本和这个环境模块
suncalc
包裹:
// Note: incomplete
// https://www.npmjs.com/package/suncalc
declare module "suncalc" {
interface suncalcResult {
solarNoon: Date;
nadir: Date;
sunrise: Date;
sunset: Date;
sunriseEnd: Date;
sunsetStart: Date;
dawn: Date;
dusk: Date;
nauticalDawn: Date;
nauticalDusk: Date;
nightEnd: Date;
night: Date;
goldenHourEnd: Date;
goldenHour: Date;
}
function sunCalc(date: Date, latitude: number, longitude: number): suncalcResult;
export = { // COMPLAINING HERE <--------------------------- line 24
getTimes: sunCalc
};
}
在TypeScript 2.5中,我得到了一个名为
suncalc.d.ts
编译时没有错误。当我升级到2.6时,它开始责怪:
message: 'The expression of an export assignment must be an identifier or qualified name in an ambient context.'
at: '24,12'
source: 'ts'
然而,在
changelog of TypeScript
环境模块中没有任何变化。
为什么现在不编译?我应该如何在TS2.6中编写导出?