mckaywrigley / ai-code-translator

Use AI to translate code from one language to another.
https://ai-code-translator.vercel.app
3.9k stars 575 forks source link

Remove string from copyText state #21

Closed alamenai closed 1 year ago

alamenai commented 1 year ago

In TypeScript, it is not mandatory to set types for all generics.

Though, useState is a generic function that takes a type argument to specify the type of the state variable.

In this case, it's possible to remove the type annotation from the useState call because TypeScript can infer the type of the state variable based on the initial value. In this case, since the initial value is a string literal ('Copy'), TypeScript will infer that the type of the copyText state variable is a string.

vercel[bot] commented 1 year ago

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

Name Status Preview Comments Updated (UTC)
ai-code-translator ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 4, 2023 11:36pm
mckaywrigley commented 1 year ago

This is actually a mild dev preference.

I like being able to see "at a glance" the types even if they're inferred.

It's a visual thing.