-
Notifications
You must be signed in to change notification settings - Fork 26
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 declarations #46
Comments
@sbliven thanks for the interest. Sure, method 1 will work well, I will be glad to approve the PR. |
is there an update on this? |
@nstringham PR welcome. |
I haven't worked on my chromonaut project in years now. I will probably not get around to a PR unless someone really needs it. I guess my previous definition file will need to be updated somewhat. |
There's an attempt at providing types that unfortunately doesn't seem was very successful, so I will put some R&D here. @ahocevar your approach enables intellisense, but it doesn't solve this: Consuming scenarios:
CJS is out of equation. Ways to define types:
It seems 5. is the most reasonable way. |
Option 3 will work fine with the |
Like I said - current master referenced in a project as npm dependency does NOT work, because of the missing |
Sorry, I just saw you pushed another commit to master. I'm testing right now. |
But you're right: individual module imports have missing types: And the reason for that is the missing "types": "./dist/color-space.d.ts", That would have been solved with #59, i.e. with individual .d.ts files. Another solution would be to define |
So, to summarize: what @sbliven suggested in 2018 (!) was basically what @MoonE contributed in #57. It was not merged, despite being a solid contribution. The .d.ts files could also have been published as #62 now suggests a solution similar to option 1 suggested by @sbliven. It works well, but @dy does not like the JSDoc comments any more (merged with #58), which are used to auto-generate the types. @dy states also that they do not like to bring in any tooling. Fun fact: The tooling used in #62 is just the TypeScript compiler, nothing else. On the other hand, @dy uses jsbuild (previously rollup) for auto-generating the |
I am still open to making #57 a @types/color-space. If you want to do that @ahocevar - please make a favour. I just don't have time span atm, but I can also do that later. |
Ok, I started work on manual type declarations here. Since https://github.com/DefinitelyTyped/DefinitelyTyped is monorepo, we have to store these declarations somewhere, so |
I am interested in using color-space in a typescript project. To this end I have created type declarations for the library (https://github.com/sbliven/chromanaut/blob/master/color-space.d.ts). I would like to make these available to other projects. This can be done in a few ways depending on the desired integration with the javascript color-space package.
Include
index.d.ts
in the package directory. This has the benefit of keeping the type definitions and the javascript in the same repository, so the versions should always match. However, it would require that new pull requests modify the index.d.ts file to reflect any changes to the javascript API.Type declarations can be included in the DefinitelyTyped repository. This makes the process independent of the maintainers here, but runs a greater risk that the type information will be out of date.
Both methods are widely used. I'm happy to help maintain the declarations regardless of which approach is preferred by the community here.
The text was updated successfully, but these errors were encountered: