@@ -345,6 +345,16 @@ var __extends = (this && this.__extends) || function (d, b) {
345345 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
346346};` ;
347347
348+ const assignHelper = `
349+ var __assign = (this && this.__assign) || Object.assign || function(t) {
350+ for (var s, i = 1, n = arguments.length; i < n; i++) {
351+ s = arguments[i];
352+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
353+ t[p] = s[p];
354+ }
355+ return t;
356+ };` ;
357+
348358 // emit output for the __decorate helper function
349359 const decorateHelper = `
350360var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -380,6 +390,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
380390 const languageVersion = getEmitScriptTarget ( compilerOptions ) ;
381391 const modulekind = getEmitModuleKind ( compilerOptions ) ;
382392 const sourceMapDataList : SourceMapData [ ] = compilerOptions . sourceMap || compilerOptions . inlineSourceMap ? [ ] : undefined ;
393+ const emittedFilesList : string [ ] = compilerOptions . listEmittedFiles ? [ ] : undefined ;
383394 const emitterDiagnostics = createDiagnosticCollection ( ) ;
384395 let emitSkipped = false ;
385396 const newLine = host . getNewLine ( ) ;
@@ -390,6 +401,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
390401 return {
391402 emitSkipped,
392403 diagnostics : emitterDiagnostics . getDiagnostics ( ) ,
404+ emittedFiles : emittedFilesList ,
393405 sourceMaps : sourceMapDataList
394406 } ;
395407
@@ -540,6 +552,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
540552 let convertedLoopState : ConvertedLoopState ;
541553
542554 let extendsEmitted : boolean ;
555+ let assignEmitted : boolean ;
543556 let decorateEmitted : boolean ;
544557 let paramEmitted : boolean ;
545558 let awaiterEmitted : boolean ;
@@ -623,6 +636,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
623636 decorateEmitted = false ;
624637 paramEmitted = false ;
625638 awaiterEmitted = false ;
639+ assignEmitted = false ;
626640 tempFlags = 0 ;
627641 tempVariables = undefined ;
628642 tempParameters = undefined ;
@@ -1259,11 +1273,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12591273 }
12601274 else {
12611275 // Either emit one big object literal (no spread attribs), or
1262- // a call to React.__spread
1276+ // a call to the __assign helper
12631277 const attrs = openingNode . attributes ;
12641278 if ( forEach ( attrs , attr => attr . kind === SyntaxKind . JsxSpreadAttribute ) ) {
1265- emitExpressionIdentifier ( syntheticReactRef ) ;
1266- write ( ".__spread(" ) ;
1279+ write ( "__assign(" ) ;
12671280
12681281 let haveOpenedObjectLiteral = false ;
12691282 for ( let i = 0 ; i < attrs . length ; i ++ ) {
@@ -4630,8 +4643,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
46304643 write ( "(" ) ;
46314644 if ( node ) {
46324645 const parameters = node . parameters ;
4646+ const skipCount = node . parameters . length && ( < Identifier > node . parameters [ 0 ] . name ) . text === "this" ? 1 : 0 ;
46334647 const omitCount = languageVersion < ScriptTarget . ES6 && hasRestParameter ( node ) ? 1 : 0 ;
4634- emitList ( parameters , 0 , parameters . length - omitCount , /*multiLine*/ false , /*trailingComma*/ false ) ;
4648+ emitList ( parameters , skipCount , parameters . length - omitCount - skipCount , /*multiLine*/ false , /*trailingComma*/ false ) ;
46354649 }
46364650 write ( ")" ) ;
46374651 decreaseIndent ( ) ;
@@ -7651,7 +7665,7 @@ const _super = (function (geti, seti) {
76517665 }
76527666
76537667 function isUseStrictPrologue ( node : ExpressionStatement ) : boolean {
7654- return ! ! ( node . expression as StringLiteral ) . text . match ( / u s e s t r i c t / ) ;
7668+ return ( node . expression as StringLiteral ) . text === " use strict" ;
76557669 }
76567670
76577671 function ensureUseStrictPrologue ( startWithNewLine : boolean , writeUseStrict : boolean ) {
@@ -7701,11 +7715,16 @@ const _super = (function (geti, seti) {
77017715 if ( ! compilerOptions . noEmitHelpers ) {
77027716 // Only Emit __extends function when target ES5.
77037717 // For target ES6 and above, we can emit classDeclaration as is.
7704- if ( ( languageVersion < ScriptTarget . ES6 ) && ( ! extendsEmitted && node . flags & NodeFlags . HasClassExtends ) ) {
7718+ if ( languageVersion < ScriptTarget . ES6 && ! extendsEmitted && node . flags & NodeFlags . HasClassExtends ) {
77057719 writeLines ( extendsHelper ) ;
77067720 extendsEmitted = true ;
77077721 }
77087722
7723+ if ( compilerOptions . jsx !== JsxEmit . Preserve && ! assignEmitted && ( node . flags & NodeFlags . HasJsxSpreadAttribute ) ) {
7724+ writeLines ( assignHelper ) ;
7725+ assignEmitted = true ;
7726+ }
7727+
77097728 if ( ! decorateEmitted && node . flags & NodeFlags . HasDecorators ) {
77107729 writeLines ( decorateHelper ) ;
77117730 if ( compilerOptions . emitDecoratorMetadata ) {
@@ -8232,6 +8251,16 @@ const _super = (function (geti, seti) {
82328251 if ( declarationFilePath ) {
82338252 emitSkipped = writeDeclarationFile ( declarationFilePath , sourceFiles , isBundledEmit , host , resolver , emitterDiagnostics ) || emitSkipped ;
82348253 }
8254+
8255+ if ( ! emitSkipped && emittedFilesList ) {
8256+ emittedFilesList . push ( jsFilePath ) ;
8257+ if ( sourceMapFilePath ) {
8258+ emittedFilesList . push ( sourceMapFilePath ) ;
8259+ }
8260+ if ( declarationFilePath ) {
8261+ emittedFilesList . push ( declarationFilePath ) ;
8262+ }
8263+ }
82358264 }
82368265 }
82378266}
0 commit comments