Skip to content

The order of union types obtained by keyof will changeΒ #42102

Closed
@xxf1996

Description

@xxf1996

Bug Report

πŸ”Ž Search Terms

order of keyof return union type

πŸ•— Version & Regression Information

  • version: 4.0.3

⏯ Playground Link

link

πŸ’» Code

export interface RecallStrategyForm {
  target1: string;
  target2?: string;
  getType: string;
  inputId: string;
  templateTag: string;
  limit: {
    quota: string;
    sign: string;
    num: number;
  };
  recallWeight: number;
  recallOrder: string;
  recallBasis: number;
  recallMax: number;
  dateRange: number[];
  isCompletion: boolean;
  completionNum: number;
}

export interface RecallStrategyTable {
  id: string;
  target: string;
  rule: string;
  basis: string;
  weight: string;
  order: string;
  maxNum: number;
  isCompletion: string;
  dateRange: string;
}

export interface RecallStrategyDetail {
  id: string;
  no: number;
  itemId: string;
  itemName: string;
  totalMake: number;
  '7Make': number;
  '3Make': number;
  activeDay: number;
  cover: string;
  templateType: string;
}

type formKey = keyof RecallStrategyForm
type tableKey = keyof RecallStrategyTable
type detailKey = keyof RecallStrategyDetail

πŸ™ Actual behavior

image
image
image

We can see that the result order of one is different from the order of the other two, the other two are arranged in the order of declaration, but the middle one is not;

πŸ™‚ Expected behavior

I hope the order of return is in accordance with the order of declaration or a fixed way;

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions