TypeScript type ignore case

NEW ANSWER FOR TYPESCRIPT 4.1+ Welcome back! Now that TypeScript 4.1 has introduced template literal types and the Uppercase/Lowercase intrinsic string mapping types, we can now answer this question without needing regular expression types. There are two main approaches. The “brute force” approach makes heavy use of recursive conditional types and unions to turn your … Read more

How to declare a Map type in typescript?

The error message you are describing occurs in a declaration file. To make this work, you need remove the semi-colon at the end of your interface declaration: interface DependData { [key: string]: string; } The extra semi-colon is causing an empty statement to be parsed in addition to the interface declaration, thus giving that error … Read more

Why does accessing a property of indexOf still compile?

Quite easy. someArray.indexOf you know that this is a function, which is also an object and can have properties. By doing someArray.indexOf[someObject], you are trying to reach the property with the key valued to the value of someObject. Of course, it is not defined on the indexOf function, so it returns undefined. Quick example that … Read more

error TS2403: Subsequent variable declarations must have the same type

In my case it was @types/node that was triggering the error on AbortSignal type declaration. In some of my projects, a fresh (re)install of @types/node to latest version fixed the bug In some others, I have uninstalled @types/node which was probably duplicated somewhere. Doing so didn’t change anything at my dev workflow (not sure why … Read more

Optional typed immediately destructured parameters?

Presumably you’re unhappy about the following error: const fooBad = ({ bar }?: { bar?: boolean }) => {}; // error! // ┌──────────> ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // A binding pattern parameter cannot be optional in an implementation signature. Which makes sense, because you can’t destructure undefined. What you can do, in TypeScript, is to use a default … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)