Skip to content
Discussion options

You must be logged in to vote

The runtimeModel argument is RuntimeModel | undefined because it's not guaranteed to be set. In other words, the runtimeModel property on the MyContextStore.Provider is optional, so it has to be defined as RuntimeModel | undefined.

Instead of using @ts-ignore, you have some options:

  1. If the runtime model is not always provided, you can use the nullish coalescing operator to provide a fallback value
export const MyContextStore = createContextStore<RuntimeModel>((runtimeModel)=> ({
 myProp: runtimeModel?.myProp ?? 'fallback',
}))
  1. If the runtime model is always provided, you can use the non-null assertion operator to provide a fallback value:
export const MyContextStore = createContextStore<

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Karmalakas
Comment options

@Karmalakas
Comment options

Answer selected by Karmalakas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants