-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
🔎 Search Terms
error TS2322: Type 'Uint8Array' is not assignable to type 'BufferSource'.
🕗 Version & Regression Information
- This changed between versions 5.8.2__ and 5.9.2_
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
No response
💻 Code
// TypeScript Crypto API Demo - Reproducing iv parameter type error
// For reporting issue to TypeScript team
// Simplified test function
async function testCryptoDecrypt() {
// Create a Uint8Array as iv
const iv = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
// Mock key and data
const key = {} as CryptoKey;
const data = new Uint8Array([1, 2, 3, 4, 5]);
try {
// This should report TypeScript error
const result = await window.crypto.subtle.decrypt(
{
name: "AES-GCM",
iv, // ❌ TypeScript error: Type 'Uint8Array' is not assignable to type 'BufferSource'
tagLength: 128,
additionalData: new Uint8Array([1, 2]),
},
key,
data
);
console.log("Decryption successful:", result);
} catch (error) {
console.error("Decryption failed:", error);
}
}🙁 Actual behavior
When I upgraded ts to the latest version 5.9.2, I found that my project failed to compile with the error message
🙂 Expected behavior
I would like to confirm that this behavior is expected
Additional information about the issue
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug