Importing in Typescript errors ts(2614)
See original GitHub issueI finally started trying out twin (you recommended it on reddit a few weeks ago!) having issues starting up in typescript however.
I followed the installation guide for CRA, I’ve made two code sandboxes setting up: Plain JS (Working): https://codesandbox.io/s/lucid-kapitsa-cjy3y?file=/src/App.js TS (Errors): https://codesandbox.io/s/busy-moser-yxl7g?file=/src/App.tsx
As you can see the JS works fine, and the TS does display the elements styled but there is a TS error for the imports Module '"../node_modules/twin.macro/types"' has no exported member 'tw'. Did you mean to use 'import tw from "../node_modules/twin.macro/types"' instead?ts(2614)
I’m assuming it can’t find the type definitions? I know you say you’ve got them built in, not sure if I missed something in installation.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:14 (4 by maintainers)
@KieranO547 To fix this if you need
css
, css comes from @emotion/core or your css-in-js library of choice. Had this issue yesterday, all I had to do was this:Although, it would be nice if the typings matched the documentation!
@KieranO547
It appears that you’ve not followed the guide for annotating the TypeScript types for your chosen CSS-in-JS library:
Let us know if this resolves your issue.
@ben-rogerson I was worried these instructions would not be visible enough if not linked to from the main readme (which is why I had initially linked them from there!), and this comment here has confirmed these suspicions. I suggest that we link them again from the readme. Thoughts?