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

Typescript types definition location #17

Open
emersonlaurentino opened this issue Jan 14, 2020 · 6 comments
Open

Typescript types definition location #17

emersonlaurentino opened this issue Jan 14, 2020 · 6 comments
Labels
discussion Something isn't working practices/patterns stale This will not be worked on

Comments

@emersonlaurentino
Copy link
Member

What is to be discussed?
Typescript types definition location.

Describe the solution you'd like
Create a declaration file when they are common between files, otherwise leave inside the file itself. But never create global types.

Additional context
There are developers who declare types within the file itself and export to other files, there are others who like global types and others who define them in a declaration file.

@jgfidelis
Copy link

jgfidelis commented Jan 14, 2020

I prefer to use declaration files as well if types are shared across multiple files

@kaisermann
Copy link
Contributor

It's always better to have separate declaration files. However, how those typings are going to be used defines if it's better to put them in a .d.ts or .ts file.

My rule of thumb is: is the typings supposed to be consumed by other apps/libs? .ts and import them where needed. If you only need them to type your project, .d.ts and use them globally.

@kaisermann kaisermann added the discussion Something isn't working label Jan 14, 2020
@emersonlaurentino
Copy link
Member Author

@kaisermann honestly i don't like global types. @salesfelipe has an opinion on the use of enum when in global types...

@kaisermann
Copy link
Contributor

@emersonlaurentino probably because he needed the enum elsewhere, so .ts with explicit imports would be the way to go. I don't think we need to write in stone that you SHOULD NEVER USE GLOBAL TYPINGS, but one must be aware of the caveats of the approach.

@stale
Copy link

stale bot commented Jan 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is a discussion thread, the most voted option will be final. Thank you for your contributions.

@stale stale bot added the stale This will not be worked on label Jan 21, 2020
@stale stale bot removed the stale This will not be worked on label Jan 22, 2020
@stale
Copy link

stale bot commented Jan 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is a discussion thread, the most voted option will be final. Thank you for your contributions.

@stale stale bot added the stale This will not be worked on label Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Something isn't working practices/patterns stale This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants