0

So, as I know there are several ways to use interfaces in TypeScript:

  • Declare interfaces in d.ts files and than use them in .ts files
    without import

    Declare interaces in .ts files and import them when we need them

What is best practice to do? Use .d.ts or stick to the import in my own TS project?

Thanks!

Nikita Shchypyplov
  • 1,090
  • 1
  • 9
  • 18

1 Answers1

1

Normally, you'll want to use *.d.ts files when they are part of an external dependency. Most NPM packages come pre-compiled in JavaScript and ship *.d.ts files to allow your IDE and the TypeScript compiler to work properly.

When you work in your own project and the files you are referencing are part of that project, you'll want to directly use the *.ts files.

fjc
  • 5,590
  • 17
  • 36