Replies: 3 comments 28 replies
-
Here are my thoughts for the numbered ones:
|
Beta Was this translation helpful? Give feedback.
-
I'm back to thinking about I was updating my types usage examples gist to show how to deal with inference troubles in view components. I first use the simple example where explitly declaring the return type as I mean, TypedH could also have solved the problem, but in a less easy way. Do we have some example where just declaring the return type isn't enough? For easy reference, here is the example I used: import {h, text, Action, VDOM} from "hyperapp"
type MyComponentProps<S> = {
foo: Action<S, any>,
bar: string
}
// In this version, typescript tries to infer the
// return type of the view component, but cannot,
// because only the first child has any actions
// from which the state type can be inferred
// in the second child, the state type is inferred
// to be unknown.
const myComponent = <S>(props: MyComponentProps<S>) =>
h('div', {}, [
h('button', {onclick: props.foo}, text('click')),
h('p', {}, text(props.bar)),
])
// The easiest way to solve this is to explicitly
// declare the return type:
const myComponent2 = <S>(props: MyComponentProps<S>):VDOM<S> =>
h('div', {}, [
h('button', {onclick: props.foo}, text('click')),
h('p', {}, text(props.bar)),
]) EDIT: The issue in #1048 doesn't seem to be solved quite so easily. Investigating further |
Beta Was this translation helpful? Give feedback.
-
I recently discovered that types can be private. I feel silly for not realizing this sooner ! Like I said in Discord, we can just move the types we want private outside of the Now we don't need to feel pressured into inlining just for the sake of minimizing public exposure for the types. So, the question becomes, what to make private? Perhaps what would otherwise get inlined should instead be made private. Also, should we reintroduce types that were inlined but make them private? Maybe their inclusion makes the the types file better structured. At the moment I think |
Beta Was this translation helpful? Give feedback.
-
Hyperapp's TypeScript definitions are more or less solid at this point. However, a few topics remain that are a little more about philosophical positions rather than technical advancement.
Here they are in the priority I think they should be in.
TypedText
fortext()
as there is aTypedH
forh
?app()
'sdispatch:
property? (not just a types question)DispatchInitializer
,Key
,Subscriptions
,Tag
,Unsubscribe
, andVDOMNodeType
.View
a worthwhile type definition?Unsubscribe
be part ofSubscriptions
?Here is some other stuff that is also important but probably doesn't need as much debate.
any
s currently being used can be replaced by more type-safeunknown
s while preserving DX?Update (4/20/2021, 8:05 PM EST):
Beta Was this translation helpful? Give feedback.
All reactions