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 - rename not working in ts

See original GitHub issue

follow the tutorial, i rename the posts to articles, but the eslint yell at me

image
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web'
import { FindPosts } from 'types/graphql'

export const QUERY = gql`
  query ArticlesQuery {
    articles: posts {
      id
      title
      body
      createdAt
    }
  }
`

export const Loading = () => <div>Loading...</div>

export const Empty = () => <div>Empty</div>

export const Failure = ({ error }: CellFailureProps) => (
  <div style={{ color: 'red' }}>Error: {error.message}</div>
)

export const Success = ({ articles }: CellSuccessProps<FindPosts>) => {
  return (
    <>
      {articles.map((article) => (
        <article key={article.id}>
          <header>
            <h2>{article.title}</h2>
          </header>
          <p>{article.body}</p>
          <div>Posted at: {article.createdAt}</div>
        </article>
      ))}
    </>
  )
}

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
callingmedic911commented, May 11, 2022

@jtoar codegen checks the web side as well and generates the type for each GraphQL operation.

And I finally see why it’s not working.

@PeterChen1997 type needs to change from CellSuccessProps<FindPosts> to CellSuccessProps<ArticlesQuery>. Since the type name is the same as whatever is set for the operation name. If we use query SomeOtherName, we need to update the type name.

0reactions
Tobbecommented, May 19, 2022

@jtoar if you read through what I and Andre have said above, what do you think is a good next step?

Read more comments on GitHub >

github_iconTop Results From Across the Web

F2 rename doesn't work in TypeScript · Issue #103213 - GitHub
I can't repo the rename bug but have seen the could not load TypeScript at this path . This can happen when you...
Read more >
Typescript confusing error after .js file renamed to .tsx file
I had the same issue. Renamed the files which I needed to .tsx and changed the code to typescript. Restarted the server. It...
Read more >
How to Fix VS Code Rename Symbols Feature for TypeScript
The solution for this problem is to select TypeScript version in Visual Studio Code. You can do this by opening up the command...
Read more >
In TypeScript, renaming a class function (via Refactor) causes ...
In TypeScript, renaming a class function (via Refactor) causes functions with the same name in untyped objects to be renamed as well, everywhere...
Read more >
TypeScript Programming with Visual Studio Code
No, the TypeScript language service that ships with Visual Studio 2019 and 2022 isn't compatible with VS Code. You will need to install...
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