question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lynt removed all typecast type assertions

See original GitHub issue

When I ran npm run lynt --typescript --fix lynt removed type assertions from across the app.

For example: const abc: HTMLFormElement = <HTMLFormElement>nativeElement.querySelector('.xyz'); became const abc: HTMLFormElement = nativeElement.querySelector('.xyz');

I couldn’t find any rule in my tslint.json that requested this change.

I suspect some rule did this, but I couldn’t find it in my tslint.json. Please comment if you know 🙇

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
saadqcommented, Jul 17, 2018

This rule has been removed entirely as of v0.5.0. Release notes: https://github.com/saadq/lynt/releases/tag/v0.5.0

1reaction
whyboriscommented, Jun 20, 2018

I think you’re correct about 'no-unnecessary-type-assertion' I removed the line 'no-unnecessary-type-assertion': true, from node_modules/lynt/lib/tslint/config.js (manual hack) and re-ran the npm run lynt (pacagke.json command has --typescript --fix) and it no longer removed the type assertions! Your file: https://github.com/saadq/lynt/blob/master/src/tslint/config.ts#L80

ps – using lynt removed about 300 unused imports in our codebase ❤️ 🙌 ❤️

pps - After lynt removed the unused imports, it left behind some blank lines, resulting in errors when I was running our regular linter: it complained no-consecutive-blank-lines. Sorry to overload this issue – please let me know if you’d like me to open a new issue with just this comment 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript-eslint/consistent-type-assertions.md at main - GitHub
This rule aims to standardize the use of type assertion style across the codebase. Keeping to one syntax consistently helps with code readability....
Read more >
non-nullable-type-assertion-style - TypeScript ESLint
Enforce non-null assertions over explicit type casts. Extending "plugin:@typescript-eslint/strict" in an ESLint configuration enables this rule. Some problems ...
Read more >
How to assert a type of an HTMLElement in TypeScript?
A type assertion is like a type cast in other languages, but performs no special checking or restructuring of data.
Read more >
Why You Should Avoid Type Assertions in TypeScript
Add Linting rules to disable Type Assertions​​ This is where linting can be very useful by giving us visual feedback in our code...
Read more >
Type assertions (related to casting) • Tackling TypeScript
This chapter is about type assertions in TypeScript, which are related to type casts in other languages and performed via the as operator....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found