types-4-strapi-2
types-4-strapi-2 copied to clipboard
'ExtractNested' is declared but its value is never read.
When running the following script
"typegen": "t4s -o ./src/types -r load-strapi --prettier .prettierrc"
It outputs the following file in src/types/builtins/Media.ts
import { IMediaFormat } from './MediaFormat';
import { ExtractNested } from './ExtractNested';
import { ExtractFlat } from './ExtractFlat';
import { RequiredBy } from './RequiredBy';
export interface IMedia<Populate extends string | never = never> {
id: number;
attributes: RequiredBy<
{
formats?: {
thumbnail?: IMediaFormat | null;
large?: IMediaFormat | null;
medium?: IMediaFormat | null;
small?: IMediaFormat | null;
} | null;
name: string;
hash: string;
ext: string;
mime: string;
url: string;
provider: string;
previewUrl: string | null;
provider_metadata: string | null;
alternativeText: string | null;
caption: string | null;
width: number | null;
height: number | null;
size: number;
},
ExtractFlat<Populate>
>;
}
It imports ExtractNested
, but is never used.
Which causes the Strapi app to exit, and because I Generate interfaces as soon as you create/modify/delete new components or content types the Strapi application exists everytime I create, updated or delete a collection.
Current solution is use an eslint plugin eslint-plugin-unused-imports and running a eslint --fix ./src/types --ext .js,.jsx,.ts,.tsx
command after my typegen
command in my src/extensions/content-type-builder/strapi-server.ts
file. This will remove the unused import and prevent the Strapi app from exiting.