Skip to content

Type casting breaks the validation of element types in the array #46965

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
KostyaTretyak opened this issue Dec 1, 2021 · 1 comment
Closed

Comments

@KostyaTretyak
Copy link

Bug Report

πŸ”Ž Search Terms

  • type casting

πŸ•— Version & Regression Information

4.6.0-dev.20211130

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const array: { property: number }[] = [
  {property: 1},
  {property: 1} as any, // <-- Type casting
  'text', // <-- No errors, but it's wrong
];

πŸ™ Actual behavior

No errors.

πŸ™‚ Expected behavior

Should show errors.

@MartinJohns
Copy link
Contributor

MartinJohns commented Dec 1, 2021

Duplicate of #19541. Used search terms: array any in:title

Also pointing out that the official and favourable term is "type assertion", not casting. With the term "casting" people often think of a transformation, possibly even including runtime behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants