Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automate discovery of ts typings for non-default imports #200

Closed
vladmandic opened this issue Oct 22, 2021 · 1 comment
Closed

automate discovery of ts typings for non-default imports #200

vladmandic opened this issue Oct 22, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@vladmandic
Copy link
Owner

automate discovery of ts typings for non-default imports

when using named import like:

import { Human } from '@vladmandic/human/dist/human.custom.esm';

tsc complains:

Cannot find module '@vladmandic/human/dist/human.custom.esm' or its corresponding type declarations.

issue is like simply that tsc doesnt know where to look for them

easiest thing is to create human.d.ts with:

declare module '@vladmandic/human/dist/human.custom.esm' {
  export * from '@vladmandic/human/types/src/human';
}

and reference it in tsconfig.json

    "typeRoots": ["src/"] // whereever human.d.ts resides

there should be a nice way to automate this

@vladmandic vladmandic added the enhancement New feature or request label Oct 22, 2021
@vladmandic vladmandic self-assigned this Oct 22, 2021
@vladmandic
Copy link
Owner Author

added generic human.d.ts that re-exports types for all human variations
when using named imports and tsc complains about it cannot find type declarations, simply add line

/// <reference path='../node_modules/@vladmandic/human/dist/human.d.ts' />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant