Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Add typescript definition file for public API #52

Closed

Conversation

tatethurston
Copy link

Fixes #35.

Summary

Describe the goal of this PR. Mention any related Issue numbers.

Requirements (place an x in each [ ])

@CLAassistant
Copy link

CLAassistant commented Dec 23, 2017

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov
Copy link

codecov bot commented Dec 23, 2017

Codecov Report

Merging #52 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #52   +/-   ##
=======================================
  Coverage   94.26%   94.26%           
=======================================
  Files           4        4           
  Lines         122      122           
=======================================
  Hits          115      115           
  Misses          7        7

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 479b48c...d7e43f2. Read the comment docs.

@tatethurston
Copy link
Author

Using "types" in package.json as suggested by the TS team http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html.

I followed DefinitelyTyped's https://github.com/DefinitelyTyped/DefinitelyTyped project structure. As a type test, I'm using the first example from the readme.

@tatethurston tatethurston force-pushed the typescript-definitions branch from eeb33d9 to 1712c92 Compare January 3, 2018 00:28
@tatethurston tatethurston force-pushed the typescript-definitions branch from 1712c92 to d7e43f2 Compare January 3, 2018 00:35
@boazj
Copy link

boazj commented May 10, 2018

Is something preventing this from being merged?

@aoberoi
Copy link
Contributor

aoberoi commented May 31, 2018

😮 i'm sorry i missed this PR earlier! thank you so much for taking the time to add some typing. i'll review and give you some feedback now.

@aoberoi
Copy link
Contributor

aoberoi commented May 31, 2018

i think this is a great start on getting types into this package. i'd like to also start thinking about whether we can leverage the AsyncAPI Spec to generate some of the types, so that re-syncing with the platform when additions or modifications are made becomes trivial. some of these ideas are also discussed here: slackapi/node-slack-sdk#496

@@ -0,0 +1,22 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its an interesting choice to essentially deliver the types in a separate package. i'm not certain what the advantages are to this approach over simply adding an index.d.ts to the root of the package. can you explain? one disadvantage i see is that its common practice to list the @types/* dependencies in the top-level package.json, see this section of the manual.

is the intention that we would publish two separate modules to npm? if so, i think that would be confusing, and at that point we might as well only offer ambient declarations via DefinitelyTyped.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript's publishing documentation suggests publishing to the @types organization on npm if the package is not written in TypeScript.

I believe the intent is to avoid shipping type definitions to those who don't need them.

That said, I'm happy to instead add index.d.ts if that is your preferred approach.

"SLACKEVENTMIDDLEWARE_TOKEN_VERIFICATION_FAILURE";

type EventType =
"app_uninstalled" |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have some apprehension to committing an exhaustive list of event types into this repo. these values are bound to change over time, and that means developers would have to deal with a compiler error if an up to date set is not available. we came up with a technique to allow flexibility using generics in this issue. i'd prefer a solution that allowed unknown event types to work without a compiler error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if that's a goal then we could union String at the end or simply define EventType as a string.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants