You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current component that supports a similar use case, Mount, has the defect that TypeScript is not able to tell when the data used inside it is defined. It cannot use the when clause to refine the type. In particular, the following code will lead to an annoying type error (since you as a developer know the code is correct, but TypeScript doesn't)
typeUserDataProps={name: FacetProp<string>middlename?: FacetProp<string|undefined>}constUserData=({ name, middlename }: UserDataProps)=>{constnameFacet=useFacetWrap(name)constmiddlenameFacet=useFacetWrap(middlename)return(<div><p>Name: <fast-texttext={nameFacet}/></p><Mountdata={useFacetMap((middlename)=>middlename!=null,[],[middlenameFacet])}><p>Middlename: <fast-texttext={middlenameFacet}/></p>{/* Since TypeScript cannot know that `middlenameFacet` now holds a `string` for sure and still thinks that it could be `string | undefined`, it will complain. The only way to fix this is to extract a new component or with a type assertion. Neither is good */}</With></div>)}
TODO
Implement
Document
The text was updated successfully, but these errors were encountered:
Example:
Why?
The current component that supports a similar use case,
Mount
, has the defect that TypeScript is not able to tell when the data used inside it is defined. It cannot use thewhen
clause to refine the type. In particular, the following code will lead to an annoying type error (since you as a developer know the code is correct, but TypeScript doesn't)TODO
The text was updated successfully, but these errors were encountered: