|
1 | 1 | import {isRegExp} from 'node:util/types'; |
2 | 2 | import {findVariable, getPropertyName} from '@eslint-community/eslint-utils'; |
3 | 3 | import {renameVariable} from './fix/index.js'; |
4 | | -import {combineBooleanStates, getPromisedTypeBooleanState, getTypeBooleanState} from './utils/get-type-boolean-state.js'; |
| 4 | +import {combineBooleanStates, getTypeBooleanState} from './utils/get-type-boolean-state.js'; |
5 | 5 | import resolveVariableName from './utils/resolve-variable-name.js'; |
6 | 6 | import {getBooleanWrapperVariableState} from './utils/get-boolean-wrapper-variable-state.js'; |
7 | 7 | import { |
@@ -677,16 +677,16 @@ function getPromisedTypeInformationBooleanState(node, context, allowNullish = tr |
677 | 677 | return unknown; |
678 | 678 | } |
679 | 679 |
|
680 | | - return nonNullableType.isUnion() |
681 | | - ? getPossiblyPromisedTypeBooleanState(nonNullableType, checker, allowNullish) |
682 | | - : getPromisedTypeBooleanState(nonNullableType, checker); |
| 680 | + return getPossiblyPromisedTypeBooleanState(nonNullableType, checker, allowNullish); |
683 | 681 | } catch { |
684 | 682 | return unknown; |
685 | 683 | } |
686 | 684 | } |
687 | 685 |
|
688 | 686 | function getPossiblyPromisedTypeBooleanState(type, checker, allowNullish) { |
689 | | - const awaitedType = checker.getAwaitedType(type); |
| 687 | + const awaitedType = type.isUnion() |
| 688 | + ? checker.getAwaitedType(type) |
| 689 | + : checker.getPromisedTypeOfPromise(type); |
690 | 690 | if (!awaitedType) { |
691 | 691 | return unknown; |
692 | 692 | } |
@@ -1796,21 +1796,7 @@ function getAsyncFunctionTypeInformationBooleanState(node, context, allowNullish |
1796 | 1796 | return unknown; |
1797 | 1797 | } |
1798 | 1798 |
|
1799 | | - if (nonNullableReturnType.isUnion()) { |
1800 | | - return getPossiblyPromisedTypeBooleanState(nonNullableReturnType, checker, allowNullish); |
1801 | | - } |
1802 | | - |
1803 | | - const promisedType = checker.getPromisedTypeOfPromise(nonNullableReturnType); |
1804 | | - if (!promisedType) { |
1805 | | - return unknown; |
1806 | | - } |
1807 | | - |
1808 | | - const nonNullableType = checker.getNonNullableType(promisedType); |
1809 | | - if (!allowNullish && nonNullableType !== promisedType) { |
1810 | | - return unknown; |
1811 | | - } |
1812 | | - |
1813 | | - return getTypeBooleanState(nonNullableType, checker, new Set(), false); |
| 1799 | + return getPossiblyPromisedTypeBooleanState(nonNullableReturnType, checker, allowNullish); |
1814 | 1800 | })); |
1815 | 1801 | } catch { |
1816 | 1802 | return unknown; |
|
0 commit comments