Type error with typescript using example
See original GitHub issueI’m following the example to set up next-with-apollo and am trying to do so using typescript instead of regular JavaScript. However, I’m getting the follow error when I do so:
[ts]
Argument of type 'typeof MyApp' is not assignable to parameter of type 'typeof App'.
Types of parameters 'props' and 'props' are incompatible.
Type 'TProps & AppComponentProps' is not assignable to type 'Props & AppComponentProps'.
Type 'TProps & AppComponentProps' is not assignable to type 'Props'.
Property 'apollo' is missing in type 'AppComponentProps'.
class MyApp
Here is my _app.tsx
import App, { Container } from 'next/app';
import ApolloClient from 'apollo-boost';
import { ApolloProvider } from 'react-apollo';
import withApollo from '../lib/withApollo';
interface Props {
apollo: ApolloClient<any>;
}
class MyApp extends App<Props> {
render() {
const { Component, pageProps, apollo } = this.props;
return (
<Container>
<ApolloProvider client={apollo}>
<Component {...pageProps} />
</ApolloProvider>
</Container>
);
}
}
export default withApollo(MyApp);
The withApollo.ts
didn’t change from the example in the README.
Did I miss some simple here? I assumed given that this was written in TypeScript that it should work pretty simply.
Thanks!!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Documentation - Understanding Errors - TypeScript
Whenever TypeScript finds an error, it tries to explain what went wrong in as much detail as possible. Because its type system is...
Read more >Get a catch block error message with TypeScript - Kent C. Dodds
TypeScript forces you to acknowledge you can't know what was thrown making getting the error message a pain. Here's how you can manage...
Read more >Type-Safe Error Handling In TypeScript - DEV Community
In this post, I introduce the concept of a Result type, which eliminates the need for throwing exceptions, and reduces risk of runtime ......
Read more >Improving TypeScript error handling with exhaustive type ...
In this article, we'll cover a few of the most common approaches for error handling in TypeScript (TS). We'll talk about most common...
Read more >Exception Handling - TypeScript Deep Dive - Gitbook
Creates an instance representing an error that occurs when a variable or parameter is not of a valid type.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hisea Can you add the
apollo
prop like here ?Thank you, it worked well.
sorry for my novice typescript question.