How to write multiline function in ts-node repl? I'm working on ubuntu environment

578 Views Asked by At

I want to write below function in ts-node repl

function   padLeft (value: string, padding: any) { 
     if  ( typeof  padding === "number") { 
         return  Array(padding + 1).join(" ") + value; 
    } 
     if  ( typeof  padding === "string") { 
         return  padding + value; 
    } 
     throw   new  Error(`Expected string or number, got '${padding}'.`); 
} 

1

There are 1 best solutions below

0
user561810 On

I was using ts-node version 0.9.2 . Multi line feature was not there. So I upgraded it to version 1.8.

npm install -g tsun

The issue got resolved