Skip to content

Fix TypeScript compilation error in Device Provisioning Services samples#36120

Closed
Siongithub wants to merge 1 commit intomainfrom
suatiskender/fix-js-sdk-gen
Closed

Fix TypeScript compilation error in Device Provisioning Services samples#36120
Siongithub wants to merge 1 commit intomainfrom
suatiskender/fix-js-sdk-gen

Conversation

@Siongithub
Copy link
Contributor

Packages impacted by this PR

azure-resourcemanager-deviceprovisioningservices

Issues associated with this PR

Azure/azure-rest-api-specs#37922

error TS2322: Type 'string' is not assignable to type 'Uint8Array<ArrayBufferLike>'.
The generation process failed for specification-deviceprovisioningservices-resource-manager-Microsoft.Devices-DeviceProvisioningServices-tspconfig.yaml. Refer to the full log for details.

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

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

@Siongithub Siongithub requested a review from qiaozha as a code owner October 6, 2025 17:35
Copilot AI review requested due to automatic review settings October 6, 2025 17:35
@Siongithub Siongithub requested a review from MaryGao as a code owner October 6, 2025 17:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Buffer to Uint8Array for 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

Copy link
Member

@MaryGao MaryGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is incorrect and we have prepared a release pr for you : #36149.

Could you close your pr?

@Siongithub Siongithub closed this Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Mgmt This issue is related to a management-plane library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants