Skip to content

Inclusion of any typed value disables checking of other values #32165

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
chrisnojima opened this issue Jun 28, 2019 · 1 comment
Closed

Inclusion of any typed value disables checking of other values #32165

chrisnojima opened this issue Jun 28, 2019 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@chrisnojima
Copy link

TypeScript Version:
3.5.2

Search Terms:
array any untyped

Code

const poison: any = 3
const arr: Array<number> = [
    1,
    'two',
    poison
]

Expected behavior:
TS would complain about 'two' above. Commenting out poison does show the error. My goal was to type my array to catch bad values getting into it, yet a single anyed value disables me doing any kind of validation

Actual behavior:
TS ignores 'two'

Playground Link:
https://www.typescriptlang.org/play/index.html#code/MYewdgzgLgBADiAlhcAuGBDMBPGBeGAZgChRJYMAnS9AQWo2wB4wBXAWwCMBTSgPnwwA2sRhiYARgA0o8QHIoAdxByZ4+EhRhiAXSA

Related Issues:
Couldn't find it

@RyanCavanaugh
Copy link
Member

Duplicate #26184

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

2 participants