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

styled-jsx, TypeScript and external css files #381

Closed
paulbrie opened this issue Jan 13, 2018 · 4 comments
Closed

styled-jsx, TypeScript and external css files #381

paulbrie opened this issue Jan 13, 2018 · 4 comments

Comments

@paulbrie
Copy link

Hi, do you have any working example of next/styled-jsx /TypeScript with external CSS files?

Thanks, Paul

@giuseppeg
Copy link
Collaborator

Nope, there is an open issue about typescript. You may want to ask there.

@djskinner
Copy link

I'm interested in this also as I've not been able to get this working.

Inline styles as follows now work fine:

        <style jsx>{`
        div {
            background: crimson;
        }
        `}</style>

Note that it's important to use "jsx": "react-native" in your tsconfig.json.

I've tried to externalise the CSS as follows:

// styles.ts
import css from "styled-jsx/css";

export default css`
div {
    background: crimson;
}
`;

Using it in my component as follows:

import styles from "./styles";

<style jsx>{styles}</style>

However this gives the following error:

Syntax Error: <style jsx>{`some css`}</style>), but got MemberExpression

@djskinner
Copy link

Here's a basic test case. I took the official TypeScript example and externalised the CSS.

vercel/next.js@canary...djskinner:ts-external-css

This gives the same error as above.

@giuseppeg
Copy link
Collaborator

closing this since it Relates to #90

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

No branches or pull requests

3 participants