Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First version of TypeScript sample repo #1

Merged
merged 13 commits into from
Feb 11, 2025
Merged

Conversation

alexcasalboni
Copy link
Collaborator

@alexcasalboni alexcasalboni commented Feb 11, 2025

I've converted this PR into its own repo (plus TS-native tests as well).

@Jer1605
Copy link

Jer1605 commented Feb 11, 2025

@alexcasalboni

Also, @Jer1605 any suggestions to make that code more TS-friendly? I've only converted the typing from the JS implementation, but I'm sure that a native TypeScript implementation would look quite different :)

Yes it would, but that's a nice job ! :) You could go further using strict typing (strict mode, noImplicitAny), defining clear interfaces and type aliases, and leveraging generics instead of any to improve safety and readability. Enums and union types are great to enforce constraints, while refining function signatures ensures consistency. Also, making sure module resolution is properly set up and adding ESLint with TS support would help keep the code clean and maintainable. Finally, using Mocha with ts-node as you've already done lets you run tests directly on .ts files. After that, you’ll have a good TypeScript dev setup for a small non complex project (if we need it to be more ingineered, or more scalable, some further config would be needed)! 😃🚀 But getting rid of any is the most important, as it's the nightmare of any TS dev (exceptions can be made in certain specific cases).

@alexcasalboni
Copy link
Collaborator Author

Thanks @Jer1605 🙏 I've added ESLint with TS support and removed all any references 👌

@alexcasalboni
Copy link
Collaborator Author

Ok, this is ready to merged (no more warnings) 👌

@alexcasalboni alexcasalboni merged commit 6cb4752 into main Feb 11, 2025
1 check passed
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.

3 participants