-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFixedA PR has been merged for this issueA PR has been merged for this issue
Description
TypeScript Version: 3.3.0-dev.20181207
Search Terms: bind generic strict
Code
class SomeClass {
constructor() {
this.genericMethod = this.genericMethod.bind(this);
// TS2322: Type '(callback: (p: {}) => {}) => void' is not
// assignable to type '<T>(callback: (p: T) => T) => void':
this.genericWithCallback = this.genericWithCallback.bind(this);
}
genericMethod<T>(p: T): void { }
genericWithCallback<T>(callback: (p: T) => T): void { }
}
Compile with tsc TypeScriptIssue.ts --target es6 --strictBindCallApply
Expected behavior:
No compile error
Actual behavior:
error TS2322: Type '(callback: (p: {}) => {}) => void' is not assignable to type '<T>(callback: (p: T) => T) => void'.
Types of parameters 'callback' and 'callback' are incompatible.
Types of parameters 'p' and 'p' are incompatible.
Type '{}' is not assignable to type 'T'.
Playground Link: (no --strictBindCallApply flag available)
Related issues:
krishan
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFixedA PR has been merged for this issueA PR has been merged for this issue