Definitelytyped: styled-components Babel macro with TypeScript and Create React App

Created on 29 Nov 2018  路  8Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/xxxx package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @Igorbek @Igmat @Lavoaster @Kovensky

I opened styled-components/styled-components#2253 yesterday, but was referred over here because they don't maintain the types there since v4. I hope I've come to the right place.

Full environment/reproduction details are included in that ticket, so I'll include a more succinct summary here:

When I follow the styled-components TypeScript docs, but instead try to import from the babel macro submodule (i.e. styled-components/macro instead of styled-components), I get the following error:

Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Cannot read property 'name' of undefined
    at :3000/Users/ginosoave/work/playground/sc-macro/node_modules/babel-plugin-macros/dist/index.js:89

I'm kind of new to both TypeScript and babel-plugin-macros. Please can anyone either help me resolve this issue or point me in the right direction?

Most helpful comment

All 8 comments

I, too, am having this issue, and haven't figured out the cause or solution.

Have same error, any suggestions to fix it?

Did anyone figure out a solution?

Have you tried submitting this against babel-plugin-macros?

Looking at the stack you reported, it seems like an issue in there. (I'm also seeing it)

I was able to work around the issue using what is shown here:
https://github.com/styled-components/styled-components/issues/2368#issuecomment-462507866

Was this page helpful?
0 / 5 - 0 ratings