forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdestructuring.ts
568 lines (535 loc) · 28.7 KB
/
destructuring.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
/*@internal*/
namespace ts {
interface FlattenContext {
context: TransformationContext;
level: FlattenLevel;
downlevelIteration: boolean;
hoistTempVariables: boolean;
emitExpression: (value: Expression) => void;
emitBindingOrAssignment: (target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) => void;
createArrayBindingOrAssignmentPattern: (elements: BindingOrAssignmentElement[]) => ArrayBindingOrAssignmentPattern;
createObjectBindingOrAssignmentPattern: (elements: BindingOrAssignmentElement[]) => ObjectBindingOrAssignmentPattern;
createArrayBindingOrAssignmentElement: (node: Identifier) => BindingOrAssignmentElement;
visitor?: (node: Node) => VisitResult<Node>;
}
export const enum FlattenLevel {
All,
ObjectRest,
}
/**
* Flattens a DestructuringAssignment or a VariableDeclaration to an expression.
*
* @param node The node to flatten.
* @param visitor An optional visitor used to visit initializers.
* @param context The transformation context.
* @param level Indicates the extent to which flattening should occur.
* @param needsValue An optional value indicating whether the value from the right-hand-side of
* the destructuring assignment is needed as part of a larger expression.
* @param createAssignmentCallback An optional callback used to create the assignment expression.
*/
export function flattenDestructuringAssignment(
node: VariableDeclaration | DestructuringAssignment,
visitor: ((node: Node) => VisitResult<Node>) | undefined,
context: TransformationContext,
level: FlattenLevel,
needsValue?: boolean,
createAssignmentCallback?: (name: Identifier, value: Expression, location?: TextRange) => Expression): Expression {
let location: TextRange = node;
let value: Expression;
if (isDestructuringAssignment(node)) {
value = node.right;
while (isEmptyArrayLiteral(node.left) || isEmptyObjectLiteral(node.left)) {
if (isDestructuringAssignment(value)) {
location = node = value;
value = node.right;
}
else {
return visitNode(value, visitor, isExpression);
}
}
}
let expressions: Expression[];
const flattenContext: FlattenContext = {
context,
level,
downlevelIteration: context.getCompilerOptions().downlevelIteration,
hoistTempVariables: true,
emitExpression,
emitBindingOrAssignment,
createArrayBindingOrAssignmentPattern: makeArrayAssignmentPattern,
createObjectBindingOrAssignmentPattern: makeObjectAssignmentPattern,
createArrayBindingOrAssignmentElement: makeAssignmentElement,
visitor
};
if (value) {
value = visitNode(value, visitor, isExpression);
if (isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText)) {
// If the right-hand value of the assignment is also an assignment target then
// we need to cache the right-hand value.
value = ensureIdentifier(flattenContext, value, /*reuseIdentifierExpressions*/ false, location);
}
else if (needsValue) {
// If the right-hand value of the destructuring assignment needs to be preserved (as
// is the case when the destructuring assignment is part of a larger expression),
// then we need to cache the right-hand value.
//
// The source map location for the assignment should point to the entire binary
// expression.
value = ensureIdentifier(flattenContext, value, /*reuseIdentifierExpressions*/ true, location);
}
else if (nodeIsSynthesized(node)) {
// Generally, the source map location for a destructuring assignment is the root
// expression.
//
// However, if the root expression is synthesized (as in the case
// of the initializer when transforming a ForOfStatement), then the source map
// location should point to the right-hand value of the expression.
location = value;
}
}
flattenBindingOrAssignmentElement(flattenContext, node, value, location, /*skipInitializer*/ isDestructuringAssignment(node));
if (value && needsValue) {
if (!some(expressions)) {
return value;
}
expressions.push(value);
}
return aggregateTransformFlags(inlineExpressions(expressions)) || createOmittedExpression();
function emitExpression(expression: Expression) {
// NOTE: this completely disables source maps, but aligns with the behavior of
// `emitAssignment` in the old emitter.
setEmitFlags(expression, EmitFlags.NoNestedSourceMaps);
aggregateTransformFlags(expression);
expressions = append(expressions, expression);
}
function emitBindingOrAssignment(target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) {
Debug.assertNode(target, createAssignmentCallback ? isIdentifier : isExpression);
const expression = createAssignmentCallback
? createAssignmentCallback(<Identifier>target, value, location)
: setTextRange(
createAssignment(visitNode(<Expression>target, visitor, isExpression), value),
location
);
expression.original = original;
emitExpression(expression);
}
}
function bindingOrAssignmentElementAssignsToName(element: BindingOrAssignmentElement, escapedName: __String): boolean {
const target = getTargetOfBindingOrAssignmentElement(element);
if (isBindingOrAssignmentPattern(target)) {
return bindingOrAssignmentPatternAssignsToName(target, escapedName);
}
else if (isIdentifier(target)) {
return target.escapedText === escapedName;
}
return false;
}
function bindingOrAssignmentPatternAssignsToName(pattern: BindingOrAssignmentPattern, escapedName: __String): boolean {
const elements = getElementsOfBindingOrAssignmentPattern(pattern);
for (const element of elements) {
if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
return true;
}
}
return false;
}
/**
* Flattens a VariableDeclaration or ParameterDeclaration to one or more variable declarations.
*
* @param node The node to flatten.
* @param visitor An optional visitor used to visit initializers.
* @param context The transformation context.
* @param boundValue The value bound to the declaration.
* @param skipInitializer A value indicating whether to ignore the initializer of `node`.
* @param hoistTempVariables Indicates whether temporary variables should not be recorded in-line.
* @param level Indicates the extent to which flattening should occur.
*/
export function flattenDestructuringBinding(
node: VariableDeclaration | ParameterDeclaration,
visitor: (node: Node) => VisitResult<Node>,
context: TransformationContext,
level: FlattenLevel,
rval?: Expression,
hoistTempVariables?: boolean,
skipInitializer?: boolean): VariableDeclaration[] {
let pendingExpressions: Expression[];
const pendingDeclarations: { pendingExpressions?: Expression[], name: BindingName, value: Expression, location?: TextRange, original?: Node; }[] = [];
const declarations: VariableDeclaration[] = [];
const flattenContext: FlattenContext = {
context,
level,
downlevelIteration: context.getCompilerOptions().downlevelIteration,
hoistTempVariables,
emitExpression,
emitBindingOrAssignment,
createArrayBindingOrAssignmentPattern: makeArrayBindingPattern,
createObjectBindingOrAssignmentPattern: makeObjectBindingPattern,
createArrayBindingOrAssignmentElement: makeBindingElement,
visitor
};
if (isVariableDeclaration(node)) {
let initializer = getInitializerOfBindingOrAssignmentElement(node);
if (initializer && isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText)) {
// If the right-hand value of the assignment is also an assignment target then
// we need to cache the right-hand value.
initializer = ensureIdentifier(flattenContext, initializer, /*reuseIdentifierExpressions*/ false, initializer);
node = updateVariableDeclaration(node, node.name, node.type, initializer);
}
}
flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
if (pendingExpressions) {
const temp = createTempVariable(/*recordTempVariable*/ undefined);
if (hoistTempVariables) {
const value = inlineExpressions(pendingExpressions);
pendingExpressions = undefined;
emitBindingOrAssignment(temp, value, /*location*/ undefined, /*original*/ undefined);
}
else {
context.hoistVariableDeclaration(temp);
const pendingDeclaration = lastOrUndefined(pendingDeclarations);
pendingDeclaration.pendingExpressions = append(
pendingDeclaration.pendingExpressions,
createAssignment(temp, pendingDeclaration.value)
);
addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
pendingDeclaration.value = temp;
}
}
for (const { pendingExpressions, name, value, location, original } of pendingDeclarations) {
const variable = createVariableDeclaration(
name,
/*type*/ undefined,
pendingExpressions ? inlineExpressions(append(pendingExpressions, value)) : value
);
variable.original = original;
setTextRange(variable, location);
if (isIdentifier(name)) {
setEmitFlags(variable, EmitFlags.NoNestedSourceMaps);
}
aggregateTransformFlags(variable);
declarations.push(variable);
}
return declarations;
function emitExpression(value: Expression) {
pendingExpressions = append(pendingExpressions, value);
}
function emitBindingOrAssignment(target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) {
Debug.assertNode(target, isBindingName);
if (pendingExpressions) {
value = inlineExpressions(append(pendingExpressions, value));
pendingExpressions = undefined;
}
pendingDeclarations.push({ pendingExpressions, name: <BindingName>target, value, location, original });
}
}
/**
* Flattens a BindingOrAssignmentElement into zero or more bindings or assignments.
*
* @param flattenContext Options used to control flattening.
* @param element The element to flatten.
* @param value The current RHS value to assign to the element.
* @param location The location to use for source maps and comments.
* @param skipInitializer An optional value indicating whether to include the initializer
* for the element.
*/
function flattenBindingOrAssignmentElement(
flattenContext: FlattenContext,
element: BindingOrAssignmentElement,
value: Expression | undefined,
location: TextRange,
skipInitializer?: boolean) {
if (!skipInitializer) {
const initializer = visitNode(getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, isExpression);
if (initializer) {
// Combine value and initializer
value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer;
}
else if (!value) {
// Use 'void 0' in absence of value and initializer
value = createVoidZero();
}
}
const bindingTarget = getTargetOfBindingOrAssignmentElement(element);
if (isObjectBindingOrAssignmentPattern(bindingTarget)) {
flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
}
else if (isArrayBindingOrAssignmentPattern(bindingTarget)) {
flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
}
else {
flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element);
}
}
/**
* Flattens an ObjectBindingOrAssignmentPattern into zero or more bindings or assignments.
*
* @param flattenContext Options used to control flattening.
* @param parent The parent element of the pattern.
* @param pattern The ObjectBindingOrAssignmentPattern to flatten.
* @param value The current RHS value to assign to the element.
* @param location The location to use for source maps and comments.
*/
function flattenObjectBindingOrAssignmentPattern(flattenContext: FlattenContext, parent: BindingOrAssignmentElement, pattern: ObjectBindingOrAssignmentPattern, value: Expression, location: TextRange) {
const elements = getElementsOfBindingOrAssignmentPattern(pattern);
const numElements = elements.length;
if (numElements !== 1) {
// For anything other than a single-element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once. Additionally, if we have zero elements
// we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
// so in that case, we'll intentionally create that temporary.
const reuseIdentifierExpressions = !isDeclarationBindingElement(parent) || numElements !== 0;
value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
}
let bindingElements: BindingOrAssignmentElement[];
let computedTempVariables: Expression[];
for (let i = 0; i < numElements; i++) {
const element = elements[i];
if (!getRestIndicatorOfBindingOrAssignmentElement(element)) {
const propertyName = getPropertyNameOfBindingOrAssignmentElement(element);
if (flattenContext.level >= FlattenLevel.ObjectRest
&& !(element.transformFlags & (TransformFlags.ContainsRest | TransformFlags.ContainsObjectRest))
&& !(getTargetOfBindingOrAssignmentElement(element).transformFlags & (TransformFlags.ContainsRest | TransformFlags.ContainsObjectRest))
&& !isComputedPropertyName(propertyName)) {
bindingElements = append(bindingElements, element);
}
else {
if (bindingElements) {
flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
bindingElements = undefined;
}
const rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
if (isComputedPropertyName(propertyName)) {
computedTempVariables = append(computedTempVariables, (rhsValue as ElementAccessExpression).argumentExpression);
}
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, /*location*/ element);
}
}
else if (i === numElements - 1) {
if (bindingElements) {
flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
bindingElements = undefined;
}
const rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern);
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
}
}
if (bindingElements) {
flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
}
}
/**
* Flattens an ArrayBindingOrAssignmentPattern into zero or more bindings or assignments.
*
* @param flattenContext Options used to control flattening.
* @param parent The parent element of the pattern.
* @param pattern The ArrayBindingOrAssignmentPattern to flatten.
* @param value The current RHS value to assign to the element.
* @param location The location to use for source maps and comments.
*/
function flattenArrayBindingOrAssignmentPattern(flattenContext: FlattenContext, parent: BindingOrAssignmentElement, pattern: ArrayBindingOrAssignmentPattern, value: Expression, location: TextRange) {
const elements = getElementsOfBindingOrAssignmentPattern(pattern);
const numElements = elements.length;
if (flattenContext.level < FlattenLevel.ObjectRest && flattenContext.downlevelIteration) {
// Read the elements of the iterable into an array
value = ensureIdentifier(
flattenContext,
createReadHelper(
flattenContext.context,
value,
numElements > 0 && getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
? undefined
: numElements,
location
),
/*reuseIdentifierExpressions*/ false,
location
);
}
else if (numElements !== 1 && (flattenContext.level < FlattenLevel.ObjectRest || numElements === 0)
|| every(elements, isOmittedExpression)) {
// For anything other than a single-element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once. Additionally, if we have zero elements
// we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
// so in that case, we'll intentionally create that temporary.
// Or all the elements of the binding pattern are omitted expression such as "var [,] = [1,2]",
// then we will create temporary variable.
const reuseIdentifierExpressions = !isDeclarationBindingElement(parent) || numElements !== 0;
value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
}
let bindingElements: BindingOrAssignmentElement[];
let restContainingElements: [Identifier, BindingOrAssignmentElement][];
for (let i = 0; i < numElements; i++) {
const element = elements[i];
if (flattenContext.level >= FlattenLevel.ObjectRest) {
// If an array pattern contains an ObjectRest, we must cache the result so that we
// can perform the ObjectRest destructuring in a different declaration
if (element.transformFlags & TransformFlags.ContainsObjectRest) {
const temp = createTempVariable(/*recordTempVariable*/ undefined);
if (flattenContext.hoistTempVariables) {
flattenContext.context.hoistVariableDeclaration(temp);
}
restContainingElements = append(restContainingElements, <[Identifier, BindingOrAssignmentElement]>[temp, element]);
bindingElements = append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
}
else {
bindingElements = append(bindingElements, element);
}
}
else if (isOmittedExpression(element)) {
continue;
}
else if (!getRestIndicatorOfBindingOrAssignmentElement(element)) {
const rhsValue = createElementAccess(value, i);
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, /*location*/ element);
}
else if (i === numElements - 1) {
const rhsValue = createArraySlice(value, i);
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, /*location*/ element);
}
}
if (bindingElements) {
flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
}
if (restContainingElements) {
for (const [id, element] of restContainingElements) {
flattenBindingOrAssignmentElement(flattenContext, element, id, element);
}
}
}
/**
* Creates an expression used to provide a default value if a value is `undefined` at runtime.
*
* @param flattenContext Options used to control flattening.
* @param value The RHS value to test.
* @param defaultValue The default value to use if `value` is `undefined` at runtime.
* @param location The location to use for source maps and comments.
*/
function createDefaultValueCheck(flattenContext: FlattenContext, value: Expression, defaultValue: Expression, location: TextRange): Expression {
value = ensureIdentifier(flattenContext, value, /*reuseIdentifierExpressions*/ true, location);
return createConditional(createTypeCheck(value, "undefined"), defaultValue, value);
}
/**
* Creates either a PropertyAccessExpression or an ElementAccessExpression for the
* right-hand side of a transformed destructuring assignment.
*
* @link https://tc39.github.io/ecma262/#sec-runtime-semantics-keyeddestructuringassignmentevaluation
*
* @param flattenContext Options used to control flattening.
* @param value The RHS value that is the source of the property.
* @param propertyName The destructuring property name.
*/
function createDestructuringPropertyAccess(flattenContext: FlattenContext, value: Expression, propertyName: PropertyName): LeftHandSideExpression {
if (isComputedPropertyName(propertyName)) {
const argumentExpression = ensureIdentifier(flattenContext, visitNode(propertyName.expression, flattenContext.visitor), /*reuseIdentifierExpressions*/ false, /*location*/ propertyName);
return createElementAccess(value, argumentExpression);
}
else if (isStringOrNumericLiteral(propertyName)) {
const argumentExpression = getSynthesizedClone(propertyName);
argumentExpression.text = argumentExpression.text;
return createElementAccess(value, argumentExpression);
}
else {
const name = createIdentifier(idText(propertyName));
return createPropertyAccess(value, name);
}
}
/**
* Ensures that there exists a declared identifier whose value holds the given expression.
* This function is useful to ensure that the expression's value can be read from in subsequent expressions.
* Unless 'reuseIdentifierExpressions' is false, 'value' will be returned if it is just an identifier.
*
* @param flattenContext Options used to control flattening.
* @param value the expression whose value needs to be bound.
* @param reuseIdentifierExpressions true if identifier expressions can simply be returned;
* false if it is necessary to always emit an identifier.
* @param location The location to use for source maps and comments.
*/
function ensureIdentifier(flattenContext: FlattenContext, value: Expression, reuseIdentifierExpressions: boolean, location: TextRange) {
if (isIdentifier(value) && reuseIdentifierExpressions) {
return value;
}
else {
const temp = createTempVariable(/*recordTempVariable*/ undefined);
if (flattenContext.hoistTempVariables) {
flattenContext.context.hoistVariableDeclaration(temp);
flattenContext.emitExpression(setTextRange(createAssignment(temp, value), location));
}
else {
flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined);
}
return temp;
}
}
function makeArrayBindingPattern(elements: BindingOrAssignmentElement[]) {
Debug.assertEachNode(elements, isArrayBindingElement);
return createArrayBindingPattern(<ArrayBindingElement[]>elements);
}
function makeArrayAssignmentPattern(elements: BindingOrAssignmentElement[]) {
return createArrayLiteral(map(elements, convertToArrayAssignmentElement));
}
function makeObjectBindingPattern(elements: BindingOrAssignmentElement[]) {
Debug.assertEachNode(elements, isBindingElement);
return createObjectBindingPattern(<BindingElement[]>elements);
}
function makeObjectAssignmentPattern(elements: BindingOrAssignmentElement[]) {
return createObjectLiteral(map(elements, convertToObjectAssignmentElement));
}
function makeBindingElement(name: Identifier) {
return createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name);
}
function makeAssignmentElement(name: Identifier) {
return name;
}
const restHelper: EmitHelper = {
name: "typescript:rest",
scoped: false,
text: `
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};`
};
/** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement
* `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`
*/
function createRestCall(context: TransformationContext, value: Expression, elements: ReadonlyArray<BindingOrAssignmentElement>, computedTempVariables: ReadonlyArray<Expression>, location: TextRange): Expression {
context.requestEmitHelper(restHelper);
const propertyNames: Expression[] = [];
let computedTempVariableOffset = 0;
for (let i = 0; i < elements.length - 1; i++) {
const propertyName = getPropertyNameOfBindingOrAssignmentElement(elements[i]);
if (propertyName) {
if (isComputedPropertyName(propertyName)) {
const temp = computedTempVariables[computedTempVariableOffset];
computedTempVariableOffset++;
// typeof _tmp === "symbol" ? _tmp : _tmp + ""
propertyNames.push(
createConditional(
createTypeCheck(temp, "symbol"),
temp,
createAdd(temp, createLiteral(""))
)
);
}
else {
propertyNames.push(createLiteral(propertyName));
}
}
}
return createCall(
getHelperName("__rest"),
/*typeArguments*/ undefined,
[
value,
setTextRange(
createArrayLiteral(propertyNames),
location
)
]);
}
}