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

Manage TypeScript declaration files using npm #162

Merged
merged 1 commit into from
Oct 3, 2016
Merged

Manage TypeScript declaration files using npm #162

merged 1 commit into from
Oct 3, 2016

Conversation

olgertse
Copy link
Contributor

@olgertse olgertse commented Sep 29, 2016

TODO:

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

TypeScript 2 made it easier to install declaration files using npm.

Moving all the declaration file dependencies from typings to npm solves the problem where you have to install all the definitions manually (issue #124).

Now you just have to npm install apollo-server into your TS project and it just works, except for graphql definitions, those still need to be installed using the typings utility. Couldn't get them to work by installing from npm, for some reason.

Note: Running npm install in an existing project will probably case duplicate definition errors with the typings directory. To resolve that just delete the typings directory and run typings install to install the graphql definitions.

Also, having @types/chai in devDependencies resulted in missing type definition when compiling project that is depending on apollo-server. Thats why it's in dependencies section.

@apollo-cla
Copy link

@od1k: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@helfer
Copy link
Contributor

helfer commented Sep 30, 2016

@od1k cool! I think there's even a typed-graphql npm package that we could use (same content as the github repo), which would make the typings install step completely unnecessary. We used it in graphql-tools.

@olgertse
Copy link
Contributor Author

For some reason, when typed-graphql was installed from npm, the compiler was complaining about missing types. But I will take another look at this problem in the evening. Completely getting rid of 'typings install' would be really nice.

@DxCx
Copy link
Contributor

DxCx commented Sep 30, 2016

@od1k to use typed-graphql package you just need to state it in tsconfig.
example

@olgertse
Copy link
Contributor Author

olgertse commented Sep 30, 2016

Thanks @DxCx!
I've tried your suggestion but run into a couple of problems.
It seems that having types inside compilerOptions disables automatic searching of types. At least something breaks, because I had to add mocha to the list as well to get it to compile.

But even when I got it working there was still one issue remaining. When you npm install apollo-server into a project it does not compile because of all the graphql types missing.

The only way I could get it to work without having to do any additional steps after npm install is by having a new file typings.d.ts with /// <reference types="typed-graphql" />, just as the typed-graphql GitHub readme states.
While this does work, it feels like a hack and I'm not sure if I should push those changes.

Ideal scenario would be for typed-graphql to be published to npm ~types.

@DxCx
Copy link
Contributor

DxCx commented Oct 1, 2016

ok @od1k cool.
so please note this PR (DefinitelyTyped/DefinitelyTyped#11598)
which will give you @types/graphql package.

@olgertse
Copy link
Contributor Author

olgertse commented Oct 1, 2016

Nice! I guess we wait until it becomes available on npm.

@DxCx
Copy link
Contributor

DxCx commented Oct 1, 2016

@od1k i think it might take some time, IMO using the typings file can work in the meanwhile..
especially when in that point we do prefere to work against typed-graphql until we know that the new @types can be trusted.

@olgertse
Copy link
Contributor Author

olgertse commented Oct 1, 2016

I guess you're right. I didn't find any information on how long does it take to get merged PRs on definitelytyped to get published to npm, so I've stayed with solution mentioned above.

I think this is ready to be merged.

@DxCx DxCx merged commit b6819ec into apollographql:master Oct 3, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants