Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/eslint-plugin/src/rules/no-unnecessary-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,13 +622,9 @@ export default createRule<Options, MessageId>({
if (prevType.isUnion()) {
const isOwnNullable = prevType.types.some(type => {
const signatures = type.getCallSignatures();
return signatures.some(sig =>
isNullableType(sig.getReturnType(), { allowUndefined: true }),
);
return signatures.some(sig => isNullableType(sig.getReturnType()));
});
return (
!isOwnNullable && isNullableType(prevType, { allowUndefined: true })
);
return !isOwnNullable && isNullableType(prevType);
}

return false;
Expand Down
16 changes: 1 addition & 15 deletions packages/type-utils/src/predicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,10 @@ import { isTypeFlagSet } from './typeFlagUtils';

const log = debug('typescript-eslint:eslint-plugin:utils:types');

export interface IsNullableTypeOptions {
/**
* @deprecated - this flag no longer does anything and will be removed in the next major
*/
isReceiver?: boolean;
/**
* @deprecated - this flag no longer does anything and will be removed in the next major
*/
allowUndefined?: boolean;
}

/**
* Checks if the given type is (or accepts) nullable
*/
export function isNullableType(
type: ts.Type,
_deprecated?: IsNullableTypeOptions,
): boolean {
export function isNullableType(type: ts.Type): boolean {
return isTypeFlagSet(
type,
ts.TypeFlags.Any |
Expand Down