tslib icon indicating copy to clipboard operation
tslib copied to clipboard

feat: Add type information to `__assign(…)` helper function

Open ExE-Boss opened this issue 5 years ago • 4 comments

This adds typed overloads to __assign, along with a TSDoc comment copied from lib.es2015.core.d.ts#ObjectConstructor.assign(…).


review?(@DanielRosenwasser)

ExE-Boss avatar Jan 06 '20 01:01 ExE-Boss

Is there any particular reason you're looking to type these more strictly?

DanielRosenwasser avatar Jan 15 '20 07:01 DanielRosenwasser

Well, I’d like to eventually add type information to all TSLib helpers.

ExE-Boss avatar Jan 15 '20 07:01 ExE-Boss

But is there a benefit? This code generally doesn't get consumed by users, and specifically this function has a hard time being accurately typed.

DanielRosenwasser avatar Jan 15 '20 07:01 DanielRosenwasser

Well, this function acts as an alias for Object.assign if it exists, and uses an approximate implementation if it doesn’t, like in an ES3 environment, which is why I just copied the type information from that.

Arguably, it should be defined as:

export declare var __assign: typeof Object.assign;

ExE-Boss avatar Jan 15 '20 07:01 ExE-Boss