Skip to content

TS2448 Block-scoped variable used before its declaration #1870

@jfirebaugh

Description

@jfirebaugh

Steps to reproduce

export function foo() {
  const _fn = () => {
    ;(() => numFilesSelected)()
  }

  const numFilesSelected = 1
}

Behavior with typescript@5.9

No error.

Behavior with tsgo

test.tsx:3:13 - error TS2448: Block-scoped variable 'numFilesSelected' used before its declaration.

3     ;(() => numFilesSelected)()
              ~~~~~~~~~~~~~~~~

  test.tsx:6:9 - 'numFilesSelected' is declared here.
    6   const numFilesSelected = 1
              ~~~~~~~~~~~~~~~~

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