user12700434
user12700434

Reputation:

When we use declare and export keyword in TypeScript?

In ts file I see declaration of interface:

declare interface BlockForm {
}

But in others places I see declaration as:

export interface BlockFormField {
}

What is difference, when we should use declare interface and export interface?

Upvotes: 1

Views: 437

Answers (1)

Michael Ceber
Michael Ceber

Reputation: 2452

So the export keyword is specifcially to make the interface available to other files.

The declare keyword is not required, however, if used like how you used it then the interface will not be available exernally without the export keyword.

I guess this also works but I don't think declare is adding any value:

export declare interface BlockForm

Upvotes: 2

Related Questions