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

Missing "lock" method in ScreenOrientation #1615

Open
mistic100 opened this issue Aug 28, 2023 · 12 comments
Open

Missing "lock" method in ScreenOrientation #1615

mistic100 opened this issue Aug 28, 2023 · 12 comments

Comments

@mistic100
Copy link

I just updated from 5.1.3 to 5.2.2 and I cannot compile anymore because the "lock" method was removed from the ScreenOrientation interface.

I don't think this is correct.

This is the change https://github.com/microsoft/TypeScript/pull/54725/files#diff-dc0eab937d15e62545da3ed7b4f40ad6b24f15dd88fbc6ceda2bfb4ed8356eb0L20901

MDN : https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/lock

ping @sandersn

thanks

@mistic100
Copy link
Author

Hmm it seems it's because it falls under the "two major browsers" threshold since Firefox removed it (duh !). However Chrome Android having the majority of the smartphone market wouldn't it make sense to keep it ?

@richso
Copy link

richso commented Nov 24, 2023

for those who experience this compilation error, you may change to this alternative syntax to bypass the compiler error:

window.screen.orientation['lock']('landscape');

@tsukumijima
Copy link

@saschanaz
I am running into the same problem. This is an obvious regression and should be corrected ASAP.

@liyokuna
Copy link

hello,

I am facing this issue, can't wait for the fix.
the temp solution from @richso is not working on my angular project.

@eduardo-mior
Copy link

@liyokuna As a temporary solution I change the source codes of this lib inside VSCode, so the error stops happening, but every time I update VSCode I need to adjust the source code again, as the source code is inside the VScode folder installed on the my computer.

It's not a recommended solution, but this way VScode stops reporting unnecessary and incorrect errors. This only works for VScode.

@liyokuna
Copy link

liyokuna commented Jan 18, 2024

thanks for the answer but @eduardo-mior i'm on intelli j unfortunately :|

@mistic100
Copy link
Author

or just add // @ts-ignore before the line

@HolgerJeromin
Copy link

HolgerJeromin commented Jan 18, 2024

I think the correct way would be adding the now missing interface locally in one of your .ts or .d.ts files:

type OrientationLockType = "any" | "landscape" | "landscape-primary" | "landscape-secondary" | "natural" | "portrait" | "portrait-primary" | "portrait-secondary";
interface ScreenOrientation extends EventTarget {
    lock(orientation: OrientationLockType): Promise<void>;
}

@liyokuna
Copy link

yep did that, @mistic100 but i thnik my issue is maybe somewhere else in my ngular project...

@jakebailey
Copy link
Member

Placing that into a d.ts file included in your project will also augment the global types and allow things to work. You definitely do not need to be overwriting any files in VS Code or node_modules to add things to the globals like this.

@Knagis
Copy link

Knagis commented Feb 29, 2024

the main issue is that unlock is there, while lock was removed. even if there is a valid reason to remove lock, it should be consistent, since both of the methods have the same support.

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

8 participants