How to fix Type assertion contradicts narrowed type in TypeScript | DevErrors