0

Maybe this is a stupid question but can not find anything, help me.

I'm trying TS, and I happened to test an interface

interface HelloWorldTS {
        name : string;
    }

within this code.

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();

but I make a error: cannot find name "HelloWorldTS", in this line TSInterface : HelloWorldTS = { name: "hello"};

My question is, if possible use an interface from a static method, and if so, what is my mistake. sorry for my bad English I hope you understand what I want to ask

1 Answer 1

4

You're just missing the keyword to declare a new variable like let

interface HelloWorldTS {
        name : string;
    }

class Startup {


    public static main(): number {
        console.log('Hello World');

        let TSInterface : HelloWorldTS = { name: "hello"};

        return 0;
    }


}
Sign up to request clarification or add additional context in comments.

1 Comment

oh man, I vote your answer, but still can not accept it, but accept it, thank you very much for your time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.