Home > Software engineering >  TypeScript - Describe function declared inside namespace?
TypeScript - Describe function declared inside namespace?

Time:07-12

If I have a namespace in global.d.ts with a function inside:

declare namespace MY_NAMESPACE {
  function doSomething(): void
}

How can I describe that function then?

CodePudding user response:

The purpose of a d.ts file isn't to create a runnable function. It is only used to describe the types of a module that does not have any.

For example: Module A is a pure JavaScript package, but you want to use it strongly typed in your TypeScript project. If that is the case, you write a d.ts file for that module.

TypeScript Documentation: Modules .d.ts

  • Related