Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

"as any" exception to no-object-literal-type-assertion #2716

Closed
KurtPreston opened this issue May 8, 2017 · 2 comments
Closed

"as any" exception to no-object-literal-type-assertion #2716

KurtPreston opened this issue May 8, 2017 · 2 comments

Comments

@KurtPreston
Copy link

I really like the no-object-literal-type-assertion rule for cases where I'm trying to type a variable. i.e., this is great:

// What I should write:
const x: MyInterface = {...}

// What tslint wisely stops me from writing:
const x = {...} as MyInterface

However, the one circumstance where I tend to use the as syntax is specifically when doing type overrides for tests. i.e.

// What I want to write for my test:
const x = {...} as any

// What tslint recommends:
const x: any = {...}

In this case, I'm using as any to draw attention to the fact that it is an override... the variable x is not actually an any type.

Would it be possible to add an option to ignore no-object-literal-type-assertion for as any?

@ajafff
Copy link
Contributor

ajafff commented May 8, 2017 via email

@adidahiya
Copy link
Contributor

fixed by #2671

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

No branches or pull requests

3 participants