Skip to content

Conversation

TaKO8Ki
Copy link
Contributor

@TaKO8Ki TaKO8Ki commented Nov 14, 2023

Summary

closes #389

closes #395

This implements a new rule to restrict the usage of variables without any type or initialisation in TS.

ref: https://www.typescriptlang.org/tsconfig#noImplicitAny

I have taken over #395. Thank you for the work @b4s36t4.

Test Plan

All existing tests should pass. #395 has added some test cases for valid and invalid situation and I've improved them.
In addition, I have corrected all the issues pointed out in #395 for now.

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter A-Website Area: website L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Nov 14, 2023
@TaKO8Ki
Copy link
Contributor Author

TaKO8Ki commented Nov 14, 2023

WIll fix conflicts.

@TaKO8Ki TaKO8Ki force-pushed the add-noImplicitAnyLet branch from b14ba5f to 829e4a8 Compare November 14, 2023 06:17
@TaKO8Ki TaKO8Ki force-pushed the add-noImplicitAnyLet branch from 8a8892b to 3ec0556 Compare November 14, 2023 09:18
declare_rule! {
/// Disallow use of implicit `any` type on variable declarations.
///
/// Typescript variable declaration without any `type` or `initialization` can cause issue later in the code.
Copy link
Member

@unvalley unvalley Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This @Conaclos 's suggestion is good to add.
ref: #395 (comment)

Suggested change
/// Typescript variable declaration without any `type` or `initialization` can cause issue later in the code.
/// TypeScript variable declaration without any type annotation and initialization have the `any` type.
/// The any type in TypeScript is a dangerous “escape hatch” from the type system.
/// Using any disables many type checking rules and is generally best used only as a last resort or when prototyping code.
/// TypeScript’s `--noImplicitAny` compiler option doesn't report this case.

After fixing this, you need to run just codegen again 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed it!

@unvalley
Copy link
Member

unvalley commented Nov 14, 2023

@TaKO8Ki Thanks for completing it! We can merge this after updating above suggestion.

@TaKO8Ki TaKO8Ki requested a review from unvalley November 14, 2023 14:10
@unvalley unvalley merged commit c83b64f into biomejs:main Nov 14, 2023
@TaKO8Ki TaKO8Ki deleted the add-noImplicitAnyLet branch November 14, 2023 15:12
@Conaclos Conaclos added the A-Changelog Area: changelog label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project A-Website Area: website L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📎 Implement lint/noImplicitAnyLet
4 participants