cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.06k stars 397 forks source link

Are JSS#options part of the public API? #828

Closed eps1lon closed 5 years ago

eps1lon commented 5 years ago

Neither feature nor bug report. More a question for the maintainers considering the public API.

Currently Jss#options is not documented in the API docs and the typing (InternalJSSOptions) also indicates that these should not be used. However react-jss currently requires options.createGenerateClassName to be visible.

I'm currently working on ts definitions for react-jss and would like to know if this requires a change to the definitions forjss as well.

kof commented 5 years ago

Jss constructor is a private API, it is used by create function in the package and those options are public

kof commented 5 years ago

Same like StyleSheet is private, but createStyleSheet is public

eps1lon commented 5 years ago

Sure the constructor is private and I'm not asking about the options I pass to create.

const jss = create();

// do I access private variables here that can be removed at any time without a major release?
const { createGenerateClassName } = jss.options; 
kof commented 5 years ago

Yes

On Tue, Aug 21, 2018, 07:21 Sebastian Silbermann notifications@github.com wrote:

Sure the constructor is private and I'm not asking about the options I pass to create.

const jss = create(); // do I access private variables here that can be removed at any time without a major release?const { createGenerateClassName } = jss.options;

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cssinjs/jss/issues/828#issuecomment-414553087, or mute the thread https://github.com/notifications/unsubscribe-auth/AADOWP0NRUhC7A-J06nhe-kypQaKGpchks5uS5jUgaJpZM4WElv9 .

HenriBeck commented 5 years ago

Why would you need to access those?

We are now exporting atleast some of the flow types from jss to be used by plugins and Integrations.

In the case of the Jss class: We are exporting only the type of the class and the Options for the constructor

eps1lon commented 5 years ago

So why does react-jss depend on those private variables? I realize that this sounds purely academic since react-jss is tightly coupled with jss on purpose but it kind of blocks typescript definitions over at DefinitelyTyped. Or I just require typeof Jss to communicate the tight coupling between those two. Sorry about the unrelated ramble 😄 Appreciate your help.

@HenriBeck I don't. react-jss does https://github.com/cssinjs/react-jss/blob/06044cbf8e7596c30f03573605567f42fa1b0763/src/propTypes.js#L5 https://github.com/cssinjs/react-jss/blob/06044cbf8e7596c30f03573605567f42fa1b0763/src/JssProvider.js#L58

HenriBeck commented 5 years ago

Ohhh, I see what you mean.

Yes, react-jss is obviously tightly coupled to jss itself.

You shouldn’t need those things for only the ts types though.

kof commented 5 years ago

I think we could avoid using jss.options there as well.

eps1lon commented 5 years ago

As far as I'm concerned this is resolved. Going to close this. Thank you for your time @kof and @HenriBeck :+1: