Skip to content

Instantly share code, notes, and snippets.

@inomdzhon
Last active July 26, 2019 15:11
Show Gist options
  • Save inomdzhon/8dcb061f62dea3f0e1748c949217c93e to your computer and use it in GitHub Desktop.
Save inomdzhon/8dcb061f62dea3f0e1748c949217c93e to your computer and use it in GitHub Desktop.

Прелюдия

Назовём пакет example.

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "src",
    "jsx": "react",
    "target": "esnext",
    "module": "esnext",
    "declaration": true,
    "outDir": "dist",
    "strict": true,
    "typeRoots": ["./node_modules/@types"]
  },
  "exclude": ["node_modules", "lib"],
  "include": ["./src/**/*.ts", "./src/**/*.tsx"]
}

index.ts

export { platform } from 'utils/platform';

При сборке в папку dist попадает файл index.d.ts

export { platform } from 'utils/platform';

Итог

/example
  /dist
    /utils
      /platform.d.ts
    /index.d.ts
    /index.js   
  /src
    /utils
      /platform.ts
    /index.ts

Проблема

import { platform } from 'example';

platform.isIOS() <- Cannot find declaration to go to

Но вот если прописать относиьтельный путь, то будет работать (index.ts)

export { platform } from './utils/platform'; <- относительный путь

Вопрос

Как мне быть если я не хочу везде писать относительные пути? (edited)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment