let starsArray: JSX.Element[] = [];

const [array, setArray] = useState<JSX.Element[]>([]);


interface ISomething {
    arr: string[]

// Somewhere in a class a method uses ISomething interface.
public someMethod(): ISomething['arr'] {
    // Note, if you omit ": ISomething['arr']" in the line below
    // you would face ts2345 error when you push a string into the array later.
    const localArray: ISomething['arr'] = [];
    return localArray;

Related Query

More Query from same tag