Skip to content

Using only GodanConjugationMap cannot correctly infer some conjugated forms of 「行く」「ある」 #7

@huyi1985

Description

@huyi1985
type GodanConjugationMap = {
  : {
    ます形: "き";
    て形: "いて";
    ...
  };
  ...
  : {
    ...
    ない形: "ら";
    ...
  };
};

// Helper utility types for conjugation
type GetGodanConjugation<
  E extends GodanVerb["ending"],
  F extends ConjugationForm
> = F extends keyof GodanConjugationMap[E]
  ? StringLiteral<GodanConjugationMap[E][F]>
  : never;

type 行く = GodanVerb & { stem: "行"; ending: "く" };
type ある = GodanVerb & { stem: "あ"; ending: "る" };

type 行くて形 = ConjugateVerb<行く, "て形">;
type あるない形 = ConjugateVerb<ある, "ない形">;

const wrongIku: 行くて形 = "行いて"
const wrongAru: あるない形 = "あら"

const verifyIku: 行くて形 = "行って" // Type '"行って"' is not assignable to type '"行いて"'.
const verifyAru: あるない形 = ""    // ない。Type '""' is not assignable to type '"あら"'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions