Is it possible to use an interface from a static method? I'm encountering an issue and could really use some help.
I've been experimenting with TypeScript, testing out an interface:
interface HelloWorldTS {
name : string;
}
Here's the code snippet where I tried using this interface:
class Startup {
public static main(): number {
console.log('Hello World');
return 0;
}
}
Startup.main();
interface HelloWorldTS {
name : string;
}
class Startup {
public static main(): number {
console.log('Hello World');
TSInterface : HelloWorldTS = { name: "hello"};
return 0;
}
}
Startup.main();
However, I encountered an error: cannot find name "HelloWorldTS" on this line
TSInterface : HelloWorldTS = { name: "hello"};
So, my question is, can an interface be used from a static method? If so, what mistake am I making? Apologies for any language barriers; I hope my question makes sense.