-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[No QA][TS migration] Migrate 'Visibility' lib to TypeScript #27437
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type IsVisible = () => boolean; | ||
type HasFocus = () => boolean; | ||
type OnVisibilityChange = (callback: () => void) => () => void; | ||
|
||
export type {IsVisible, HasFocus, OnVisibilityChange}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// TODO: Move this type to desktop/contextBridge.js once it is converted to TS | ||
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. Can we link to the tracking issue for this? 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. Yes, here is a link to desktop files migration issue: #25333 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. Cool thanks, we could also link it here for clarity |
||
type ContextBridgeApi = { | ||
send: (channel: string, data?: unknown) => void; | ||
sendSync: (channel: string, data?: unknown) => unknown; | ||
invoke: (channel: string, ...args: unknown) => Promise<unknown>; | ||
on: (channel: string, func: () => void) => void; | ||
removeAllListeners: (channel: string) => void; | ||
}; | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface Window { | ||
electron: ContextBridgeApi; | ||
} | ||
} | ||
|
||
// We used the export {} line to mark this file as an external module | ||
export {}; |
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 don't think we had to remove the named function here.
function isVisible(): boolean
would be fine I guess.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.
From TS guidelines:
That's why
IsVisible
type was created in the first place and used here. I think the change was necessary.