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

typeof item in Array incrorrect #46304

Closed
kikyouink opened this issue Oct 11, 2021 · 3 comments
Closed

typeof item in Array incrorrect #46304

kikyouink opened this issue Oct 11, 2021 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@kikyouink
Copy link

kikyouink commented Oct 11, 2021

Bug Report

text[key] on left infer to never ??? but why text[key] on right infer to string | number?

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

typescript - 4.5.0

  • This is a crash

⏯ Playground Link

link

πŸ’» Code

interface Item {
    id: number;
    name: string;
    age: number;
}

const form: Item = {
    id: 99,
    name: 'k',
    age: 99,
};

const text: Item = {
    id: 1,
    name: 'εΌ δΈ‰',
    age: 18,
};

(['id','name','age'] as const).forEach(key => {
    text[key] = text[key];
});

// Type 'string | number' is not assignable to type 'never'.
// Type 'string' is not assignable to type 'never'.

πŸ™ Actual behavior

bug occured

πŸ™‚ Expected behavior

no bug

@jcalz
Copy link
Contributor

jcalz commented Oct 11, 2021

Working as intended, as per #30769. Possible duplicate of #32693

@fatcerberus
Copy link

This is a crash

Uh... no it's not? Nor is it a bug. It's just an error you didn't expect.

@andrewbranch andrewbranch added the Duplicate An existing issue was already created label Oct 11, 2021
@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

5 participants