Low fidelity Typescript types for `context.query`
See original GitHub issueSteps to reproduce
Follow the docs link to create a project: How to embed Keystone + SQLite in a Next.js app.
Expected result
It builds just fine, dynamic lists
typings are connected with imports.
Actual result
npm run build
doesn’t work:
List item types has any
type (instead of Post
for query.Post.findMany
):
Node v14.18.1, macOS 12.1.
Workarounds
Currently I found out that it can be “fixed” by importing from .keystone/types
and specifying types manually like this, for each usage on Next.js pages on frontend:
import { query } from '.keystone/api'
import { Lists } from '.keystone/types'
export async function getStaticProps() {
const posts = (await query.Post.findMany({ query: 'id title slug' })) as Lists.Post.Item[]
return { props: { posts } }
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Context | React TypeScript Cheatsheets
Using createContext with an empty object as default value. ... // set the type of state you want to handle with context e.g....
Read more >Prototyping and data modeling in the browser using TypeScript
The UX designers can review the low-fidelity UI rendered by React. The data model and the UI are two different views of the...
Read more >Stripe API reference – Node
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries....
Read more >DownloadManager - Android Developers
Query the download manager about downloads that have been requested. ... network and the download manager is waiting for a Wi-Fi connection to...
Read more >Backbone.js
Remove a previously-bound callback function from an object. If no context is specified, all of the versions of the callback with different contexts...
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
We’ve somewhat improved this with #7249 which is yet to be released and we’re looking at improving this further
@dcousens thanks! Yes, complete typings implementation looks complicated for this kind of queries, but at least I’d expect this to return something like a
Partial<Post>
(or to be more precise,Promise<Partial<Post>>
).