-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
googleapis/gapic-generator-typescript
#1034Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
https://github.com/googleapis/nodejs-functions/pulls
then two changes are needed
(1) use the logic similar to the one in namer.js to replace the names if they are bad
(namer.js is basically a way to plug the JS code to the template execution phase)
and then (2) make sure the usages use the new name, so const request = { function: renamedFunction }
namer: https://github.com/googleapis/gapic-generator-typescript/blob/main/templates/typescript_gapic/namer.js
it can be preinitialized with things like function
usage: https://github.com/googleapis/gapic-generator-typescript/blob/main/templates/typescript_gapic/src/%24version/%24service_client.ts.njk#L823
(use id.get(suggestedName) everywhere where it might cause conflict, and it will be renamed by the namer if needed)
otherwise, in cases where a proto has a real naming conflict, the samples will use the wrong names
here, https://github.com/googleapis/gapic-generator-typescript/blob/main/templates/typescript_samples/samples/generated/%24version/%24service.%24method.js.njk#L48
the template says async function {{ method.name.toCamelCase() }}() { while it should say async function {{ id.get(method.name.toCamelCase()) }} {
the rule is, all class members' names in the output should go through the namer
(and now we're going to expand this to the parameter names as well)
We need to make the namer consider reserved words like function as "used"
the logic is really straightforward, the only complicated thing here is how this logic is plugged in to the templates (which, as you surely know by now, don't allow much to do )
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.