Skip to content

Object.freeze pattern legal in 2.3, rejected in 2.4 #17711

Closed
@evmar

Description

@evmar

TypeScript Version: 2.4.2

Code

Object.freeze({
  foo() {
    return Object.freeze('a');
  },
});

(with --strict)

Expected behavior:
Accepted in 2.3 and 2.4.

Actual behavior:
In 2.4: 'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

Note that the TS playground currently is 2.3.3, so you can't reproduce this on there.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions