diff --git a/lib/tsc.js b/lib/tsc.js index daf867a74dd6b..a51c4f9fc29d1 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -10486,6 +10486,7 @@ var ts; var hasAsyncFunctions; var hasDecorators; var hasParameterDecorators; + var hasJsxSpreadAttribute; var inStrictMode; var symbolCount = 0; var Symbol; @@ -10516,6 +10517,7 @@ var ts; hasAsyncFunctions = false; hasDecorators = false; hasParameterDecorators = false; + hasJsxSpreadAttribute = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -10729,6 +10731,9 @@ var ts; if (hasAsyncFunctions) { flags |= 33554432; } + if (hasJsxSpreadAttribute) { + flags |= 1073741824; + } } node.flags = flags; if (saveState) { @@ -11291,6 +11296,9 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 250: return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 242: + hasJsxSpreadAttribute = true; + return; case 148: case 149: case 150: @@ -26673,6 +26681,7 @@ var ts; }; function emitFiles(resolver, host, targetSourceFile) { var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -26752,6 +26761,7 @@ var ts; var decoratedClassAliases; var convertedLoopState; var extendsEmitted; + var assignEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -26816,6 +26826,7 @@ var ts; decorateEmitted = false; paramEmitted = false; awaiterEmitted = false; + assignEmitted = false; tempFlags = 0; tempVariables = undefined; tempParameters = undefined; @@ -27278,8 +27289,7 @@ var ts; else { var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 242; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); + write("__assign("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { if (attrs[i].kind === 242) { @@ -32092,10 +32102,14 @@ var ts; } function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && node.flags & 4194304)) { + if (languageVersion < 2 && !extendsEmitted && node.flags & 4194304) { writeLines(extendsHelper); extendsEmitted = true; } + if (compilerOptions.jsx !== 1 && !assignEmitted && (node.flags & 1073741824)) { + writeLines(assignHelper); + assignEmitted = true; + } if (!decorateEmitted && node.flags & 8388608) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -32528,7 +32542,7 @@ var ts; ts.ioWriteTime = 0; ts.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; var emptyArray = []; - ts.version = "1.8.9"; + ts.version = "1.8.10"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 122354193885e..5c0ccf6879748 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -11111,6 +11111,7 @@ var ts; var hasAsyncFunctions; var hasDecorators; var hasParameterDecorators; + var hasJsxSpreadAttribute; var inStrictMode; var symbolCount = 0; var Symbol; @@ -11141,6 +11142,7 @@ var ts; hasAsyncFunctions = false; hasDecorators = false; hasParameterDecorators = false; + hasJsxSpreadAttribute = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -11354,6 +11356,9 @@ var ts; if (hasAsyncFunctions) { flags |= 33554432; } + if (hasJsxSpreadAttribute) { + flags |= 1073741824; + } } node.flags = flags; if (saveState) { @@ -11916,6 +11921,9 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 250: return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 242: + hasJsxSpreadAttribute = true; + return; case 148: case 149: case 150: @@ -27298,6 +27306,7 @@ var ts; }; function emitFiles(resolver, host, targetSourceFile) { var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -27377,6 +27386,7 @@ var ts; var decoratedClassAliases; var convertedLoopState; var extendsEmitted; + var assignEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -27441,6 +27451,7 @@ var ts; decorateEmitted = false; paramEmitted = false; awaiterEmitted = false; + assignEmitted = false; tempFlags = 0; tempVariables = undefined; tempParameters = undefined; @@ -27903,8 +27914,7 @@ var ts; else { var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 242; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); + write("__assign("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { if (attrs[i].kind === 242) { @@ -32717,10 +32727,14 @@ var ts; } function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && node.flags & 4194304)) { + if (languageVersion < 2 && !extendsEmitted && node.flags & 4194304) { writeLines(extendsHelper); extendsEmitted = true; } + if (compilerOptions.jsx !== 1 && !assignEmitted && (node.flags & 1073741824)) { + writeLines(assignHelper); + assignEmitted = true; + } if (!decorateEmitted && node.flags & 8388608) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -33153,7 +33167,7 @@ var ts; ts.ioWriteTime = 0; ts.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; var emptyArray = []; - ts.version = "1.8.9"; + ts.version = "1.8.10"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index de2270a13ea71..efd5b2378fb9f 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -360,6 +360,7 @@ declare namespace ts { HasDecorators = 8388608, HasParamDecorators = 16777216, HasAsyncFunctions = 33554432, + HasJsxSpreadAttribute = 1073741824, Modifier = 1022, AccessibilityModifier = 56, BlockScoped = 24576, diff --git a/lib/typescript.js b/lib/typescript.js index a7424a7d6f0c2..abd6745fc8953 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -383,6 +383,9 @@ var ts; NodeFlags[NodeFlags["HasDecorators"] = 8388608] = "HasDecorators"; NodeFlags[NodeFlags["HasParamDecorators"] = 16777216] = "HasParamDecorators"; NodeFlags[NodeFlags["HasAsyncFunctions"] = 33554432] = "HasAsyncFunctions"; + // This was picked out from the 'master' branch. + // To keep the flags consistent, we're skipping a few ahead. + NodeFlags[NodeFlags["HasJsxSpreadAttribute"] = 1073741824] = "HasJsxSpreadAttribute"; NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; @@ -13267,6 +13270,7 @@ var ts; var hasAsyncFunctions; var hasDecorators; var hasParameterDecorators; + var hasJsxSpreadAttribute; // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -13300,6 +13304,7 @@ var ts; hasAsyncFunctions = false; hasDecorators = false; hasParameterDecorators = false; + hasJsxSpreadAttribute = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -13592,6 +13597,9 @@ var ts; if (hasAsyncFunctions) { flags |= 33554432 /* HasAsyncFunctions */; } + if (hasJsxSpreadAttribute) { + flags |= 1073741824 /* HasJsxSpreadAttribute */; + } } node.flags = flags; if (saveState) { @@ -14281,6 +14289,9 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); case 250 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); + case 242 /* JsxSpreadAttribute */: + hasJsxSpreadAttribute = true; + return; case 148 /* CallSignature */: case 149 /* ConstructSignature */: case 150 /* IndexSignature */: @@ -32450,6 +32461,7 @@ var ts; function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; // emit output for the __metadata helper function @@ -32539,6 +32551,7 @@ var ts; var decoratedClassAliases; var convertedLoopState; var extendsEmitted; + var assignEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -32609,6 +32622,7 @@ var ts; decorateEmitted = false; paramEmitted = false; awaiterEmitted = false; + assignEmitted = false; tempFlags = 0; tempVariables = undefined; tempParameters = undefined; @@ -33165,11 +33179,10 @@ var ts; } else { // Either emit one big object literal (no spread attribs), or - // a call to React.__spread + // a call to the __assign helper var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 242 /* JsxSpreadAttribute */; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); + write("__assign("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { if (attrs[i].kind === 242 /* JsxSpreadAttribute */) { @@ -38850,10 +38863,14 @@ var ts; if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 4194304 /* HasClassExtends */)) { + if (languageVersion < 2 /* ES6 */ && !extendsEmitted && node.flags & 4194304 /* HasClassExtends */) { writeLines(extendsHelper); extendsEmitted = true; } + if (compilerOptions.jsx !== 1 /* Preserve */ && !assignEmitted && (node.flags & 1073741824 /* HasJsxSpreadAttribute */)) { + writeLines(assignHelper); + assignEmitted = true; + } if (!decorateEmitted && node.flags & 8388608 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -39343,7 +39360,7 @@ var ts; /* @internal */ ts.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /** The version of the TypeScript compiler release */ var emptyArray = []; - ts.version = "1.8.9"; + ts.version = "1.8.10"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index b70bdd45935f7..6ec63215c925c 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -360,6 +360,7 @@ declare namespace ts { HasDecorators = 8388608, HasParamDecorators = 16777216, HasAsyncFunctions = 33554432, + HasJsxSpreadAttribute = 1073741824, Modifier = 1022, AccessibilityModifier = 56, BlockScoped = 24576, diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index a7424a7d6f0c2..abd6745fc8953 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -383,6 +383,9 @@ var ts; NodeFlags[NodeFlags["HasDecorators"] = 8388608] = "HasDecorators"; NodeFlags[NodeFlags["HasParamDecorators"] = 16777216] = "HasParamDecorators"; NodeFlags[NodeFlags["HasAsyncFunctions"] = 33554432] = "HasAsyncFunctions"; + // This was picked out from the 'master' branch. + // To keep the flags consistent, we're skipping a few ahead. + NodeFlags[NodeFlags["HasJsxSpreadAttribute"] = 1073741824] = "HasJsxSpreadAttribute"; NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; @@ -13267,6 +13270,7 @@ var ts; var hasAsyncFunctions; var hasDecorators; var hasParameterDecorators; + var hasJsxSpreadAttribute; // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). @@ -13300,6 +13304,7 @@ var ts; hasAsyncFunctions = false; hasDecorators = false; hasParameterDecorators = false; + hasJsxSpreadAttribute = false; } return bindSourceFile; function createSymbol(flags, name) { @@ -13592,6 +13597,9 @@ var ts; if (hasAsyncFunctions) { flags |= 33554432 /* HasAsyncFunctions */; } + if (hasJsxSpreadAttribute) { + flags |= 1073741824 /* HasJsxSpreadAttribute */; + } } node.flags = flags; if (saveState) { @@ -14281,6 +14289,9 @@ var ts; return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); case 250 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); + case 242 /* JsxSpreadAttribute */: + hasJsxSpreadAttribute = true; + return; case 148 /* CallSignature */: case 149 /* ConstructSignature */: case 150 /* IndexSignature */: @@ -32450,6 +32461,7 @@ var ts; function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; + var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; // emit output for the __metadata helper function @@ -32539,6 +32551,7 @@ var ts; var decoratedClassAliases; var convertedLoopState; var extendsEmitted; + var assignEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -32609,6 +32622,7 @@ var ts; decorateEmitted = false; paramEmitted = false; awaiterEmitted = false; + assignEmitted = false; tempFlags = 0; tempVariables = undefined; tempParameters = undefined; @@ -33165,11 +33179,10 @@ var ts; } else { // Either emit one big object literal (no spread attribs), or - // a call to React.__spread + // a call to the __assign helper var attrs = openingNode.attributes; if (ts.forEach(attrs, function (attr) { return attr.kind === 242 /* JsxSpreadAttribute */; })) { - emitExpressionIdentifier(syntheticReactRef); - write(".__spread("); + write("__assign("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { if (attrs[i].kind === 242 /* JsxSpreadAttribute */) { @@ -38850,10 +38863,14 @@ var ts; if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 4194304 /* HasClassExtends */)) { + if (languageVersion < 2 /* ES6 */ && !extendsEmitted && node.flags & 4194304 /* HasClassExtends */) { writeLines(extendsHelper); extendsEmitted = true; } + if (compilerOptions.jsx !== 1 /* Preserve */ && !assignEmitted && (node.flags & 1073741824 /* HasJsxSpreadAttribute */)) { + writeLines(assignHelper); + assignEmitted = true; + } if (!decorateEmitted && node.flags & 8388608 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -39343,7 +39360,7 @@ var ts; /* @internal */ ts.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /** The version of the TypeScript compiler release */ var emptyArray = []; - ts.version = "1.8.9"; + ts.version = "1.8.10"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { diff --git a/package.json b/package.json index 331fcd812fe71..6cf457383fcdc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.8.9", + "version": "1.8.10", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/program.ts b/src/compiler/program.ts index df4fb5fbba75e..97447d4271e96 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -13,7 +13,7 @@ namespace ts { const emptyArray: any[] = []; - export const version = "1.8.9"; + export const version = "1.8.10"; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { let fileName = "tsconfig.json";