question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing in Typescript errors ts(2614)

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
AlexanderArvidssoncommented, May 21, 2020

@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:

import { css } from "@emotion/core";
import tw from "twin.macro"

Although, it would be nice if the typings matched the documentation!

5reactions
rbuteracommented, Jun 4, 2020

@KieranO547

Can I confirm if this issue definitely closed? I’ve just upgraded to v1.3.0 and still see the same error in typescript when importing styled from twin.macro: import tw, { styled } from 'twin.macro'; gives “has no exported member named styled”.

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid TS2614 error when importing interfaces from ...
Try declaring BenefitDetails interface in de dedicated ts file (ie: benefitDetails.model.ts). Then import the BenefitDetails where needed.
Read more >
TypeScript errors and how to fix them
error TS2497: Module ' logdown ' resolves to a non-module entity and cannot be imported using this construct. Broken Code ❌. Export: logdown.d.ts....
Read more >
Module has no exported member error in TypeScript
The error "Module has no exported member" occurs when we try to import a member that doesn't exist in the specified module. To...
Read more >
isolatedModules - TSConfig Option - TypeScript
'index.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export ...
Read more >
Typescript does not found exported member - Vue Forum
import { S1 } from './S1.vue';. the compiler says me. ERROR in D:/Git/GeneralPlayground/vue-ts-4/src/components/HelloWorld.vue 11:9 Module ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found