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
{{ message }}
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Error:
Argument of type '{ size: number; label: string; }' is not assignable to parameter of type '{ label: string; }'.
Object literal may only specify known properties, and 'size' does not exist in type '{ label: string; }'.
My typesscript version is 1.7.5
Steps to recreate the Error:
Create a .ts file named script.ts
type the following code :
functionprintLabel(labelledObj: {label: string}){console.log(labelledObj.label);}varmyObj={size: 10,label: "Size 10 Object"};// myObj is of type {size:number;label:string}// printLabel(myObj);printLabel({size: 10,label: "Size 10 Object"});// the object being passed to printLabel is also of type {size:number;label:string}
Compile the script.ts using command tsc script either from command prompt/powershell
it is clearly mentioned in documentation that if we send extra arguments it is ok .please refer to attached code-snippet
But what is the difference if i assign an object to a variable , pass that variable as argument and if i directly pass the object as argument ?
Could you please at least add a warning message in the handbook like "Some of this information may be outdated"? I mean, I lost some time trying to figure out whats wrong with my code while following this handbook for learning typescript. A version warning message would be enough for considering the problem as a version incongruity.
From @jeevan-reddy on December 20, 2015 16:56
Error:
Argument of type '{ size: number; label: string; }' is not assignable to parameter of type '{ label: string; }'.
Object literal may only specify known properties, and 'size' does not exist in type '{ label: string; }'.
My typesscript version is 1.7.5
Steps to recreate the Error:
it is clearly mentioned in documentation that if we send extra arguments it is ok .please refer to attached code-snippet
![code-snippet](https://cloud.githubusercontent.com/assets/15384537/11918884/31811042-a767-11e5-8d3a-416edadc28e5.JPG)
But what is the difference if i assign an object to a variable , pass that variable as argument and if i directly pass the object as argument ?
Copied from original issue: microsoft/TypeScript#6175
The text was updated successfully, but these errors were encountered: