Import helpers skips __assign when target >= ES6

Instead, Object.assign is emitted.
This commit is contained in:
Nathan Shively-Sanders 2017-01-30 12:42:19 -08:00
parent 46cdac1ec7
commit cca68adf87
5 changed files with 28 additions and 13 deletions

View file

@ -11721,7 +11721,7 @@ namespace ts {
member = prop;
}
else if (memberDecl.kind === SyntaxKind.SpreadAssignment) {
if (languageVersion < ScriptTarget.ESNext) {
if (languageVersion < ScriptTarget.ES2015) {
checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign);
}
if (propertiesArray.length > 0) {

View file

@ -5,10 +5,12 @@ declare var dec: any;
@dec export class A {
}
const o = { a: 1 };
const y = { ...o };
//// [tslib.d.ts]
export declare function __extends(d: Function, b: Function): void;
export declare function __assign(t: any, ...sources: any[]): any;
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
export declare function __param(paramIndex: number, decorator: Function): Function;
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
@ -23,3 +25,5 @@ A = tslib_1.__decorate([
dec
], A);
export { A };
const o = { a: 1 };
const y = Object.assign({}, o);

View file

@ -8,6 +8,14 @@ declare var dec: any;
}
const o = { a: 1 };
>o : Symbol(o, Decl(a.ts, 5, 5))
>a : Symbol(a, Decl(a.ts, 5, 11))
const y = { ...o };
>y : Symbol(y, Decl(a.ts, 6, 5))
>o : Symbol(o, Decl(a.ts, 5, 5))
=== tests/cases/compiler/tslib.d.ts ===
export declare function __extends(d: Function, b: Function): void;
>__extends : Symbol(__extends, Decl(tslib.d.ts, --, --))
@ -16,11 +24,6 @@ export declare function __extends(d: Function, b: Function): void;
>b : Symbol(b, Decl(tslib.d.ts, --, --))
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
export declare function __assign(t: any, ...sources: any[]): any;
>__assign : Symbol(__assign, Decl(tslib.d.ts, --, --))
>t : Symbol(t, Decl(tslib.d.ts, --, --))
>sources : Symbol(sources, Decl(tslib.d.ts, --, --))
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
>__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --))
>decorators : Symbol(decorators, Decl(tslib.d.ts, --, --))

View file

@ -8,6 +8,17 @@ declare var dec: any;
}
const o = { a: 1 };
>o : { a: number; }
>{ a: 1 } : { a: number; }
>a : number
>1 : 1
const y = { ...o };
>y : { a: number; }
>{ ...o } : { a: number; }
>o : { a: number; }
=== tests/cases/compiler/tslib.d.ts ===
export declare function __extends(d: Function, b: Function): void;
>__extends : (d: Function, b: Function) => void
@ -16,11 +27,6 @@ export declare function __extends(d: Function, b: Function): void;
>b : Function
>Function : Function
export declare function __assign(t: any, ...sources: any[]): any;
>__assign : (t: any, ...sources: any[]) => any
>t : any
>sources : any[]
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
>__decorate : (decorators: Function[], target: any, key?: string | symbol, desc?: any) => any
>decorators : Function[]

View file

@ -7,9 +7,11 @@ declare var dec: any;
}
const o = { a: 1 };
const y = { ...o };
// @filename: tslib.d.ts
export declare function __extends(d: Function, b: Function): void;
export declare function __assign(t: any, ...sources: any[]): any;
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
export declare function __param(paramIndex: number, decorator: Function): Function;
export declare function __metadata(metadataKey: any, metadataValue: any): Function;