ts-reset
ts-reset copied to clipboard
Added improved typings for Array.every
This PR adds improved typings to Array.every when using the Boolean constructor, in a way that's very similar to what's already being done for Array.filter.
After extensive testing, these types seem to always behave as expected, narrowing the type of the array or tuple down as much as possible (possibly even to never).
I haven't added this feature to recommended.d.ts because I'd like to have some feedback on this first, but I feel like it would make sense to add it there since this is very much in line with the Array.filter improvements, which are recommended.
Nevermind, these typings seem to break any project importing typescript, for me it's happening with the following error:
node_modules/typescript/lib/typescript.d.ts:6558:15 - error TS2430: Interface 'JsonSourceFile' incorrectly extends interface 'SourceFile'.
Types of property 'statements' are incompatible.
Type 'NodeArray<JsonObjectExpressionStatement>' is not assignable to type 'NodeArray<Statement>'.
Type 'Statement' is missing the following properties from type 'JsonObjectExpressionStatement': expression, _flowContainerBrand
6558 interface JsonSourceFile extends SourceFile {
~~~~~~~~~~~~~~
Found 1 error in node_modules/typescript/lib/typescript.d.ts:6558
Converting this to a draft until I've figured out a solution.
This should do it, as far as I can tell there are no further regressions in the codebases I've tested