English, asked by Arslanbazaz5668, 1 year ago

Likewise other elements, Interface of TypeScript is usually converted to JavaScript in typescript.

Answers

Answered by Sidyandex
0

An interface is a syntax that any entity must adhere to, and you can find some interface that describes properties, methods and events.

They are also considered as the number of interface and interfaces contain the declaration of numbers.

It can describe some standard structure and we can derive some classes from the interface to follow.

Interfaces are not converted to JavaScript and it is just a part of the TypeScript.

The union type of interfaces are:

interface RunOptions {

  program:string;

  commandline:string[]|string|(()=>string);

}


//commandline as string

var options:RunOptions = {program:""test1"",commandline:""Hello""};

console.log(options.commandline)  


//commandline as a string array

options = {program:""test1"",commandline:[""Hello"",""World""]};

console.log(options.commandline[0]);

console.log(options.commandline[1]);  


//commandline as a function expression

options = {program:""test1"",commandline:()=>{return ""**Hello World**"";}};


var fn:any = options.commandline;

console.log(fn());

Similar questions
Math, 7 months ago