Flow Connect Help
Roadmap
  • ℹ️This is Flow Connect
    • Overview
    • Technical overview
      • System requirements
    • What's new?
      • Change log
  • ▶️quick start
    • Create an application
    • Create an admin access group
  • 🔁working with Connect
    • Connect to systems
      • Connector agents
        • Add agent group
        • Install agent manager
        • Add agent
        • Manage agent
      • Connectors
        • IFS Applications 10
        • Oracle
        • Microsoft SQL Server
        • Send Email
        • REST
          • Microsoft Graph API
          • Infor M3 REST
            • Obtaining Infor ION API file
            • Configure REST Connector with ION API file
          • IFS Cloud
            • IAM Client Registration
            • Obtaining end-point info from IFS Cloud
            • Configure REST Connector for IFS Cloud
        • File System
      • Redirect URIs
    • Create and design
      • Application packages
      • Applications
        • Create
        • Design
        • Test
        • Commit
      • Portal Pages
        • Create Portal Page
        • Design Portal Page
        • Commit Portal Page
      • Components
        • Create component
        • Manage component
      • Modules
        • Create module
        • Manage module
      • Automations
        • Functionality
        • Create Automation
        • Manage Automation
        • Creating Access Key
        • Executing Automations Externally
          • IFS Cloud
          • Salesforce Apex Trigger Example
    • Deploy
      • Environments
      • Deploy
    • Use
      • On mobile devices
      • In web browser - Web client
      • In web browser - Portal
    • Share
      • Share Applications
    • User administration
      • Users
        • Invite a new user
        • Manage users
      • User groups
        • Create user groups
        • Manage user groups
      • Access
        • Manage access
  • ⏸️Reference
    • How-to guides
      • Create User Step controls
        • Header
        • Static text
        • Labelled static text
        • Link
        • Image viewer
        • Text input
        • Numeric input
        • Date input
        • Time input
        • Check box input
        • Binary option input
        • List selection input
        • List multi-selection input
        • Menu selection input
        • Data grid
        • Calendar control
        • Image selection input
        • List presentation
        • Camera Input
      • Dependent controls in User step
        • Variable source
        • Expression source
        • Control visibility (condition to hide)
      • Configure SSO for Microsoft Entra
    • Reference
      • Clients
        • Settings
        • My data
      • Designer
        • Controls
          • Header
          • Static text
          • Labeled static text
          • Link
          • External app launcher
          • Image viewer
          • Text input
          • Numeric input
          • Date input
          • Time input
          • Check box input
          • Binary option input
          • List selection input
          • List multi-selection input
          • Menu selection input
          • Data grid
          • Calendar
          • Image selection input
          • List presentation
          • Camera input
          • File gallery
          • GPS location input
          • Signature capture input
          • Item creation sub task
          • Check list sub task
          • Verb sub task
        • Steps
          • Start
          • User interaction
          • External system
          • Decision
          • Assertion
          • HTTP requests
          • Assignment
          • Table
          • Event listener
          • Checkpoint
          • Script
          • Annotation
          • End
          • Local data resource
      • Portal
        • Design items
          • Portlets
            • Accumulation chart
            • Base chart
            • Circular gauge
            • Custom content
            • Data tree
            • Document viewer
            • Filter
            • Kanban
            • KPI card
            • Link
            • My apps
            • Record
            • Rich text
            • Table
          • Container
          • Common portlet configuration
            • General
            • Events
            • Data
            • Custom buttons
            • Style
        • Portal settings
          • Branding
          • Page
          • Navigation
        • Profile
        • Portlet actions
        • Cache
        • Input to Start Step
      • Diagnostic mode
      • FlowScript
        • Walkthrough
          • Introduction
          • Expressions and programs
          • Anatomy of a program
          • Variables
          • Simple types
          • Nullable types
          • Records
          • Sequences
          • Other types
          • Arithmetic
          • Other expressions
          • Queries
          • Conditionals and loops
          • Function definitions
          • Built-in functions
          • DateTime module
          • Seq module
          • HTTP module
          • CSV module
          • JSON module
          • Trace module
          • Record module
          • XML Module
          • Filesystem Module
          • Custom modules
          • Custom Types
          • Appendix: Subtyping rules
          • Appendix: Escape sequences
          • Appendix: Type checking errors
      • Flowscript Copilot
      • Glossary
    • Flow Connect Downloads
      • Install Flow Connect Designer
    • Migrate from Flow Classic
      • Portal - migrate from Flow Classic
      • Classic vs. Connect Comparison Guide
Powered by GitBook
On this page
  • Subtypes and supertypes
  • Record subtyping
  • Lowest common supertype

Was this helpful?

  1. Reference
  2. Reference
  3. FlowScript
  4. Walkthrough

Appendix: Subtyping rules

Each value in FlowScript belongs to at least one type. The value true, for example, belongs to the type boolean, and the value {x: 1} belongs to type {x: number}. The types themselves have mutual relationships. This document outlines the relationship between the types in FlowScript

Subtypes and supertypes

You may think of a type as a set of values. The type boolean is the set containg the two values true and false. The type boolean? (nullable boolean) is the set containing the three values true, false and null.

Because all members of the boolean set are also members of the boolean? set, boolean is a subtype of boolean?.

If A is a subtype of B, it means that you may pass values of type A whenever a value of type B is called for.

If A is a subtype of B, we say that B is a supertype of A.

// Example 1: we can assign a value of type boolean
// to a variable of type boolean?.
// In other words, boolean is a subtype of boolean?.

let x: boolean = false;
let y: boolean? = x; // no problem
// Example 2: we cannot assign any value of type boolean?
// to a variable of type boolean.
// In other words, boolean? is not a subtype of boolean.

let x: boolean? = null;
let y: boolean = x; // Type mismatch

Record subtyping

FlowScript record values are subject to width and depth subtyping rules. Width subtyping means that a record {x: number, y: number} is a subtype {x: number}. Depth subtyping means that a record {x: boolean} is a subtype of {x: boolean?}.

Intuitively, we can think of a record type as specifying the minimum members that a record must have. A record is allowed to have more members than required, but not less.

// Example: demonstrate width subtyping of records
let user = {id: 1, name: "Leon"};

// We can update the "user" variable with a record containing
// more fields than required by its type.
set user = {id: 2, name: "Theodora", email: "theodora@example.com"};

In the example above, the user variable after the set statement has an extra member called email. The type of the variable, however, does not include the email member, so we cannot access it directly. The member is still there, but you must use type narrowing to "find" it.

Lowest common supertype

For any pair of types A and B, there exists at least one type C which is a supertype of A and B. The type unknown is supertype of all other types, but sometimes there is a more useful and specific common supertype. This is known as the lowest common supertype (LCS).

For example, given the types {name: text, email: text} and {name: text, age: number}, the lowest common supertype is {name: text}. We can think of the LCS as the "common denominator" of two types.

// Example of a situation where FlowScript will
// find the lowest common supertype of several values.

let people = [
    {name: "Gregorsz", email: "gregorsz@example.com"},
    {name: "Felicia", age: 51}
];

Similarly, the LCS of boolean and boolean? is boolean? and the LCS of number* and text* is text*.

PreviousCustom TypesNextAppendix: Escape sequences

Last updated 1 year ago

Was this helpful?

⏸️