Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Suggestion: use numeric literals for BYTES_PER_ELEMENT #59557

Copy link
Copy link
@lionel-rowe

Description

@lionel-rowe
Issue body actions

⚙ Compilation target

ES5+

⚙ Library

lib.es5.d.ts, lib.es2022.bigint.d.ts

Missing / Incorrect Definition

Suggesting to change the BYTES_PER_ELEMENT static and instance properties as follows:

interface Uint8Array {
    // ...
-   readonly BYTES_PER_ELEMENT: number;
+   readonly BYTES_PER_ELEMENT: 1;
    // ...
}
interface BigInt64ArrayConstructor {
    // ...
-   readonly BYTES_PER_ELEMENT: number;
+   readonly BYTES_PER_ELEMENT: 8;
    // ...
}

Etc.

Sample Code

declare function fn(bytesPerElement: 1 | 2 | 4 | 8): void
// currently reports "Argument of type 'number' is not assignable to parameter of type '1 | 2 | 4 | 8'".
fn(Uint32Array.BYTES_PER_ELEMENT)

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT#examples

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.