Skip to content

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

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

Closed
xxf1996 opened this issue Dec 24, 2020 · 2 comments
Closed

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

xxf1996 opened this issue Dec 24, 2020 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@xxf1996
Copy link

xxf1996 commented Dec 24, 2020

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;

@andrewbranch andrewbranch added Design Limitation Constraints of the existing architecture prevent this from being fixed Duplicate An existing issue was already created and removed Design Limitation Constraints of the existing architecture prevent this from being fixed labels Dec 28, 2020
@andrewbranch
Copy link
Member

Duplicate of #17944

@andrewbranch andrewbranch marked this as a duplicate of #17944 Dec 28, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants