How can I refer to the interface

reguarding this line here:

I specifed a,b in the sort as type any. but I want them to be associated with the title property in the interface, denoted as string

how can I do this?

Quick way would be to create an interface and set types of a and b accordingly:

// Types.ts
export interface IState {
  issues: Issue[];
}

export interface Issue {
  title: string;
  id: string;
  repository_url: string;
  html_url: string;
  user: {
    html_url: string;
    login: string;
    avatar_url: string;
  };
}
// App.tsx
...
import { IState, Issue } from './Types';
...
.sort((a: Issue, b: Issue) => {

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.