Skip to content
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

replaced StateMap and Stylesheet interface declaration with type declaration #116

Closed
wants to merge 1 commit into from

Conversation

wtfil
Copy link
Contributor

@wtfil wtfil commented Sep 5, 2017

Hi.
I am trying to create stylable stateless component

import * as React from 'react';
import {SBStateless} from 'stylable-react-component';
import styles from './styles.st.css';

export const MyComponent = SBStateless(
    (props) => {
        return (...);
    },
    styles
);

But I receive error like

error TS4023: Exported variable 'MyComponent' has or is using name 'Stylesheet' from external module "...PATH.../node_modules/stylable/dist/src/runtime" but cannot be named.

I made some research and found this issue, which said that I either have to add explicit import of Stylesheet in my component or let compiler add type declaration automatically.
I prefer the second option but this require the update type declaration. As far I know, type and interface has only different that type will not create actual alias name, so compiler could use this.

@AviVahl
Copy link
Collaborator

AviVahl commented Sep 5, 2017

Does the validation error occur if you give MyComponent an explicit type?
for example:
https://github.com/wix/stylable-components/blob/master/src/components/drop-down/drop-down.tsx#L29

I'm not sure how I feel about using type (rather than interface) to work around d.ts generation issues.

@AviVahl
Copy link
Collaborator

AviVahl commented Sep 5, 2017

Also, TS 2.6 is expected to address it, as far as I can see (was added to the milestone).
The compiler will add the imports to the .d.ts automatically.
microsoft/TypeScript#9944

@wtfil
Copy link
Contributor Author

wtfil commented Sep 5, 2017

@AviVahl no, it does not. Thx!
I think i can use that for now, and probably this PR is not relevant

@wtfil wtfil closed this Sep 27, 2017
@AviVahl AviVahl deleted the wtfil/stylesheet-type-declaration branch September 27, 2017 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants