-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code with and enforce strictNullChecks
This commit applies `strictNullChecks` to the entire codebase to improve maintainability and type safety. Key changes include: - Remove some explicit null-checks where unnecessary. - Add necessary null-checks. - Refactor static factory functions for a more functional approach. - Improve some test names and contexts for better debugging. - Add unit tests for any additional logic introduced. - Refactor `createPositionFromRegexFullMatch` to its own function as the logic is reused. - Prefer `find` prefix on functions that may return `undefined` and `get` prefix for those that always return a value.
- Loading branch information
1 parent
7ab16ec
commit 07d678f
Showing
283 changed files
with
2,367 additions
and
2,625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 19 additions & 19 deletions
38
src/application/Context/State/Filter/Event/FilterChange.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
import { IFilterResult } from '@/application/Context/State/Filter/IFilterResult'; | ||
import { FilterActionType } from './FilterActionType'; | ||
import { IFilterChangeDetails, IFilterChangeDetailsVisitor } from './IFilterChangeDetails'; | ||
import { | ||
IFilterChangeDetails, IFilterChangeDetailsVisitor, | ||
ApplyFilterAction, ClearFilterAction, | ||
} from './IFilterChangeDetails'; | ||
|
||
export class FilterChange implements IFilterChangeDetails { | ||
public static forApply(filter: IFilterResult) { | ||
if (!filter) { | ||
throw new Error('missing filter'); | ||
} | ||
return new FilterChange(FilterActionType.Apply, filter); | ||
public static forApply( | ||
filter: IFilterResult, | ||
): IFilterChangeDetails { | ||
return new FilterChange({ type: FilterActionType.Apply, filter }); | ||
} | ||
|
||
public static forClear() { | ||
return new FilterChange(FilterActionType.Clear); | ||
public static forClear(): IFilterChangeDetails { | ||
return new FilterChange({ type: FilterActionType.Clear }); | ||
} | ||
|
||
private constructor( | ||
public readonly actionType: FilterActionType, | ||
public readonly filter?: IFilterResult, | ||
) { } | ||
private constructor(public readonly action: ApplyFilterAction | ClearFilterAction) { } | ||
|
||
public visit(visitor: IFilterChangeDetailsVisitor): void { | ||
if (!visitor) { | ||
throw new Error('missing visitor'); | ||
} | ||
switch (this.actionType) { | ||
switch (this.action.type) { | ||
case FilterActionType.Apply: | ||
visitor.onApply(this.filter); | ||
if (visitor.onApply) { | ||
visitor.onApply(this.action.filter); | ||
} | ||
break; | ||
case FilterActionType.Clear: | ||
visitor.onClear(); | ||
if (visitor.onClear) { | ||
visitor.onClear(); | ||
} | ||
break; | ||
default: | ||
throw new Error(`Unknown action type: ${this.actionType}`); | ||
throw new Error(`Unknown action: ${this.action}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.