Skip to content

ThisParameterType always unknown when strictFunctionTypes is disabled #32964

@fatcerberus

Description

@fatcerberus

TypeScript Version: 3.5.1

Search Terms: thisparametertype unknown

Code

interface Foo { blub: string };
function fn(this: Foo) {}

// with strictFunctionTypes ENABLED, this evaluates to Foo.
// with strictFunctionTypes DISABLED, it evaluates to unknown.
type Test = ThisParameterType<typeof fn>; 

Expected behavior:
ThisParameterType<typeof fn> should be Foo, regardless of strictFunctionTypes setting.

Actual behavior:
ThisParameterType<> evaluates to unknown, always, when strictFunctionTypes is disabled.

Playground Link:
https://www.typescriptlang.org/play/#code/JYOwLgpgTgZghgYwgAgGIHt3IN7IEYA2ArngFzIDOYUoA5sgL4DcAUDESAmMOiMjCAAUYABbAK5DOgCUOBixYB6RcgDuwUZWrAuqDlx4gAKgE8ADhArIAogDkAggCEAMtYAiAGmSjxyCADc4YjhIKzAsKQA6JRV1TSoaXX1uXlMLKzcASQBlJ1dPZA0-QODQ7ywOAGsQdFUQaLBzFCNLMGQAXmQjMQoABTgoOABbCEgoNIgAHkaLdBh+EAA+JmQWIA

Related Issues:
404: related issue not found

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions