-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Object rest #12028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object rest #12028
Changes from all commits
a7c1836
e3a08ed
ac20b46
9d4ddb6
7ff8876
7ed5204
14f8b99
c9c5f49
71f3157
cc342d1
4337369
4c365bd
609cd00
9977936
214ce38
0196947
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,14 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | |
return t; | ||
};`; | ||
|
||
const restHelper = ` | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will need to add this to https://github.com/Microsoft/tslib There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also you will need a check in checker.ts for __rest and __assign, and add some tests for these. |
||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) | ||
t[p] = s[p]; | ||
return t; | ||
};`; | ||
|
||
// emit output for the __decorate helper function | ||
const decorateHelper = ` | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
|
@@ -226,6 +234,7 @@ const _super = (function (geti, seti) { | |
let currentFileIdentifiers: Map<string>; | ||
let extendsEmitted: boolean; | ||
let assignEmitted: boolean; | ||
let restEmitted: boolean; | ||
let decorateEmitted: boolean; | ||
let paramEmitted: boolean; | ||
let awaiterEmitted: boolean; | ||
|
@@ -2222,6 +2231,11 @@ const _super = (function (geti, seti) { | |
assignEmitted = true; | ||
} | ||
|
||
if (languageVersion < ScriptTarget.ESNext && !restEmitted && node.flags & NodeFlags.HasRestAttribute) { | ||
writeLines(restHelper); | ||
restEmitted = true; | ||
} | ||
|
||
if (!decorateEmitted && node.flags & NodeFlags.HasDecorators) { | ||
writeLines(decorateHelper); | ||
if (compilerOptions.emitDecoratorMetadata) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we removing private? it will exist at runtime, we do not create it as enumerable: false, and it not a parent property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well.. this is actually different from what we do with
keyof
where we filter privates as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spread also removes privates. It's the right thing to do there, and I think it is here too:
I don't think
exposed
should be an easy way to get all ofP
's private members.