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

[Bug]: [Electron.d.ts][gn-typescript-definitions][Invalid type annotations] Electron.PrintToPDFOptions > Margins #276

Open
3 tasks done
eezz4 opened this issue Jan 20, 2024 · 3 comments

Comments

@eezz4
Copy link

eezz4 commented Jan 20, 2024

Preflight Checklist

Electron Version

28.1.2

What operating system are you using?

Windows

Operating System Version

all

What arch are you using?

x64

Last Known Working Electron version

28.1.2

Expected Behavior

Electron.PrintToPDFOptions > Margins

web-contents.md, webview-tag.md file

#### `contents.print([options], [callback])`
### `<webview>.print([options])`
* `options` Object (optional)
  * `margins` Object (optional)
    * `marginType` string (optional) - Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen, you will also need to specify `top`, `bottom`, `left`, and `right`.
    * `top` number (optional) - The top margin of the printed web page, in pixels.
    * `bottom` number (optional) - The bottom margin of the printed web page, in pixels.
    * `left` number (optional) - The left margin of the printed web page, in pixels.
    * `right` number (optional) - The right margin of the printed web page, in pixels.
#### `contents.printToPDF(options)`
### `<webview>.printToPDF(options)`
* `options` Object
  * `marginsToPDF` Object (optional)
    * `top` number (optional) - Top margin in inches. Defaults to 1cm (~0.4 inches).
    * `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
    * `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
    * `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).

Actual Behavior

The docs are different, the gn-typescript-definitions script only creates one 'Margins'.

  interface WebContentsPrintOptions {
    ...
    margins?: Margins;
    ...
  }
  interface PrintToPDFOptions {
    ...
    margins?: Margins;
    ...
  }
  interface WebviewTagPrintOptions {
    ...
    margins?: Margins;
    ...
  }

  interface Margins {
    /**
     * Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
     * you will also need to specify `top`, `bottom`, `left`, and `right`.
     */
    marginType?: ('default' | 'none' | 'printableArea' | 'custom');
    /**
     * The top margin of the printed web page, in pixels.
     */
    top?: number;
    /**
     * The bottom margin of the printed web page, in pixels.
     */
    bottom?: number;
    /**
     * The left margin of the printed web page, in pixels.
     */
    left?: number;
    /**
     * The right margin of the printed web page, in pixels.
     */
    right?: number;
  }

Testcase Gist URL

No response

Additional Information

No response

@eezz4 eezz4 changed the title [Bug]: [Electron.d.ts] confilct type Electron.PrintToPDFOptions > Margins [Bug]: [Electron.d.ts][gn-typescript-definitions][Invalid type annotations] Electron.PrintToPDFOptions > Margins Jan 20, 2024
@codebytere codebytere transferred this issue from electron/electron Jan 29, 2024
@codebytere
Copy link
Member

@eezz4 the issue originates here so i've gone ahead and transferred it. Just to confirm - you put the erring version as 28.1.2 and the last working version as 28.1.2; they shouldn't be the same as one indicates the last version it worked and one the verrsion it's not working. Did this ever generate expected documentation?

@eezz4
Copy link
Author

eezz4 commented Jan 29, 2024

@codebytere

Sorry, I was wrong about the Last Known Working Electron version!

When I analyzed the gn-typescript-definitions script, it seems to be parsing the doc to create electron.d.ts.

It appears that docs-parser doesn't support this case of duplication.

@MarshallOfSound MarshallOfSound transferred this issue from electron/docs-parser Sep 23, 2024
@MarshallOfSound
Copy link
Member

Moved this over to typescript-definitions as that module is what tries to do smart "deduplication" of common structures.

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

No branches or pull requests

3 participants