Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Compiler doesn't prevent from spreading object types in a record type #6822

@tsnobip

Description

@tsnobip

Originally discovered by a post on the forum, you can do this today:

type baseProps = {"name": string}

type props = {
  ...baseProps,
  label: string,
}

let label: props = {
  "name": "hello",
  "label": "label",
}

See playground

The compiler would not complain (tested with versions v11.0.0 to v11.1.1), type props here looks like a record type but is actually an object type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions