fix(typescript): use bracket notation for non-identifier property names in file upload requests #11084
+28
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refs: https://github.com/fern-demo/uipath-typescript/commit/cde7c73511239a0bc22deb07d709f5b606379583
Fixes a bug where the TypeScript SDK generator produced invalid JavaScript when file upload request parameters had property names containing hyphens (e.g., header names like
X-Custom-Header).Changes Made
FileUploadRequestParameter.getReferenceToProperty()to use bracket notation (request["X-Custom-Header"]) instead of dot notation when the property name is not a valid JavaScript identifierisValidIdentifier()utility to@fern-typescript/commonsusingesutils.keyword.isIdentifierNameES6for proper ES6 identifier validationBefore (invalid JS - interpreted as subtraction):
After (valid JS):
Updates since last revision
isValidIdentifierutility from@fern-typescript/commonsinstead of a local regex, per reviewer feedbackesutils.keyword.isIdentifierNameES6which is already used elsewhere in the codebase (e.g.,getPropertyKey.ts)Testing
GeneratedQueryParams.tswhich already usescreateElementAccessExpressionfor similar casesHuman Review Checklist
esutils.keyword.isIdentifierNameES6("X-Custom-Header")returnsfalse(triggering bracket notation)isValidIdentifierutility needs unit testsLink to Devin run: https://app.devin.ai/sessions/0522dde80b444962aea65de6933ee41a
Requested by: [email protected] (@tjb9dc)