From c34b39bcffbacbe2b9d11ce03a6b0490aa2eac29 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 27 May 2020 18:39:09 +0000 Subject: [PATCH] Cherry-pick PR #38808 into release-3.9 Component commits: 2906ce4c98 Skip default when iterating exports in __importStar, same as __exportStar 1da7d7a28a Accept baselines --- src/compiler/transformers/module/module.ts | 2 +- tests/baselines/reference/esModuleInterop.js | 2 +- tests/baselines/reference/esModuleInteropImportCall.js | 2 +- tests/baselines/reference/esModuleInteropImportNamespace.js | 2 +- .../baselines/reference/esModuleInteropNamedDefaultImports.js | 2 +- .../reference/esModuleInteropPrettyErrorRelatedInformation.js | 2 +- .../esModuleInteropUsesExportStarWhenDefaultPlusNames.js | 2 +- .../reference/esModuleInteropWithExportStar(target=es3).js | 2 +- .../reference/esModuleInteropWithExportStar(target=es5).js | 2 +- tests/baselines/reference/esModuleIntersectionCrash.js | 2 +- tests/baselines/reference/exportAsNamespace2(module=amd).js | 2 +- .../reference/exportAsNamespace2(module=commonjs).js | 4 ++-- tests/baselines/reference/exportAsNamespace2(module=umd).js | 4 ++-- tests/baselines/reference/exportAsNamespace3(module=amd).js | 2 +- .../reference/exportAsNamespace3(module=commonjs).js | 4 ++-- tests/baselines/reference/exportAsNamespace3(module=umd).js | 4 ++-- .../baselines/reference/exportAsNamespace_exportAssignment.js | 2 +- tests/baselines/reference/exportDefault.js | 4 ++-- tests/baselines/reference/importEquals1.js | 2 +- tests/baselines/reference/importEquals2.js | 2 +- .../when-esModuleInterop-option-changes.js | 2 +- 21 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 2708dc1deba81..47e3b92c7d71d 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1914,7 +1914,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; };` diff --git a/tests/baselines/reference/esModuleInterop.js b/tests/baselines/reference/esModuleInterop.js index 20c009e80a4b0..14085e89d79f5 100644 --- a/tests/baselines/reference/esModuleInterop.js +++ b/tests/baselines/reference/esModuleInterop.js @@ -35,7 +35,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleInteropImportCall.js b/tests/baselines/reference/esModuleInteropImportCall.js index cb29b51cd43d8..d57eafba73bb8 100644 --- a/tests/baselines/reference/esModuleInteropImportCall.js +++ b/tests/baselines/reference/esModuleInteropImportCall.js @@ -26,7 +26,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleInteropImportNamespace.js b/tests/baselines/reference/esModuleInteropImportNamespace.js index 8704f95b0a883..fee52b0157ee5 100644 --- a/tests/baselines/reference/esModuleInteropImportNamespace.js +++ b/tests/baselines/reference/esModuleInteropImportNamespace.js @@ -27,7 +27,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleInteropNamedDefaultImports.js b/tests/baselines/reference/esModuleInteropNamedDefaultImports.js index 3d950a2d25cca..f87d7fe5f24eb 100644 --- a/tests/baselines/reference/esModuleInteropNamedDefaultImports.js +++ b/tests/baselines/reference/esModuleInteropNamedDefaultImports.js @@ -45,7 +45,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.js b/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.js index 556414576d179..6d05072a5bbc2 100644 --- a/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.js +++ b/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.js @@ -27,7 +27,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleInteropUsesExportStarWhenDefaultPlusNames.js b/tests/baselines/reference/esModuleInteropUsesExportStarWhenDefaultPlusNames.js index 1e20e8e208c53..f463275511f64 100644 --- a/tests/baselines/reference/esModuleInteropUsesExportStarWhenDefaultPlusNames.js +++ b/tests/baselines/reference/esModuleInteropUsesExportStarWhenDefaultPlusNames.js @@ -20,7 +20,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js b/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js index de77e148cdfb1..262cc58e28161 100644 --- a/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js +++ b/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js @@ -29,7 +29,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js b/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js index 133a175e1ad06..00600c6f31cdf 100644 --- a/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js +++ b/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js @@ -29,7 +29,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/esModuleIntersectionCrash.js b/tests/baselines/reference/esModuleIntersectionCrash.js index 5f1b5b2e10498..b91f88929b749 100644 --- a/tests/baselines/reference/esModuleIntersectionCrash.js +++ b/tests/baselines/reference/esModuleIntersectionCrash.js @@ -29,7 +29,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportAsNamespace2(module=amd).js b/tests/baselines/reference/exportAsNamespace2(module=amd).js index 17d850ee505e1..e166d970e94d5 100644 --- a/tests/baselines/reference/exportAsNamespace2(module=amd).js +++ b/tests/baselines/reference/exportAsNamespace2(module=amd).js @@ -47,7 +47,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportAsNamespace2(module=commonjs).js b/tests/baselines/reference/exportAsNamespace2(module=commonjs).js index 0b0522339e149..c258c022a224d 100644 --- a/tests/baselines/reference/exportAsNamespace2(module=commonjs).js +++ b/tests/baselines/reference/exportAsNamespace2(module=commonjs).js @@ -38,7 +38,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63,7 +63,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportAsNamespace2(module=umd).js b/tests/baselines/reference/exportAsNamespace2(module=umd).js index ce18b9cef8266..5985e966afce7 100644 --- a/tests/baselines/reference/exportAsNamespace2(module=umd).js +++ b/tests/baselines/reference/exportAsNamespace2(module=umd).js @@ -47,7 +47,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -82,7 +82,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportAsNamespace3(module=amd).js b/tests/baselines/reference/exportAsNamespace3(module=amd).js index 7c321cb39339b..ce2bc8d8a7a74 100644 --- a/tests/baselines/reference/exportAsNamespace3(module=amd).js +++ b/tests/baselines/reference/exportAsNamespace3(module=amd).js @@ -53,7 +53,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportAsNamespace3(module=commonjs).js b/tests/baselines/reference/exportAsNamespace3(module=commonjs).js index 37ce48850f5a5..a8c3811ae599f 100644 --- a/tests/baselines/reference/exportAsNamespace3(module=commonjs).js +++ b/tests/baselines/reference/exportAsNamespace3(module=commonjs).js @@ -41,7 +41,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -69,7 +69,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportAsNamespace3(module=umd).js b/tests/baselines/reference/exportAsNamespace3(module=umd).js index 8cd5247147708..89c8e733974dc 100644 --- a/tests/baselines/reference/exportAsNamespace3(module=umd).js +++ b/tests/baselines/reference/exportAsNamespace3(module=umd).js @@ -50,7 +50,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -88,7 +88,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportAsNamespace_exportAssignment.js b/tests/baselines/reference/exportAsNamespace_exportAssignment.js index 36e08b627da91..08dce502bf448 100644 --- a/tests/baselines/reference/exportAsNamespace_exportAssignment.js +++ b/tests/baselines/reference/exportAsNamespace_exportAssignment.js @@ -27,7 +27,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/exportDefault.js b/tests/baselines/reference/exportDefault.js index ba61dc3d48fe3..c02053175da51 100644 --- a/tests/baselines/reference/exportDefault.js +++ b/tests/baselines/reference/exportDefault.js @@ -59,7 +59,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -92,7 +92,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/importEquals1.js b/tests/baselines/reference/importEquals1.js index 3b4dfd176d5a6..099c6c4221b7f 100644 --- a/tests/baselines/reference/importEquals1.js +++ b/tests/baselines/reference/importEquals1.js @@ -58,7 +58,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/importEquals2.js b/tests/baselines/reference/importEquals2.js index a96a14a6514f2..43f05ceea4060 100644 --- a/tests/baselines/reference/importEquals2.js +++ b/tests/baselines/reference/importEquals2.js @@ -38,7 +38,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js index ac73290258cea..a5387d98d5eb2 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js @@ -34,7 +34,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; };