colorette icon indicating copy to clipboard operation
colorette copied to clipboard

Fix export default for all colors

Open rwu823 opened this issue 4 years ago • 3 comments

Problems

For example if I do this, will get an error:

import c from 'colorette'

// types safe but get the error in runtime.
c.cyan('hello') // TypeError: Cannot read properties of undefined (reading 'cyan')

And then need to change to:

import * as c from 'colorette'

c.cyan('hello')

So I'm not sure if there was a special reason for this design? otherwise the general import usage case would be more reasonable and matched the type system.😅

rwu823 avatar Oct 11 '21 08:10 rwu823

What you say about the types is true, but it was probably a mistake since I didn't intend to support default exports.

Named exports, default exports, or both? Which one is more idiomatic in Node? Should we even have a default export?

jorgebucaran avatar Oct 11 '21 10:10 jorgebucaran

@jorgebucaran Well, if you don't intend to support default exports, you should fix types avoid a mistake for users.

Also chalk did export default if this project expects as a alternative.

rwu823 avatar Oct 12 '21 09:10 rwu823

Of course. Can you show us how to fix them? As I said, this was likely a mistake, because I didn't intend to support default exports when I wrote the types.

Now, I'm open to discussing adding them in the future.

jorgebucaran avatar Oct 12 '21 11:10 jorgebucaran