What is the difference between using as
or <>
in the code below?
Option A - use 'as' for the return value
convertResultToParams(columnView:IColumnViewResult):IColumnViewParams {
const params = {};
Object.keys(this.getDefaultParams())
.map(key => params[key] = columnView[key]);
return params as IColumnViewParams;
}
Option B - use 'brackets' for the return value
convertResultToParams(columnView:IColumnViewResult):IColumnViewParams {
const params = {};
Object.keys(this.getDefaultParams())
.map(key => params[key] = columnView[key]);
return <IColumnViewParams>params;
}
And why can't I just declare the type in the variable declaration?