← Back to Tutorial
TypeScript Compiler
TypeScript Code
Clear
Compile ▶
// Declaration file example for a JavaScript library // weather.js - external JavaScript library declare function getCurrentWeather(city: string): { temperature: number; conditions: string; humidity: number; }; declare function getForecast(city: string, days: number): Array<{ date: string; temp: number; }>; // Using in TypeScript const weatherData = getCurrentWeather("New York"); const forecast = getForecast("London", 5); console.log(weatherData.temperature); console.log(forecast[0].date);
Output
Download JS
TypeScript code will be compiled here