trypear / pear-landing-page

Landing page for PearAI, the Open Source AI-Powered Code Editor
https://trypear.ai
23 stars 32 forks source link

Add strict typing #23

Open ItWasEnder opened 3 weeks ago

ItWasEnder commented 3 weeks ago

Strict typing helps catch errors early during development, provides better autocompletion and documentation, and makes the code more predictable and easier to refactor.

🤝 We must be strong 💪

Use TypeScript and then set everything to type Any - JavaScript User47

Example

❌ Wrong ❌

This code is not compatible* with supabase SDK as fullName is not a field belonging to the data structure passed into signUp()

const data = {
  email: formData.get("email") as string,
  password: formData.get("password") as string,
  fullName: formData.get("full-name") as string,
};

🟢 Good 🟢

This code directly follows the SDK and would throw an error if fullName was added tot he root of data

const data: SignUpWithPasswordCredentials = {
  email: formData.get("email") as string,
  password: formData.get("password") as string,
  options: {
    data: {
      full_name: formData.get("full-name") as string,
    },
  }
};