4 ms·
And still there are coders who prefer non-statically typed languages, tsk tsk...
by pif 1y ago
And still there are coders who prefer non-statically typed languages, tsk tsk...
- tantalor 1y agoExplain how static typing would avoid this problem.
- jwolfe 1y agoIf you use the standard typescript linter, it will fail if you pass a Promise to an if statement. https://typescript-eslint.io/rules/no-misused-promises/ https://typescript-eslint.io/rules/no-misused-promises/
- b_e_n_t_o_n 1y agoThe problem was the framework's bundler was transforming those functions to return promises, a linter would need to understand next.js's specific transforms to catch this.
- pif 1y agoA function returning a boolean cannot return a Promise. As simple as that!
- tantalor 1y agoSure but if the framework also changes the signature of the function, there's nothing compiler can do. Unless you want it to catch `if(promise)`