-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore: update typescript experience #10628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
now when using `types.isString` for example, typescript will understand that the arg is actually a string and propose intelisense afterward
10ff999
export function isObject(value: any): value is Record<string,any> { | ||
if (!value) { | ||
return false; | ||
} | ||
|
||
return typeof value === 'object'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an invalid type guard.
an array, date, regex, class would also result in true but is not of type Record<string, any>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farfromrefug you should take a look at this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@offizium-berndstorath indeed it would not work with Date/Regex ... However i dont think that s what that method was intended for seeing where it is used. In this case i think we should have a isDate, isRegex ...
I mean i dont see any place where isObject
would be called with a Date, Regex, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farfromrefug you are correct. these are not really what im concerned about. its mostly about array
now when using
types.isString
for example, typescript will understand that the arg is actually a string and propose intelisense afterwardPR Checklist
What is the current behavior?
What is the new behavior?
Fixes/Implements/Closes #[Issue Number].