#Why am I getting this error message? TypeScript supports function argument types right?

5 messages · Page 1 of 1 (latest)

nocturne helm
#
let array = [1, 3, 2, 5, 7, 3];

const BubbleSort = (arr: number[]) => {
    let a = arr.length;
    let i = 0;
    while (a != 0) {
        for (; arr[i] > arr[i + 1]; i++, a--) {
            let swap = arr[i + 1];
            arr[i + 1] = arr[i];
            arr[i] = swap;
            BubbleSort(arr);
        }
    }
    return arr;
};

console.log(BubbleSort(array));

When I run the code I get this error

SyntaxError: Unexpected token ':'
hard wing
#

how are you running it

nocturne helm
#

node bubblesort.ts

hard wing
#

Node can't run TypeScript files

#

You need to compile them first or use something like tsx if you want to run them directly