I was using TypeScript version 2.5 with this ambient module for suncalc package:
// 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
};
}
In TypeScript 2.5, I got this file called suncalc.d.ts and compiled with no error. When I upgraded to 2.6, it started to blame:
message: 'The expression of an export assignment must be an identifier or qualified name in an ambient context.'
at: '24,12'
source: 'ts'
However, in the changelog of TypeScript there is nothing about changes in ambient modules.
Why is not compiling now? How should I write the export in TS2.6?