Skip to content

Why Window.print() is removed? #22917

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

Closed
Delagen opened this issue Mar 27, 2018 · 19 comments
Closed

Why Window.print() is removed? #22917

Delagen opened this issue Mar 27, 2018 · 19 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@Delagen
Copy link

Delagen commented Mar 27, 2018

TypeScript Version: 2.8.1

Search Terms:

Code

window.print()

Expected behavior: No errors.

Actual behavior: TypeScript error missing property print in Window

Playground Link: https://www.typescriptlang.org/play/index.html#src=window.print()
Related Issues:

@Delagen
Copy link
Author

Delagen commented Mar 27, 2018

Commit with changes 67c7b36

@forestmaxime
Copy link

Issue is present in 2.8.0 also. The commit also removes functions that exists in standard. It would be a good idea to redo a full code review on this one.

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels Mar 27, 2018
@mhegazy mhegazy added this to the Community milestone Mar 27, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Mar 27, 2018

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

Delagen added a commit to Delagen/TypeScript that referenced this issue Mar 28, 2018
Delagen added a commit to Delagen/TypeScript that referenced this issue Mar 28, 2018
Delagen added a commit to Delagen/TypeScript that referenced this issue Mar 28, 2018
Delagen pushed a commit to Delagen/TypeScript that referenced this issue Mar 28, 2018
Delagen pushed a commit to Delagen/TypeScript that referenced this issue Mar 28, 2018
Delagen added a commit to Delagen/TypeScript that referenced this issue Mar 28, 2018
@Delagen
Copy link
Author

Delagen commented Mar 28, 2018

git under windows produces unpredictable amount of changes, sorry for so many commits. I need to strip changelog to single line

@mhegazy mhegazy modified the milestones: Community, TypeScript 2.8.2 Mar 28, 2018
@mhegazy mhegazy self-assigned this Mar 28, 2018
mhegazy added a commit to microsoft/TypeScript-DOM-lib-generator that referenced this issue Mar 28, 2018
@mhegazy mhegazy added Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet and removed Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet labels Mar 28, 2018
@mhegazy mhegazy added Fixed A PR has been merged for this issue and removed Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet labels Mar 28, 2018
@Delagen
Copy link
Author

Delagen commented Mar 29, 2018

Thanks. Sorry I don,t read carefully instriction, that describe separate process for 2 files

@evil-shrike
Copy link

evil-shrike commented Apr 4, 2018

Also methods onbeforeprint and onafterprint were moved from Window into WindowEventHandlers which isn't related to Window.
So it's a breaking change in 2.8.
Code

	window.onbeforeprint = beforePrint;
	window.onafterprint = afterPrint;

start failing to compile:
(533,11): error TS2339: Property 'onbeforeprint' does not exist on type 'Window'.
(534,11): error TS2339: Property 'onafterprint' does not exist on type 'Window'.
Please move them back into Window.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 4, 2018

@evil-shrike please file a new ticket for that one and will get it fixed.

@evil-shrike
Copy link

#23149

@Kurtz1993
Copy link

Kurtz1993 commented Apr 4, 2018

Issue is still present in TypeScript 2.8.1

image

I use my worskpace TypeScript version which is 2.8.1 instead of VS Code's version (2.7.2).

@mhegazy
Copy link
Contributor

mhegazy commented Apr 4, 2018

Issue is still present in TypeScript 2.8.1

yes. the fix is scheduled to be released in 2.8.2

@Kurtz1993
Copy link

Thanks @mhegazy !

@mangeshdesai26
Copy link

Thanks @mhegazy

@Delagen
Copy link
Author

Delagen commented Apr 19, 2018

@ps04639 You are wrong If you think that author of issue does not read TS docs

@simonprice33
Copy link

(window as any).print(); looks to get around the issue but is still not great as when it creates the js file it resolves to window.print()

I am working on the latest available TypeScript via Nuget and the issue is still present today

@Delagen
Copy link
Author

Delagen commented Apr 24, 2018

@simonprice33 What wrong in you answer, and what you expect?

@DevEddy1
Copy link

@simonprice33 I believe at the time of posting this, the latest TS version is 2.8.3. If you are using VSCode (currently ships/updates with 2.8.1) - you can update the TS version to the latest with the command "npm install -g [email protected]". Follow the voted answer here for more information: Stack Overflow - TS Version

@JaSpr
Copy link

JaSpr commented Jun 11, 2018

I'm using ts 2.9.1 and still getting this error.

Edit: Intellij is using 2.8.1 internally, which is causing the error. I don't see any way to change which version of typescript it is using internally. I've even told it to use the typescript under node_modules (which is 2.9.1) but the tab on IntelliJ still says "TypeScript 2.8.1".

That said, I am NOT having this issue in 2.9.1

@ChamilaMaddumage
Copy link

I am using this code snippet to print my PowerBI embedded report using Angular7 and getting following error.

let report = powerbi.get(reportContainer);

//Trigger the print dialog for your browser.
report .print()
.then(function (result) {
console.log(result);
})
.catch(function (errors) {
console.log(errors);
});

Error : [ts] property 'print' does not exist on type 'Embed'

@simonprice33
Copy link

@ChamilaMaddumage try (report as any).print() and see how you get on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

10 participants