Skip to content

Added check to avoid any type in Typescript#112

Closed
pkalyankumar1010 wants to merge 14 commits intoDeepSourceCorp:masterfrom
pkalyankumar1010:avoid_any_ts
Closed

Added check to avoid any type in Typescript#112
pkalyankumar1010 wants to merge 14 commits intoDeepSourceCorp:masterfrom
pkalyankumar1010:avoid_any_ts

Conversation

@pkalyankumar1010
Copy link

  • Issue: The any type disables TypeScript’s type checking, allowing any value to be assigned.

  • Impact: Can lead to runtime errors due to unexpected data types.

  • Remedy: Use specific types or unknown instead of any.

  • Example:

    • Unsafe:
let data: any = "Hello";
console.log(data.toFixed(2)); // Runtime error: toFixed is not a function
  • Safe:
let data: unknown = "Hello";
if (typeof data === "number") {
  console.log(data.toFixed(2));
}

@vercel
Copy link

vercel bot commented Feb 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
globstar ⬜️ Ignored (Inspect) Visit Preview Mar 6, 2025 4:21pm

@pkalyankumar1010 pkalyankumar1010 changed the title Avoid any type in Typescript Added check to avoid any type in Typescript Feb 24, 2025
@sourya-deepsource
Copy link
Contributor

Commits must have verified signatures.

@pkalyankumar1010 can you please sign your commits?

@sourya-deepsource sourya-deepsource enabled auto-merge (squash) March 9, 2025 11:13
auto-merge was automatically disabled April 7, 2025 10:02

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants