Skip to main content
2 / 2
例示の型名をリネーム
orangecat
  • 1,011
  • 6
  • 10

型アノテーションをつけない SingleTextEditorParams (仮に UntypedSingleTextEditorParams とします) を先に作り、
SingleTextEditorParamKeyskeyof typeof UntypedSingleTextEditorParams とするのはいかがですか。

const UntypedSingleTextEditorParams = {
    a: ...,
    b: ...,
    c: ...,
    d: ...,
};

type SingleTextEditorParamKeys =
    keyof typeof UntypedSingleTextEditorParams;

const SingleTextEditorParams
    : Record<SingleTextEditorParamKeys, SingleTextEditorParamList>
    = UntypedSingleTextEditorParams;
orangecat
  • 1,011
  • 6
  • 10