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

Add "typings" field to package.json #251

Closed
letmaik opened this issue Aug 8, 2016 · 5 comments
Closed

Add "typings" field to package.json #251

letmaik opened this issue Aug 8, 2016 · 5 comments
Labels

Comments

@letmaik
Copy link

letmaik commented Aug 8, 2016

The package.json file should contain a "typings" field as described here. Then IDEs like Visual Studio Code will automatically find the typing information.

So, that should be:

"typings": "lib/chevrotain.d.ts"
@bd82
Copy link
Member

bd82 commented Aug 9, 2016

Thanks @letmaik I was not aware of this.

I've looked at the docs you listed and related issues on the TypeScript github page.
What I'm trying to figure out is if I now need to have two separate d.ts files published with chevrotain. one for external modules and one for global usage...

Because If I understand correctly the

declare module "chevrotain" {}

needs to be removed as well.

Hopefully it is enough to just change Chevrotain's d.ts to use one the modern module template
As I am currently using an older style of d.ts template that I saw used on definitely typed.

Did the existing chevrotain.d.ts work on VSCode after you have manually added the "typings" property ?

@bd82
Copy link
Member

bd82 commented Aug 9, 2016

I've tried doing as you have suggested.
The current chevrotain.d.ts format is not compatible with this.
You can see the logs in the failing build.

https://travis-ci.org/SAP/chevrotain/jobs/150854082

src/examples/json/api.ts(8,8): error TS2656: Exported external package typings file '/home/travis/build/SAP/chevrotain/examples/language_services/node_modules/chevrotain/lib/chevrotain.d.ts' is not a module. Please contact the package author to update the package definition.

it does work with the new UMD module template syntax.
But this syntax only works with Typescript 2 which is still in beta.

I do not think it is worth the bother right now to create another hacked d.ts file (or more than one).
Because Typescript 2 is supposed to be released "soon" so then a "standard" solution can be used.

I will try to create a push request that solves this (using typescript 2 beta) but will only merge once
the typescript 2 is officially released.

bd82 added a commit that referenced this issue Aug 9, 2016
Uses UMD module syntax which only works with typescript 2+

Use typings property in package.json

relates to #251
@letmaik
Copy link
Author

letmaik commented Aug 9, 2016

Thanks for investigating this! I don't have much experience with definition files myself yet. Your plan sounds good, version 2 is just a few weeks away. As a work-around, it seems to be enough to just copy the chevrotain.d.ts file somewhere in the project so that the compiler finds it.

@bd82
Copy link
Member

bd82 commented Aug 9, 2016

@letmaik No Problem.

And thanks for the feedback. now I know about the "typings" package.json property
and how to make usage of Chevrotain easier in the near future. 😄

@bd82 bd82 added the Blocked label Aug 10, 2016
@bd82 bd82 removed the Blocked label Sep 24, 2016
@bd82
Copy link
Member

bd82 commented Sep 24, 2016

fixed in
#280

will be available in next version.

@bd82 bd82 closed this as completed Sep 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants