[@azure-rest/ai-inference] client instanciation is not following JS standards
sinedied opened this issue · comments
- Package Name: @azure-rest/ai-inference
- Package Version: 1.0.0-beta.5
- Operating system: MacOS
- nodejs
- version: v22.13.1
- browser
- name/version:
- typescript
- version: 5.8.2
- Is the bug related to documentation in
- README.md
- source code documentation
- SDK API docs on https://learn.microsoft.com
Describe the bug
It's not specific to this SDK, but while using something like const client = ModelClient(...)
works, as a JS dev the syntax looks confusing: it's a generally accepted standard in JS/TS that only classes should use an uppercase, so we can distinguish constructors from regular functions.
Many linters also throw in an error on this syntax, so it can be an issue in enterprise contexts:
The real issue might only be the documentation and sample code though, as in code the function is properly named createClient()
:
Expected behavior
I would expect the documentation and sample code to follow commonly accepted JS/TS conventions, hence using a regular createClient()
factory function and not a ModelClient()
method that could be confused as a class constructor.
It might also be interesting to export the createClient()
for as default export (to keep compatibility) but also as a proper named export. Having to mix both default exports and named export is generally considered an anti-pattern (again, often triggering linter errors/warnings).
I like the idea of naming this factory export createFooClient()