Basic Types
EkScript has all the TypeScript basic types with special additions

Boolean

Most basic type. Has only two values: true and false . Denoted by boolean
1
let isDone: boolean = false
Copied!

Numbers

This is one of those places where EkScript is different from TypeScript. EkScript supports a wide variety of numbers, including bigint . You can also _ as a visual separator such as 1_000 . You can declare types from any of the following integer types:
Length
Signed
8-bit
char
32-bit
int
64-bit
float
TypeScript
1
let decimal: float = 6.0;
2
let anyNumber: number = 6.0; // number is an alias for float
3
let hex: int = 0xf00d;
4
let binary: int = 0b1010;
5
let octal: int = 00744;
6
let separate: int = 100_11;
7
let big: bigint = 100n;
8
let byte: char = 'A'; // u8 only
Copied!
You also have bigint

Type-Coercion

The default type for integer based values is int and for floating point values is float.
1
let a = 1; // i32
2
let b = 1.0; // f64
3
let c: int = 2;
4
​
5
let sum = 1 + 2; // i32
6
let finalSum = 1 + 2 / 1.5; // f64 (1.0 + 2.0/1.5 = 2.3333..)
7
let anotherSum: int = 1 + 2/1.5; // i32
8
console.log(anoter)
Copied!

String

You can use both ' and " quotes for Strings although the default is ' single quote. String behave similar to JavaScript. The developer can use strings without worry though.
1
let color: string = 'blue';
2
let color = 'red';
Copied!

Template strings

You can also use Template strings, spanning multiple lines. These strings are surrounded by the backtick/backquote(`) character. Embedded expressions are of the ${expr}.
1
let fullName: string = `Bob Bobbington`;
2
let age: int = 27;
3
let sentence = `Hello, my name is ${fullName}.
4
And my age is ${age}
5
`;
Copied!
The above sentence variable is equivalent to:
1
let sentence: string = 'Hello, my name is '
2
+ fullName
3
+ '.\n\n'
4
+ 'I\'ll be'
5
+ (age + 1)
6
+ ' years old next month';
Copied!
​
Last modified 8mo ago
Copy link