Avatar ·

How to apply `@ts-ignore` for an entire block of code in TypeScript?

Hi everyone! I'm just starting to learn TypeScript and ran into a problem. I'm writing a small project that uses a third-party library, and it doesn't play well with TypeScript — it has no types, and I'm getting a bunch of errors in one place. Here's an example: I need to load some data from a JSON file that I import directly. TypeScript complains about implicit `any` and that object properties might be undefined. I know I can use `// @ts-ignore` before a specific line to suppress the error, but I have about 10-15 consecutive lines like this, and writing `// @ts-ignore` before each one is terribly inconvenient and clutters the code. I tried wrapping the problematic section in an `if` or using `as any`, but that doesn't always help, or the code becomes weird. Is there a way to apply `@ts-ignore` for an entire block of code?