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

no-useless-assertion: allow assertion when contextual type is TypeParameter #282

Open
ajafff opened this issue Jun 7, 2018 · 1 comment
Assignees
Labels

Comments

@ajafff
Copy link
Member

ajafff commented Jun 7, 2018

declare function fn<T extends string | undefined>(param: T): T;
declare var v: string;
const r = fn(v as string | undefined); // this assertion should not be removed as it would change the type of 'r'

Some detection logic that could be used is already implemented in https://github.com/ajafff/tslint-consistent-codestyle/blob/7d9604f4d94bfaed3a1279f1eb53a12e6661114c/rules/noUnnecessaryTypeAnnotationRule.ts#L89

@ajafff
Copy link
Member Author

ajafff commented Jul 4, 2019

reminder to self: needs to handle union signatures and higher order function/constructor type inference

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

No branches or pull requests

1 participant