Skip to content

flip sides source and target when we check signature relations#7328

Merged
vladima merged 1 commit into
masterfrom
flipSidesInSignatureCheck
Mar 2, 2016
Merged

flip sides source and target when we check signature relations#7328
vladima merged 1 commit into
masterfrom
flipSidesInSignatureCheck

Conversation

@vladima
Copy link
Copy Markdown
Contributor

@vladima vladima commented Mar 1, 2016

and report errors during contravariant check. This is partial rollback of 5e69332 that introduced perf regressions #7293, #7082.

Note: errors in baselines has changed but personally I like new errors more since they more accurately reflect runtime behavior. I.e.

let a: (s: string) => void;
let b: (s: number) => void;
a = b;
// a("42");

used to be

t.ts(3,1): error TS2322: Type '(s: number) => void' is not assignable to type '(s: string) => void'.
  Types of parameters 's' and 's' are incompatible.
    Type 'number' is not assignable to type 'string'.

now

t.ts(3,1): error TS2322: Type '(s: number) => void' is not assignable to type '(s: string) => void'.
  Types of parameters 's' and 's' are incompatible.
    Type 'string' is not assignable to type 'number'.

In runtime a will have argument of type string that is not assignable to type number that is expected by b and this is exactly what is said in new error message.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Mar 2, 2016

👍

2 similar comments
@DanielRosenwasser
Copy link
Copy Markdown
Member

👍

@RyanCavanaugh
Copy link
Copy Markdown
Member

👍

vladima added a commit that referenced this pull request Mar 2, 2016
flip sides source and target when we check signature relations
@vladima vladima merged commit f34dcdd into master Mar 2, 2016
vladima added a commit that referenced this pull request Mar 3, 2016
@vladima vladima deleted the flipSidesInSignatureCheck branch March 14, 2016 03:54
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants