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.

Typescript error (TS2464): Computed property

See original GitHub issue
  • gatsby-plugin-emotion version: 4.0.6
  • react version: 16.8.4

Relevant code:

const StyledLink = styled(Link)({...});

const MobileLinkContainer = styled("div")({
  ... 
  [StyledLink]: {
    padding: "1rem"
  }
});

What happened: I get an error: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ts(2464) at the [StyledLink] line

Suggested solution: A workaround is to use [StyledLink as any].

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

16reactions
luk707commented, Mar 21, 2019

We’ve been experiencing the same issue for our projects, Rather than typing the StyledCheckbox to any, you can instead do it in the directly within the computed property. This way you keep nice type introspection for the rest of your application:

const StyledCheckbox = styled.input(({ theme }) => ({}));

const CheckboxLabel = styled.label(({ theme }) => ({
  [StyledCheckbox as any]: {}
}));
7reactions
chadlavicommented, Mar 4, 2021

Anyone got anything on this? this is still an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript A computed property name in a type literal must ...
ts (..,..): A computed property name in a type literal must directly refer to a built- in symbol. ...: Cannot find name 'any'....
Read more >
TS2464: A computed property name must be of type 'string ...
TS2464 : A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ... Handling errors like a pro in TypeScript....
Read more >
Documentation - TypeScript 2.9
String-like properties of an object type are those declared using an identifier, a string literal, or a computed property name of a string...
Read more >
computedPropertyNames17_ES6.errors.txt
Member "TypeScript-4.9.4/tests/baselines/reference/ ... error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
Read more >
Dynamically added functions in TypeScript - Mees van Dongen
ts(1169) * A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ts(2464) */ // interface RootFunction extends ...
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