I'm looking for a way to calculate what parts of my object types are actually in use throughout my codebase. Let's say I have the following in a types.ts file:
export type Animal = {
id: number;
name: string;
height: number;
isMammal: boolean;
}
And in another file I make an API call that returns an Animal:
const getAnimal: (id: number) => Promise<Animal>
And in two separate files, I call getAnimal and use the resulting Animal.
const animal1 = await getAnimal(1);
console.log(`Hi! Animal with id ${animal1.id} is named ${animal1.name}.`)
const animal1 = await getAnimal(1);
console.log(`This animal is ${animal1.height} feet tall.`)
But nowhere in my project do I use the isMammal property. How can I write a script that scans all of the files in my project and tells me that isMammal is not in use on the Animal type? Or alternatively, that only id, name, and height are?