Skip to content

Function parameter default values must not refer their own local scope (es spec violation) #18378

Closed
@falsandtru

Description

@falsandtru

Babel works correctly.

TypeScript Version: master

Code

f();

function f(o = {g}) {
  return console.log(o.g());

  function g() {
    return 1;
  }
}

function g() {
  return 0;
}

Expected behavior:

$ node built/local/tsc.js index.ts && node index.js
0
$ node index.ts
0

Actual behavior:

$ node built/local/tsc.js index.ts && node index.js
1
$ node index.ts
0

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions