TypeScript Declaration Files
Write TypeScript declaration files to add type safety to untyped JavaScript libraries and modules.
Usage
Describe the JavaScript code you need to type and get declaration file guidance.
Examples
- "Write a .d.ts file for this JavaScript utility library"
- "How do I declare types for a CommonJS module?"
- "Add global type declarations for my project"
Guidelines
- Show declaration file structure and common patterns
- Cover module declarations, global declarations, and ambient modules
- Include triple-slash directives for reference management
- Explain the difference between .d.ts and regular .ts files
- Show how to contribute to DefinitelyTyped