Skip to content
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

chore: tsify web-contents #24325

Merged
merged 10 commits into from Jul 6, 2020
Merged

chore: tsify web-contents #24325

merged 10 commits into from Jul 6, 2020

Conversation

nornagon
Copy link
Member

Also, deleted WebContents.sendToAll which isn't documented or used anywhere.

Notes: none

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jun 26, 2020
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jun 27, 2020
@@ -67,8 +75,8 @@ const PDFPageSizes = {
// Default printing setting
const defaultPrintingSetting = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of all the as casts below we should type this as Electron.WhateverThePrintingSettingsInterfaceIs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there exists any type in electron.d.ts that matches this.

$ rg '\bpageRange\b'
lib/browser/api/web-contents.ts
78:  pageRange: [] as {from: number, to: number}[],
279:    printSettings.pageRange = [{
$

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nornagon That's because according to the docs it's pageRanges

Copy link
Member Author

@nornagon nornagon Jul 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also true of several other members of this struct:

$ rg '\bshouldPrintBackgrounds\b'
lib/browser/api/web-contents.ts
84:  shouldPrintBackgrounds: false,
258:    printSettings.shouldPrintBackgrounds = options.printBackground;
$ rg '\bheaderFooterEnabled\b'
lib/browser/api/web-contents.ts
81:  headerFooterEnabled: false,
287:    printSettings.headerFooterEnabled = true;
$ rg '\bgenerateDraftData\b'
lib/browser/api/web-contents.ts
96:  generateDraftData: true,
$

I don't think the struct you're thinking of is the same as this struct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the type of this struct is related to these

@@ -360,14 +357,14 @@ WebContents.prototype.print = function (options = {}, callback) {
throw new Error('height and width properties are required for pageSize');
}
// Dimensions in Microns - 1 meter = 10^6 microns
options.mediaSize = {
(options as any).mediaSize = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These any casts shouldn't be needed if the original options object is typed correctly

@nornagon nornagon merged commit 1f23807 into master Jul 6, 2020
@release-clerk
Copy link

release-clerk bot commented Jul 6, 2020

No Release Notes

@nornagon nornagon deleted the tsify-web-contents branch July 6, 2020 17:50
sentialx pushed a commit to sentialx/electron that referenced this pull request Jul 30, 2020
sentialx pushed a commit to sentialx/electron that referenced this pull request Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants