简体   繁体   中英

How to export type in typescript, it marks the type as undefined

I need to have my types in a separate file, where I create it and export it as default, like so:

type props = {
    playerId: string;
    isAutoplayPrevented: boolean;
}

// 'props' is not defined.eslint(no-undef)
export default props;

Although I have defined the props , I get an ESLint warning that props is undefined . Should I ignore that warning and stop ESLint complaint, like so: // eslint-disable-next-line no-undef

Or is there any other more proper solution ?

I offer you to consider a separated file for types and write types like below:

export type General = {
  classes: Record<string, string>,
};

export type AxiosCall = {
  // etc
};

// etc

For usage you can easily import it on other components.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM