-
Notifications
You must be signed in to change notification settings - Fork 6.8k
refactor(multiple): eliminate usages of any
type (batch 2)
#30613
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
Open
jamOne-
wants to merge
12
commits into
angular:main
Choose a base branch
from
jamOne-:eliminate-any-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9aa5b3d
fix(youtube-player): Eliminate `any` casts
jamOne- 597ddf7
fix(universal-app): ngDevMode always defined in hydration e2e test
jamOne- 65f8b7a
fix(google-maps): Replace any types with unknown
jamOne- b496d50
fix(universal-app): Add ElementItem interface
jamOne- e302c42
fix(material-moment-adapter): Replace any with unknowns
jamOne- 71861c4
fix(material-luxon-adapter): Replace any with unknown
jamOne- a709636
fix(date-fns-adapter): Replace any with unknown
jamOne- 85430b8
fix(material-experimental/column-resize): Add NumberMatchers interfac…
jamOne- 8e2c180
refactor(multiple): improve types
jamOne- 41c329b
build: add safevalues to pnpm-lock.yaml
jamOne- ee77411
build: revert pnpm-lock change
jamOne- 4554496
refactor(google-maps): improve `addListener` type
jamOne- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,7 +177,7 @@ export class LuxonDateAdapter extends DateAdapter<LuxonDateTime> { | |
return this._useUTC ? LuxonDateTime.utc(options) : LuxonDateTime.local(options); | ||
} | ||
|
||
parse(value: any, parseFormat: string | string[]): LuxonDateTime | null { | ||
parse(value: unknown, parseFormat: string | string[]): LuxonDateTime | null { | ||
const options: LuxonDateTimeOptions = this._getOptions(); | ||
|
||
if (typeof value == 'string' && value.length > 0) { | ||
|
@@ -245,7 +245,7 @@ export class LuxonDateAdapter extends DateAdapter<LuxonDateTime> { | |
* (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid DateTime and empty | ||
* string into null. Returns an invalid date for all other values. | ||
*/ | ||
override deserialize(value: any): LuxonDateTime | null { | ||
override deserialize(value: unknown): LuxonDateTime | null { | ||
const options = this._getOptions(); | ||
let date: LuxonDateTime | undefined; | ||
if (value instanceof Date) { | ||
|
@@ -263,7 +263,7 @@ export class LuxonDateAdapter extends DateAdapter<LuxonDateTime> { | |
return super.deserialize(value); | ||
} | ||
|
||
isDateInstance(obj: any): boolean { | ||
isDateInstance(obj: unknown): obj is LuxonDateTime { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here - isn't this definitely a |
||
return obj instanceof LuxonDateTime; | ||
} | ||
|
||
|
@@ -315,7 +315,7 @@ export class LuxonDateAdapter extends DateAdapter<LuxonDateTime> { | |
return date.second; | ||
} | ||
|
||
override parseTime(value: any, parseFormat: string | string[]): LuxonDateTime | null { | ||
override parseTime(value: unknown, parseFormat: string | string[]): LuxonDateTime | null { | ||
const result = this.parse(value, parseFormat); | ||
|
||
if ((!result || !this.isValid(result)) && typeof value === 'string') { | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we should keep this as
boolean
even thoughdate-fns
says it's returningvalue is Date
. Their implementation is clearly returning aboolean
, not aDate
-like object as it says here: https://github.com/date-fns/date-fns/blob/313b902b9a72c64501074db9bc2b9897d2db5140/src/isDate/index.ts#L33In their original javascript implementation, they document that it's returning a
boolean
too`. I think this might have been a mistake when they changed to TypeScript? https://github.com/date-fns/date-fns/blob/6ba1acc644a444092c672d0d0af33fbe8e7b9481/src/isDate/index.jsThere 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.
isDateInstance(obj: unknown): obj is Date
indicates thatisDateInstance
is a "type guard". This in practice means that the function returns aboolean
value, but also it narrows down the type of the passed argument (obj
in this case).If we had code like
https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards.
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.
Ohh okay interesting, thanks for explaining!