Web Analytics

Declaration Files

Advanced~18 min

Declaration files (.d.ts) provide type information for JavaScript libraries, enabling TypeScript support.

Declaration Files

Output
Click Run to execute your code
DefinitelyTyped: Community repository of type definitions at @types/*
Best Practice: Use @types packages for popular libraries. Create custom .d.ts for internal JS code.

Summary

  • Declaration files end in .d.ts
  • Provide types for JavaScript
  • Use declare keyword
  • DefinitelyTyped has thousands of types