-
Notifications
You must be signed in to change notification settings - Fork 1
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 global type defs #37
Conversation
bb1c405
to
4979595
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some small, non-blocking suggestions about updating the comments. Otherwise, this looks great. Thanks for taking the time to do this!
I know both home-ui
& shop-collections-ui
had to add the dummy module, so it'd be good to socialize this with @brandon-vaughan & @halloffame
src/stitch_fix/generateId.js
Outdated
@@ -1,6 +1,8 @@ | |||
import { ulid } from 'ulid'; | |||
import { constantCase } from 'constant-case'; | |||
|
|||
// Keep the type signature of this function in sync with the types exposed in | |||
// index.d.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually now in generateId.d.ts
. i would also add a companion comment in generateId.d.ts
to mention that it has to be kept in sync w/ the source file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! Done.
@@ -1,6 +1,8 @@ | |||
import { ulid } from 'ulid'; | |||
import { constantCase } from 'constant-case'; | |||
|
|||
// Keep the type signature of this function in sync with the types exposed in | |||
// index.d.ts | |||
const generateId = (key) => { | |||
if (typeof key === 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the nice thing is that a TS app now won't let the key
be undefined
thanks to these type definitions.
Problem
Although the JS package isn't written in TS, it's a pain for TS apps to add a module declaration file when they need to use it. The types also need to be exposed through packages like ER that are in TS, and are consumed by TS apps.
Solution
Expose a global TS module def. Check in a TS aware application that this works as expected when importing Log Weasel directly.
TODO
After merge: