<!--
title: Organize type declarations
domain: cloud-infra
topic: Code Style
language: TypeScript
source: aws/aws-sdk-js
updated: 2016-10-29
url: https://awesomereviewers.com/reviewers/aws-sdk-js-organize-type-declarations/
-->

Structure TypeScript declarations to improve maintainability and developer experience. Organize related types into appropriate namespaces and use inheritance to avoid duplication.

For service interfaces, place shape definitions in a dedicated sub-namespace to prevent cluttering code completion:

```typescript
// Instead of this:
declare namespace ACM {
  interface AddTagsToCertificateRequest { /*...*/ }
  interface ListCertificatesResponse { /*...*/ }
  // More interfaces...
}

// Do this:
declare namespace ACM {
  // Service properties here
}
declare namespace ACM.Types {
  interface AddTagsToCertificateRequest { /*...*/ }
  interface ListCertificatesResponse { /*...*/ }
  // More interfaces...
}
```

For common properties shared across multiple interfaces or classes, use inheritance or abstract classes instead of duplicating definitions:

```typescript
// Instead of duplicating the same properties in multiple places:
interface ConfigurationOptions {
  // properties and comments
}
class Config {
  // Same properties and comments duplicated
}

// Use inheritance to share definitions:
abstract class BaseConfig {
  // Shared properties with comments
}
class Config extends BaseConfig {
  // Additional properties specific to Config
}
```

This approach improves code completion accuracy, reduces maintenance overhead, and creates a more intuitive API structure.
