Skip to content

Type definition for ScrollBehavior appears to be wrong #28755

Closed

Description

@jglover

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:

Activity

  1. jglover commented on Nov 30, 2018

    @jglover
    Author
  2. DanielRuf commented on Jun 19, 2023

    @DanielRuf

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

  3. DanielRuf commented on Jun 19, 2023

    @DanielRuf

    Will be fixed in 5.1: #47441 (comment)

  4. SleighJ commented on Oct 4, 2023

    @SleighJ

    Currently on 5.2 and having this issue

  5. pauIbanez commented on Mar 14, 2024

    @pauIbanez

    Is this still not added or re-broken?

  6. RyanCavanaugh commented on Mar 14, 2024

    @RyanCavanaugh
    Member

    Please log a new issue using the appropriate template

  7. alp-ex commented on Mar 20, 2024

    @alp-ex

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

  8. Sebastp commented on Oct 7, 2024

    @Sebastp

    still an issue for me

  9. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions