Skip to content

Commit

Permalink
Merge pull request #26 from guillotinaweb/fix-implicit-any
Browse files Browse the repository at this point in the history
remove implicit any + add getView
  • Loading branch information
Mat Pellerin authored Jun 18, 2020
2 parents 881643d + 19876f4 commit 3bce993
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 1.2.5 (2020-06-18)

## Improvement
- Add getView selector [ebrehault]

## Bug fix
- Clean up implicit any [ebrehault]

# 1.2.4 (2020-06-08)

- No implicit return
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-state-traverser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@guillotinaweb/ngx-state-traverser",
"version": "1.2.4",
"version": "1.2.5",
"license": "MIT",
"author": {
"name": "Eric Brehault",
Expand Down
8 changes: 4 additions & 4 deletions projects/ngx-state-traverser/src/lib/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { TraverserActions } from './actions';
* @author inspired by [jhildenbiddle](https://stackoverflow.com/a/48218209).
* @source https://gist.github.com/ahtcx/0cd94e62691f539160b32ecda18af3d6#gistcomment-2930530
*/
export function deepMerge(target, source) {
const isObject = (obj) => obj && typeof obj === 'object';
export function deepMerge(target: any, source: any) {
const isObject = (obj: any) => obj && typeof obj === 'object';

if (!isObject(target) || !isObject(source)) {
return source;
Expand Down Expand Up @@ -67,7 +67,7 @@ export function reducer(state = initialState, action: TraverserActions.Actions):
}
}
case TraverserActions.Types.ResolveMany: {
const collection = action.payload.reduce((all, current) => {
const collection = action.payload.reduce((all: {[path: string]: any}, current) => {
let path = current.path;
if (!!path && path.endsWith('/')) {
path = path.slice(0, -1);
Expand All @@ -86,7 +86,7 @@ export function reducer(state = initialState, action: TraverserActions.Actions):
case TraverserActions.Types.CleanTraverserResources: {
const exactPathes = action.payload.filter(path => !path.endsWith('*'));
const startPathes = action.payload.filter(path => path.endsWith('*')).map(path => path.slice(0, -1));
const collection = Object.entries(state.collection).reduce((all, [path, obj]) => {
const collection = Object.entries(state.collection).reduce((all: {[path: string]: any}, [path, obj]) => {
if (!exactPathes.includes(path) && !startPathes.some(p => path.startsWith(p))) {
all[path] = obj;
}
Expand Down
7 changes: 6 additions & 1 deletion projects/ngx-state-traverser/src/lib/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export namespace TraverserSelectors {
(state: TraversingState): string => state.target.prefixedPath
);

export const getView = createSelector(
traversalSelector,
(state: TraversingState): string => state.target.view
);

export const isForbidden = createSelector(
traversalSelector,
(state: TraversingState): boolean => !!state.target.context.isForbidden
Expand Down Expand Up @@ -133,7 +138,7 @@ export namespace TraverserSelectors {
}, [] as string[]);

const ancestors: ContextOrMissing[] = ancestorPaths.map(ancestor => state.collection[ancestor] || new Missing(ancestor));
return ancestors.filter(ancestor => !ancestor['isForbidden']);
return ancestors.filter(ancestor => !(ancestor as any).isForbidden);
}
);

Expand Down

0 comments on commit 3bce993

Please sign in to comment.