Fix TypeScript compilation error in Device Provisioning Services samples#36120
Closed
Siongithub wants to merge 1 commit intomainfrom
Closed
Fix TypeScript compilation error in Device Provisioning Services samples#36120Siongithub wants to merge 1 commit intomainfrom
Siongithub wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes TypeScript compilation errors in Device Provisioning Services samples caused by stricter type checking in recent TypeScript versions. The API expects Uint8Array types for certificate data, but Buffer.from() returns a Buffer type that is no longer implicitly convertible.
- Adds explicit type casting from
BuffertoUint8Arrayfor certificate properties - Addresses compilation failures in SDK generation pipeline
- Maintains backward compatibility while satisfying TypeScript's stricter type requirements
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dpsCertificateCreateOrUpdateSample.ts (v6-beta) | Added explicit cast to Uint8Array for certificate Buffer |
| dpsCertificateCreateOrUpdateSample.ts (v5) | Added explicit cast to Uint8Array for certificate Buffer |
| dpsCertificateCreateOrUpdateSample.ts (samples-dev) | Added explicit cast to Uint8Array for certificate Buffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Packages impacted by this PR
azure-resourcemanager-deviceprovisioningservices
Issues associated with this PR
Azure/azure-rest-api-specs#37922
Describe the problem that is addressed by this PR
The error occurred because the sample code was using Buffer.from() to create certificate data, but the TypeScript compiler was not recognizing the implicit conversion from Buffer to Uint8Array.
Recent TypeScript compiler versions have become more strict about implicit Buffer to Uint8Array conversions
Failed to generate javascript SDK:
https://dev.azure.com/azure-sdk/internal/_build/results?buildId=5419379&view=logs&j=83516c17-6666-5250-abde-63983ce72a49&t=00be4b52-4a63-5865-8e02-c61723ad0692&l=1631
What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?
Are there test cases added in this PR? (If not, why?)
Provide a list of related PRs (if any)
Command used to generate this PR:**(Applicable only to SDK release request PRs)
Checklists