Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 517 Bytes

typescript_organization.md

File metadata and controls

31 lines (24 loc) · 517 Bytes

Use typescript aliases

Create prettier imports by defining the paths and baseUrl properties in the compilerOptions section in the tsconfig.json

This will avoid long relative paths when doing imports.

Bad:

import { UserService } from '../../../services/UserService';

Good:

import { UserService } from '@services/UserService';
// tsconfig.json
...
  "compilerOptions": {
    ...
    "baseUrl": "src",
    "paths": {
      "@services": ["services/*"]
  }
    ...
  }
...