Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MainView実装 #96

Merged
merged 2 commits into from
Mar 3, 2020
Merged

MainView実装 #96

merged 2 commits into from
Mar 3, 2020

Conversation

spaspa
Copy link
Member

@spaspa spaspa commented Mar 2, 2020

MainViewのレイアウト切り替え・Viewマウント機構を仮実装しました
#95 のあとに入れてください

@spaspa spaspa requested a review from unipota March 2, 2020 12:20
@sapphi-red
Copy link
Contributor

type Primitify<T> = T extends String
  ? string
  : T extends Number
  ? number
  : T extends Boolean
  ? boolean
  : T extends BigInt
  ? bigint
  : T extends Symbol
  ? symbol
  : T extends Object
  ? {}
  : never

type TypeOfProp<P> = {
  [K in keyof P]: P[K] extends new (...args: any) => any
    ? Primitify<InstanceType<P[K]>>
    : P[K]
}

type Override<T, S> = Omit<T, keyof S> & S

// ---- ここまではどっか別のファイルに書いてimport

const props = {
  channelId: String
}

type Props = Override<
  TypeOfProp<typeof props>,
  {
    channelId: ChannelId
  }
>

こんな感じにするとPropにNumberとかが増えたときとか楽そう…?
(ホバーでの表示が微妙な感じですが&こうやって指定したとしてもChannelId表示じゃなくてstring表示になっちゃう)

@spaspa
Copy link
Member Author

spaspa commented Mar 3, 2020

なるほど、Vueに渡す用の定義と型定義が近くなるのは良い気がします
ChannelIdとかの指定はコンポーネント定義見たときにわかればいい程度なのでprop名でカバーしていく💪

@spaspa spaspa merged commit 4a55256 into master Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants