Skip to content

Remove FFI type aliases while it's still experimental #64848

Description

@everett1992

What is the problem this feature will solve?

node:ffi was introduced with synonyms for the same types

i8, int8
u8, uint8, bool, char
i16, int16
u16, uint16
i32, int32
u32, uint32
i64, int64
u64, uint64
f32, float
f64, double
pointer, ptr
string, str
buffer
arraybuffer

While this may be convenient for folks that are familiar with the different names, it also adds mental overhead - developers need to confirm if 'char' and 'u8' mean the same thing or are subtly different.

There were a few bugs that are kindof related to this

  • when ffi.types.FLOAT_32 was added it's value was float32 which wasn't a supported alias, so now there's three ways to spell float 32.
  • buffer and arraybuffer are also synonyms but are different lines in the docs
  • char is listed on the same lines as u8 and bool but it is not a synonym (it varies by platform)

cc @nodejs/ffi

What is the feature you are proposing to solve the problem?

We should remove each synonym and keep one spelling for each distinct type.
I'm not opinionated on which spelling we prefer, I think the uint8 style agrees with ffi.types and the access helpers (getUint8).

We should do this now while the module is experimental. WE can always add more names in the future, but removing them after the module is stable is harder.

What alternatives have you considered?

  • we could do nothing and live with the synonyms
  • we could deprecate and print a warning when the non-preferred aliases are used

Activity

  1. added
    ffiIssues and PRs related to experimental Foreign Function Interface support.
    on Jul 30, 2026
  2. changed the title [-]Remove FFI type aliases while it's still experemental[/-] [+]Remove FFI type aliases while it's still experimental[/+] on Jul 30, 2026
  3. Renegade334 commented on Jul 31, 2026

    @Renegade334
    Member

    Feel like this should apply to the ffi.types enum as well – it's pointless providing eg. ffi.types.INT_32 if all the documentation tells users to use 'i32' instead.

    IMO this should either be made the canonical way to pass types (like eg. the quic.constants.cc enum), or removed.

  4. ShogunPanda commented on Aug 20, 2026

    @ShogunPanda
    Contributor

    I don't agree on this issue
    People can just remember their most loved convention (i8 vs int8 and equivalent) but this way we are friendly with people coming from pretty much all languagues hierarchy. No real cognitive load here.

  5. trivikr commented on Aug 20, 2026

    @trivikr
    Member

    When users prefer different options, I think that software should support all and let users choose their favorite.
    Personally, I prefer longer names like int32 over i32 as it gives clarity and is less likely to create confusion.

  6. trivikr commented on Aug 20, 2026

    @trivikr
    Member

    We can retain aliases, but designate and prominently document one canonical spelling for each type in documentation?

    For example:


    Supported type names:

    • int8
    • uint8
    • int16
    • uint16
    • int32
    • uint32
    • int64
    • uint64
    • float32
    • float64
    Alternative spellings
    • i8 for int8
    • u8 for uint8
    • i32 for int32
    • u32 for uint32
    • f32 for float32
    • f64 for float64

    WDYT?

  7. ShogunPanda commented on Aug 20, 2026

    @ShogunPanda
    Contributor

    I'm fine for the documentation. Let's also retain str and ptr as aliases.

  8. trivikr commented on Aug 26, 2026

    @trivikr
    Member

    As of v26.8.0, we're giving preference for canonical type names and marking shorter names as alternative spellings.

    This issue can be closed if there's no further community feedback.

  9. leah-1ee commented on Sep 7, 2026

    @leah-1ee
    Contributor

    One thing I'm still wondering about is cases like bool/uint8 and buffer/arrayBuffer.

    Unlike u8/uint8, these seem a bit different semantically from a user's perspective.
    Maybe they're worth discussing separately from simple alternative spellings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.ffiIssues and PRs related to experimental Foreign Function Interface support.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions