Types

Support for types in Live Elements (including support for Typescript) is currently under development. Property and function declarations can include their type, although the current compiler won't take them into account. The type syntax is compatible with Typescript, all types being Typescript types.

Declaring Component Properties

Component properties can be declared either by type property_name followed by a colon or an equal sign:

component X{
    number a = 100 // declaring property 'a' of type 'number' with a value of 100
    number b : this.a // declaring property 'b' of type 'number' bound to property 'a'
}

Or by using the prop keyword in a Typescript format (prop:[type] property_name):

component X{
    prop a :number = 100 // declaring property 'a' of type 'number' with a value of 100
    prop b :number : this.a // declaring property 'b' of type 'number' bound to property 'a'
}

They type can be omitted by using any in the first case, and simply omitting the type in the second:

component X{
    any a = 100 // a is of type 'any'
    any b : this.a // b is of type 'any'
}
component X{
    prop a := 100  // a is of type 'any'
    prop b :: this.a // b is of type 'any'
}

Declaring Functions

Parameter types in functions are required, while the return type is optional:

component X{
    fn sum(a:number, b:number){
        return a + b
    }
    fn diff(a:number, b:number):number {
        return a - b
    }
    static fn multiply(a:number, b:number){
        return a * b
    }
}