Skip to content

Type definition for ScrollBehavior appears to be wrong #28755

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
jglover opened this issue Nov 30, 2018 · 8 comments
Closed

Type definition for ScrollBehavior appears to be wrong #28755

jglover opened this issue Nov 30, 2018 · 8 comments

Comments

@jglover
Copy link

jglover commented Nov 30, 2018

Raising this here as per contribution guidelines for the TSJS-lib-generator repo
https://github.com/Microsoft/TSJS-lib-generator#contribution-guidelines
To confirm that this is indeed an issue before I open a PR to fix it over there.

TypeScript Version: 3.2.1

Search Terms:
instant
scrollbehavior
types
type defs
type definitions

Code
Sans react code

export class TestScrollTypeBug {    
  scrollToEnd(smooth: boolean = false) {
    const thing: HTMLDivElement = null
    thing.lastElementChild.scrollIntoView({
      block: 'end',
      inline: 'nearest',
      behavior: smooth 
        ? 'smooth' 
        : 'instant' 
    })
  }
}

Expected behavior:
scrollIntoViewOptions option behavior should allow the value 'instant' as it doesn't appear to be a deprecated value (according to MDN):
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

Actual behavior:
node_modules/typescript/lib/lib.dom.d.ts line 17972 is defined as
type ScrollBehavior = "auto" | "smooth";
previously the ScrollBehavior type was defined as
type ScrollBehavior = "auto" | "instant" | "smooth";
which seems to be correct.

Playground Link:
Here

Related Issues:

@jglover
Copy link
Author

jglover commented Nov 30, 2018

Closing as it looks like this is in fact correct.

microsoft/TypeScript-DOM-lib-generator@fe01c9a

MDN docs were just updated to reflect this.
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView$compare?locale=en-US&to=1440135&from=1438785

@DanielRuf
Copy link

This seems to be wrong / still broken for scrollTo: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo

@DanielRuf
Copy link

Will be fixed in 5.1: #47441 (comment)

@SleighJ
Copy link

SleighJ commented Oct 4, 2023

Currently on 5.2 and having this issue

@pauIbanez
Copy link

Is this still not added or re-broken?

@RyanCavanaugh
Copy link
Member

Please log a new issue using the appropriate template

@alp-ex
Copy link

alp-ex commented Mar 20, 2024

fixed in 5.1 as mentioned here 👌🏼
at least it's the correct type in 5.4.2

@Sebastp
Copy link

Sebastp commented Oct 7, 2024

still an issue for me

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

7 participants