-
-
Notifications
You must be signed in to change notification settings - Fork 848
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 TypeScript definitions #207
Conversation
types/index.d.ts
Outdated
@@ -1,87 +1,89 @@ | |||
// Type definitions for Chalk | |||
// Definitions by: Thomas Sauer <https://github.com/t-sauer> | |||
export const enum Level { |
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.
Using const
here will cause replacements to occur during compilation -- Since this value doesn't exist at runtime
@t-sauer Does this LGTY? |
types/index.d.ts
Outdated
has256: boolean, | ||
has16m: boolean | ||
} | ||
rgb: (r: number, g: number, b: number) => Chalk |
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.
You could write them like rgb(r: number, g: number, b: number): Chalk
. I believe this is the preferred way.
types/index.d.ts
Outdated
} | ||
|
||
export interface Chalk { | ||
new (options: ChalkOptions): Chalk |
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.
Add a ;
after every line.
types/index.d.ts
Outdated
bgWhiteBright: Chalk | ||
} | ||
|
||
declare function chalk (): any |
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.
;
types/index.d.ts
Outdated
} | ||
|
||
declare function chalk (): any | ||
export default chalk as Chalk |
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.
;
@SamVerschueren updated |
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.
One more change and then I believe it's good to go.
types/index.d.ts
Outdated
enabled: boolean; | ||
level: Level; | ||
supportsColor: { | ||
level: Level, |
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.
Last nitpick :), also ;
.
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.
ammended :)
types/index.d.ts
Outdated
None = 0, | ||
Basic = 1, | ||
Extended = 2, | ||
TrueColor = 3 |
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.
Can we change Extended
to Ansi256
here? That's the more correct term; I've never seen extended
used to refer to the Ansi256 space.
types/index.d.ts
Outdated
} | ||
|
||
export interface Chalk { | ||
new (options: ChalkOptions): Chalk; |
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.
Shouldn't this be options?: ChalkOptions
? I don't know enough about TS defs, but we don't require an object be passed.
|
||
chalk.grey('foo'); | ||
|
||
chalk.constructor({level: 1}); |
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.
Can you add a test for chalk.constructor()
and new chalk.constructor()
?
types/tsconfig.json
Outdated
"target": "es6", | ||
"noImplicitAny": true, | ||
"noEmit": true, | ||
"allowJs": true |
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.
De-indent the properties for compilerOptions
by 1, please :)
Thank you so much for your continued attention to this. I know we aren't the fastest with getting back to this but the promptness is very much appreciated <3 |
@Qix- Good finds. Updated. |
LGTM 👍 Thank you! |
Will defer to @sindresorhus as to how he wants to move forward with a merge/release. Thank you so much @calebboyd ❤️ 💃 |
Awesome! Thanks to @t-sauer for starting this and @calebboyd for finishing it. Really appreciate your work on this. |
Hmm.... have you checked it ;)? TS 2.6.0
|
Thank you for this PR. I just noticed that I can't do Is this intended? :) |
@donaldpipowitch It certainly wasn't the plan to break people's workflow. #217 if merged will add named exports to the type definitions |
No problem. Thank you very much. I love it when packages ship their own typings. Thank you for the work. |
This is just a continuation of #169 based on the conversation there. Re-based and ready to go if it LGTY
/cc @t-sauer
Closes #169