refactor(@angular-devkit/schematic): replace any with unknown#18541
refactor(@angular-devkit/schematic): replace any with unknown#18541santoshyadavdev wants to merge 1 commit intoangular:masterfrom
Conversation
4c23dbc to
6f43fc0
Compare
6f43fc0 to
7b177a2
Compare
| const kind = act && act.kind; | ||
|
|
||
| return typeof action === 'object' | ||
| && typeof act.hasOwnProperty('kind') |
There was a problem hiding this comment.
| && typeof act.hasOwnProperty('kind') |
| export function isAction(action: any): action is Action { // tslint:disable-line:no-any | ||
| const kind = action && action.kind; | ||
| export function isAction(action: unknown): action is Action { | ||
| const act = action as Action; |
There was a problem hiding this comment.
In all fairness I am not a big fan of this casting here, as this is hiding potential errors.
There was a problem hiding this comment.
Something like seems to be more "correct", but wondering if we should just stop at hasOwnProperty since it's the object has those 3 props it's should be an action.
export function isAction(action: unknown): action is Action {
if (
action
&& typeof action === 'object'
&& action.hasOwnProperty('path')
&& action.hasOwnProperty('id')
&& action.hasOwnProperty('kind')
) {
const { kind, id, path } = action as { id: unknown, path: unknown, kind: unknown };
if (
typeof kind === 'string'
&& ['c', 'o', 'r', 'd'].includes(kind)
&& typeof id === 'number'
&& typeof path === 'string'
) {
return true;
}
}
return false;
}//cc @clydin what do you think?
There was a problem hiding this comment.
based on the usage of the function, I think we should consider deprecating it and leaving it as-is for now. I put together a PR that removes the only use internally: #18637
There was a problem hiding this comment.
@santoshyadavdev, mind opening a separate PR to deprecate the this method?
There was a problem hiding this comment.
Ahh cool @alan-agius4 will do that today.
There was a problem hiding this comment.
@alan-agius4 please see #18727, should I close this one.
There was a problem hiding this comment.
Thanks, I’ll close it for you.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.