You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceIBookStyle{initialLeftPageTransforms?: (width: number)=>NamedTransform[];}interfaceNamedTransform{[name: string]: Transform3D;}interfaceTransform3D{cachedCss: string;}varstyle: IBookStyle={initialLeftPageTransforms: (width: number)=>{return[{'ry': null}];}}//!!!Type '{ initialLeftPageTransforms: (width: number) => { 'ry': any; }[]; }' is not assignable to type 'IBookStyle'://!!!Types of property 'initialLeftPageTransforms' of types '{ initialLeftPageTransforms: (width: number) => { 'ry': any; }[]; }' and 'IBookStyle' are incompatible://!!!Call signatures of types '(width: number) => { 'ry': any; }[]' and '(width: number) => NamedTransform[]' are incompatible://!!!Types of property 'pop' of types '{ 'ry': any; }[]' and 'NamedTransform[]' are incompatible://!!!Call signatures of types '() => { 'ry': any; }' and '() => NamedTransform' are incompatible://!!!Index signatures of types '{ 'ry': any; }' and 'NamedTransform' are incompatible.
Expected: errors as above
Actual: no errors
The text was updated successfully, but these errors were encountered:
This is because of the type annotation on width, causing the return expression to not be contextually typed. It might make sense for the return expression to be contextually typed, even in the presence of parameter annotations.
Changing to spec issue. In the old compiler we would contextually type the return value of a function expression only if the function expression had no parameter or return type annotations. The new compiler contextually types the return value when the function expression has no return type annotation, regardless of whether there are parameter type annotations. We previously discussed this and agreed we want the new behavior. Spec sections affected are 4.9.3 and 4.19.
ahejlsberg
changed the title
[Errors] contextually typed return types of array types
[Spec] contextually typed return types of array types
Jul 17, 2014
sophiajt
changed the title
[Spec] contextually typed return types of array types
[Spec] contextually typed return types of function expression types
Jul 18, 2014
sophiajt
changed the title
[Spec] contextually typed return types of function expression types
[Spec] contextual typing of return expression values
Jul 18, 2014
Expected: errors as above
Actual: no errors
The text was updated successfully, but these errors were encountered: