Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

how to determine whether an unknown variable is a specific Record / Tuple #388

Description

@eczn
let p = #{ x: 11, y: 22 }

function handlePoint(x: unknown) {
  if (x instanceof /* ??? */) {  // how to determine whether an unknown variable is a specific Record / Tuple
    console.log(`x is a point:`, x)
  } else {
    throw new Error(`x is not a point`)
  }
}

try to name #{ x, y }:

record Point #{ x, y }
const p = Point #{ x: 1, y: 2 }
x instanceof Point

or:

x instanceof #{x, y} 

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions