diff --git a/Gulpfile.js b/Gulpfile.js index 4c04cfc8571..4312845f1e5 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -446,10 +446,10 @@ task("runtests-parallel").flags = { " --shardId": "1-based ID of this shard (default: 1)", }; -task("diff", () => exec(getDiffTool(), [refBaseline, localBaseline], { ignoreExitCode: true })); +task("diff", () => exec(getDiffTool(), [refBaseline, localBaseline], { ignoreExitCode: true, waitForExit: false })); task("diff").description = "Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable"; -task("diff-rwc", () => exec(getDiffTool(), [refRwcBaseline, localRwcBaseline], { ignoreExitCode: true })); +task("diff-rwc", () => exec(getDiffTool(), [refRwcBaseline, localRwcBaseline], { ignoreExitCode: true, waitForExit: false })); task("diff-rwc").description = "Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable"; /** diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg deleted file mode 100644 index 77e5d6f2236..00000000000 --- a/lib/enu/diagnosticMessages.generated.json.lcg +++ /dev/null @@ -1,7664 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {1}'?]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - or -. For example '{0}' or '{1}'.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - type.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ()' instead.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/scripts/build/utils.js b/scripts/build/utils.js index b070bd133a9..a67742cca68 100644 --- a/scripts/build/utils.js +++ b/scripts/build/utils.js @@ -25,10 +25,11 @@ const isWindows = /^win/.test(process.platform); * @property {boolean} [ignoreExitCode] * @property {import("prex").CancellationToken} [cancelToken] * @property {boolean} [hidePrompt] + * @property {boolean} [waitForExit=true] */ function exec(cmd, args, options = {}) { return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => { - const { ignoreExitCode, cancelToken = CancellationToken.none } = options; + const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options; cancelToken.throwIfCancellationRequested(); // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition @@ -36,26 +37,33 @@ function exec(cmd, args, options = {}) { const command = isWindows ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`]; if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`); - const proc = spawn(isWindows ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true }); + const proc = spawn(isWindows ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: waitForExit ? "inherit" : "ignore", windowsVerbatimArguments: true }); const registration = cancelToken.register(() => { log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`); proc.kill("SIGINT"); proc.kill("SIGTERM"); reject(new CancelError()); }); - proc.on("exit", exitCode => { - registration.unregister(); - if (exitCode === 0 || ignoreExitCode) { - resolve({ exitCode }); - } - else { - reject(new Error(`Process exited with code: ${exitCode}`)); - } - }); - proc.on("error", error => { - registration.unregister(); - reject(error); - }); + if (waitForExit) { + proc.on("exit", exitCode => { + registration.unregister(); + if (exitCode === 0 || ignoreExitCode) { + resolve({ exitCode }); + } + else { + reject(new Error(`Process exited with code: ${exitCode}`)); + } + }); + proc.on("error", error => { + registration.unregister(); + reject(error); + }); + } + else { + proc.unref(); + // wait a short period in order to allow the process to start successfully before Node exits. + setTimeout(() => resolve({ exitCode: undefined }), 100); + } })); } exports.exec = exec; diff --git a/scripts/produceLKG.ts b/scripts/produceLKG.ts index da45ae35fe4..762290bcfa6 100644 --- a/scripts/produceLKG.ts +++ b/scripts/produceLKG.ts @@ -27,9 +27,14 @@ async function copyLibFiles() { async function copyLocalizedDiagnostics() { const dir = await fs.readdir(source); + const ignoredFolders = ["enu"]; + for (const d of dir) { const fileName = path.join(source, d); - if (fs.statSync(fileName).isDirectory()) { + if ( + fs.statSync(fileName).isDirectory() && + ignoredFolders.indexOf(d) < 0 + ) { await fs.copy(fileName, path.join(dest, d)); } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ffff0a69320..1565e288491 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2377,7 +2377,7 @@ namespace ts { return links.target; } - function markExportAsReferenced(node: ImportEqualsDeclaration | ExportAssignment | ExportSpecifier) { + function markExportAsReferenced(node: ImportEqualsDeclaration | ExportSpecifier) { const symbol = getSymbolOfNode(node); const target = resolveAlias(symbol); if (target) { @@ -2399,15 +2399,10 @@ namespace ts { links.referenced = true; const node = getDeclarationOfAliasSymbol(symbol); if (!node) return Debug.fail(); - if (node.kind === SyntaxKind.ExportAssignment) { - // export default - checkExpressionCached((node).expression); - } - else if (node.kind === SyntaxKind.ExportSpecifier) { - // export { } or export { as foo } - checkExpressionCached((node).propertyName || (node).name); - } - else if (isInternalModuleImportEqualsDeclaration(node)) { + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (isInternalModuleImportEqualsDeclaration(node)) { // import foo = checkExpressionCached(node.moduleReference); } @@ -17829,8 +17824,12 @@ namespace ts { return type; } + function isExportOrExportExpression(location: Node) { + return !!findAncestor(location, e => e.parent && isExportAssignment(e.parent) && e.parent.expression === e && isEntityNameExpression(e)); + } + function markAliasReferenced(symbol: Symbol, location: Node) { - if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -18812,6 +18811,17 @@ namespace ts { return false; } + function getContextualIterationType(kind: IterationTypeKind, functionDecl: SignatureDeclaration): Type | undefined { + const isAsync = !!(getFunctionFlags(functionDecl) & FunctionFlags.Async); + const contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + + return undefined; + } + function getContextualReturnType(functionDecl: SignatureDeclaration): Type | undefined { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -20341,8 +20351,8 @@ namespace ts { // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = SymbolFlags.All; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & SymbolFlags.Alias && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & SymbolFlags.Alias) { markAliasSymbolAsReferenced(reactSym); } } @@ -23477,7 +23487,11 @@ namespace ts { } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType( + yieldType || neverType, + returnType || fallbackReturnType, + nextType || getContextualIterationType(IterationTypeKind.Next, func) || unknownType, + isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -24839,13 +24853,7 @@ namespace ts { || anyType; } - const contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Next, contextualReturnType, isAsync) - || anyType; - } - - return anyType; + return getContextualIterationType(IterationTypeKind.Next, func) || anyType; } function checkConditionalExpression(node: ConditionalExpression, checkMode?: CheckMode): Type { @@ -24894,7 +24902,7 @@ namespace ts { return result; } - function checkExpressionCached(node: Expression, checkMode?: CheckMode): Type { + function checkExpressionCached(node: Expression | QualifiedName, checkMode?: CheckMode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { if (checkMode && checkMode !== CheckMode.Normal) { @@ -25222,7 +25230,8 @@ namespace ts { (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).expression === node) || (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).expression === node) || ((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === SyntaxKind.TypeQuery && (node.parent).exprName === node)); + (node.parent.kind === SyntaxKind.TypeQuery && (node.parent).exprName === node)) || + (node.parent.kind === SyntaxKind.ExportSpecifier && (compilerOptions.preserveConstEnums || node.flags & NodeFlags.Ambient)); // We allow reexporting const enums if (!ok) { error(node, Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); @@ -30152,6 +30161,10 @@ namespace ts { } else { markExportAsReferenced(node); + const target = symbol && (symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & SymbolFlags.Value) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -30178,7 +30191,17 @@ namespace ts { grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === SyntaxKind.Identifier) { - markExportAsReferenced(node); + const id = node.expression as Identifier; + const sym = resolveEntityName(id, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + const target = sym.flags & SymbolFlags.Alias ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & SymbolFlags.Value) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression as Identifier, /*setVisibility*/ true); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 725657533dd..f0f36dc765f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1743,6 +1743,16 @@ namespace ts { return false; } + /** @internal */ + export interface TSConfig { + compilerOptions: CompilerOptions; + compileOnSave: boolean | undefined; + exclude?: ReadonlyArray; + files: ReadonlyArray | undefined; + include?: ReadonlyArray; + references: ReadonlyArray | undefined; + } + /** * Generate an uncommented, complete tsconfig for use with "--showConfig" * @param configParseResult options to be generated into tsconfig.json @@ -1750,7 +1760,7 @@ namespace ts { * @param host provides current directory and case sensitivity services */ /** @internal */ - export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): object { + export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): TSConfig { const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); const files = map( filter( @@ -1778,13 +1788,13 @@ namespace ts { build: undefined, version: undefined, }, - references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath, originalPath: undefined })), + references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath ? r.originalPath : "", originalPath: undefined })), files: length(files) ? files : undefined, ...(configParseResult.configFileSpecs ? { include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), exclude: configParseResult.configFileSpecs.validatedExcludeSpecs } : {}), - compilerOnSave: !!configParseResult.compileOnSave ? true : undefined + compileOnSave: !!configParseResult.compileOnSave ? true : undefined }; return config; } diff --git a/src/compiler/transformers/es2018.ts b/src/compiler/transformers/es2018.ts index 94ccf6a08a9..67f361d0471 100644 --- a/src/compiler/transformers/es2018.ts +++ b/src/compiler/transformers/es2018.ts @@ -22,6 +22,7 @@ namespace ts { const previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + let exportedVariableStatement = false; let enabledSubstitutions: ESNextSubstitutionFlags; let enclosingFunctionFlags: FunctionFlags; let enclosingSuperContainerFlags: NodeCheckFlags = 0; @@ -40,6 +41,7 @@ namespace ts { return node; } + exportedVariableStatement = false; const visited = visitEachChild(node, visitor, context); addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -79,6 +81,8 @@ namespace ts { return visitBinaryExpression(node as BinaryExpression, noDestructuringValue); case SyntaxKind.CatchClause: return visitCatchClause(node as CatchClause); + case SyntaxKind.VariableStatement: + return visitVariableStatement(node as VariableStatement); case SyntaxKind.VariableDeclaration: return visitVariableDeclaration(node as VariableDeclaration); case SyntaxKind.ForOfStatement: @@ -321,19 +325,43 @@ namespace ts { return visitEachChild(node, visitor, context); } + function visitVariableStatement(node: VariableStatement): VisitResult { + if (hasModifier(node, ModifierFlags.Export)) { + const savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + const visited = visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitEachChild(node, visitor, context); + } + /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node: VariableDeclaration): VisitResult { + if (exportedVariableStatement) { + const savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + const visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + + function visitVariableDeclarationWorker(node: VariableDeclaration, exportedVariableStatement: boolean): VisitResult { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. if (isBindingPattern(node.name) && node.name.transformFlags & TransformFlags.ContainsObjectRestOrSpread) { return flattenDestructuringBinding( node, visitor, context, - FlattenLevel.ObjectRest + FlattenLevel.ObjectRest, + /*rval*/ undefined, + exportedVariableStatement ); } return visitEachChild(node, visitor, context); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c36b0341db3..9c0e71e28ea 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -567,6 +567,8 @@ namespace ts { return emitNode && emitNode.flags || 0; } + const escapeNoSubstitutionTemplateLiteralText = compose(escapeString, escapeTemplateSubstitution); + const escapeNonAsciiNoSubstitutionTemplateLiteralText = compose(escapeNonAsciiString, escapeTemplateSubstitution); export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, neverAsciiEscape: boolean | undefined) { // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. @@ -577,7 +579,11 @@ namespace ts { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } - const escapeText = neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ? escapeString : escapeNonAsciiString; + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. + const escapeText = neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ? + node.kind === SyntaxKind.NoSubstitutionTemplateLiteral ? escapeNoSubstitutionTemplateLiteralText : escapeString : + node.kind === SyntaxKind.NoSubstitutionTemplateLiteral ? escapeNonAsciiNoSubstitutionTemplateLiteralText : escapeNonAsciiString; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. @@ -3118,6 +3124,11 @@ namespace ts { } } + const templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str: string): string { + return str.replace(templateSubstitutionRegExp, "\\${"); + } + // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ecf46f9977d..2f7c1a9f30c 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -730,6 +730,7 @@ namespace Harness { includeBuiltFile?: string; baselineFile?: string; libFiles?: string; + noTypesAndSymbols?: boolean; } // Additional options not already in ts.optionDeclarations @@ -746,6 +747,7 @@ namespace Harness { { name: "currentDirectory", type: "string" }, { name: "symlink", type: "string" }, { name: "link", type: "string" }, + { name: "noTypesAndSymbols", type: "boolean" }, // Emitted js baseline will print full paths for every output file { name: "fullEmitPaths", type: "boolean" } ]; diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 2734d059000..dc5e5a1a9d8 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -577,10 +577,10 @@ namespace ts.FindAllReferences { // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent: Node, node: Node): Node | undefined { - if (parent.kind === SyntaxKind.VariableDeclaration) { - const p = parent as VariableDeclaration; - return p.name !== node ? undefined : - p.parent.kind === SyntaxKind.CatchClause ? undefined : p.parent.parent.kind === SyntaxKind.VariableStatement ? p.parent.parent : undefined; + const declaration = isVariableDeclaration(parent) ? parent : isBindingElement(parent) ? walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return (parent as VariableDeclaration | BindingElement).name !== node ? undefined : + isCatchClause(declaration.parent) ? undefined : isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index 5efef8dfdaf..e922fab5bcf 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -58,16 +58,18 @@ class CompilerBaselineRunner extends RunnerBase { } public checkTestCodeOutput(fileName: string, test?: CompilerFileBasedTest) { - if (test && test.configurations) { + if (test && ts.some(test.configurations)) { test.configurations.forEach(configuration => { describe(`${this.testSuiteName} tests for ${fileName}${configuration ? ` (${Harness.getFileBasedTestConfigurationDescription(configuration)})` : ``}`, () => { this.runSuite(fileName, test, configuration); }); }); } - describe(`${this.testSuiteName} tests for ${fileName}`, () => { - this.runSuite(fileName, test); - }); + else { + describe(`${this.testSuiteName} tests for ${fileName}`, () => { + this.runSuite(fileName, test); + }); + } } private runSuite(fileName: string, test?: CompilerFileBasedTest, configuration?: Harness.FileBasedTestConfiguration) { @@ -112,6 +114,7 @@ class CompilerBaselineRunner extends RunnerBase { class CompilerTest { private fileName: string; private justName: string; + private configuredName: string; private lastUnit: Harness.TestCaseParser.TestUnitData; private harnessSettings: Harness.TestCaseParser.CompilerSettings; private hasNonDtsFiles: boolean; @@ -126,6 +129,25 @@ class CompilerTest { constructor(fileName: string, testCaseContent?: Harness.TestCaseParser.TestCaseContent, configurationOverrides?: Harness.TestCaseParser.CompilerSettings) { this.fileName = fileName; this.justName = vpath.basename(fileName); + this.configuredName = this.justName; + if (configurationOverrides) { + let configuredName = ""; + const keys = Object + .keys(configurationOverrides) + .map(k => k.toLowerCase()) + .sort(); + for (const key of keys) { + if (configuredName) { + configuredName += ","; + } + configuredName += `${key}=${configurationOverrides[key].toLowerCase()}`; + } + if (configuredName) { + const extname = vpath.extname(this.justName); + const basename = vpath.basename(this.justName, extname, /*ignoreCase*/ true); + this.configuredName = `${basename}(${configuredName})${extname}`; + } + } const rootDir = fileName.indexOf("conformance") === -1 ? "tests/cases/compiler/" : ts.getDirectoryPath(fileName) + "/"; @@ -205,7 +227,7 @@ class CompilerTest { public verifyDiagnostics() { // check errors Harness.Compiler.doErrorBaseline( - this.justName, + this.configuredName, this.tsConfigFiles.concat(this.toBeCompiled, this.otherFiles), this.result.diagnostics, !!this.options.pretty); @@ -213,7 +235,7 @@ class CompilerTest { public verifyModuleResolution() { if (this.options.traceResolution) { - Harness.Baseline.runBaseline(this.justName.replace(/\.tsx?$/, ".trace.json"), + Harness.Baseline.runBaseline(this.configuredName.replace(/\.tsx?$/, ".trace.json"), JSON.stringify(this.result.traces.map(utils.sanitizeTraceResolutionLogEntry), undefined, 4)); } } @@ -225,14 +247,14 @@ class CompilerTest { // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. ? null // eslint-disable-line no-null/no-null : record; - Harness.Baseline.runBaseline(this.justName.replace(/\.tsx?$/, ".sourcemap.txt"), baseline); + Harness.Baseline.runBaseline(this.configuredName.replace(/\.tsx?$/, ".sourcemap.txt"), baseline); } } public verifyJavaScriptOutput() { if (this.hasNonDtsFiles) { Harness.Compiler.doJsEmitBaseline( - this.justName, + this.configuredName, this.fileName, this.options, this.result, @@ -245,7 +267,7 @@ class CompilerTest { public verifySourceMapOutput() { Harness.Compiler.doSourcemapBaseline( - this.justName, + this.configuredName, this.options, this.result, this.harnessSettings); @@ -256,8 +278,15 @@ class CompilerTest { return; } + const noTypesAndSymbols = + this.harnessSettings.noTypesAndSymbols && + this.harnessSettings.noTypesAndSymbols.toLowerCase() === "true"; + if (noTypesAndSymbols) { + return; + } + Harness.Compiler.doTypeAndSymbolBaseline( - this.justName, + this.configuredName, this.result.program!, this.toBeCompiled.concat(this.otherFiles).filter(file => !!this.result.program!.getSourceFile(file.unitName)), /*opts*/ undefined, diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 7d0cea1ea64..8c8e90c8d9f 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -131,6 +131,7 @@ "unittests/tsserver/formatSettings.ts", "unittests/tsserver/getApplicableRefactors.ts", "unittests/tsserver/getEditsForFileRename.ts", + "unittests/tsserver/getExportReferences.ts", "unittests/tsserver/importHelpers.ts", "unittests/tsserver/inferredProjects.ts", "unittests/tsserver/languageService.ts", diff --git a/src/testRunner/unittests/config/showConfig.ts b/src/testRunner/unittests/config/showConfig.ts index 165a557db84..ca2e76e25a6 100644 --- a/src/testRunner/unittests/config/showConfig.ts +++ b/src/testRunner/unittests/config/showConfig.ts @@ -53,6 +53,26 @@ namespace ts { showTSConfigCorrectly("Show TSConfig with advanced options", ["--showConfig", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]); + showTSConfigCorrectly("Show TSConfig with compileOnSave and more", ["-p", "tsconfig.json"], { + compilerOptions: { + esModuleInterop: true, + target: "es5", + module: "commonjs", + strict: true, + }, + compileOnSave: true, + exclude: [ + "dist" + ], + files: [], + include: [ + "src/*" + ], + references: [ + { path: "./test" } + ], + }); + // Regression test for https://github.com/Microsoft/TypeScript/issues/28836 showTSConfigCorrectly("Show TSConfig with paths and more", ["-p", "tsconfig.json"], { compilerOptions: { diff --git a/src/testRunner/unittests/tsserver/declarationFileMaps.ts b/src/testRunner/unittests/tsserver/declarationFileMaps.ts index 0f8af3c414e..734af2a68fe 100644 --- a/src/testRunner/unittests/tsserver/declarationFileMaps.ts +++ b/src/testRunner/unittests/tsserver/declarationFileMaps.ts @@ -1,11 +1,4 @@ namespace ts.projectSystem { - interface DocumentSpanFromSubstring { - file: File; - text: string; - options?: SpanFromSubstringOptions; - contextText?: string; - contextOptions?: SpanFromSubstringOptions; - } function documentSpanFromSubstring({ file, text, contextText, options, contextOptions }: DocumentSpanFromSubstring): DocumentSpan { const contextSpan = contextText !== undefined ? documentSpanFromSubstring({ file, text: contextText, options: contextOptions }) : undefined; return { @@ -19,19 +12,6 @@ namespace ts.projectSystem { return documentSpanFromSubstring(input); } - interface MakeReferenceItem extends DocumentSpanFromSubstring { - isDefinition: boolean; - lineText: string; - } - function makeReferenceItem({ isDefinition, lineText, ...rest }: MakeReferenceItem): protocol.ReferencesResponseItem { - return { - ...protocolFileSpanWithContextFromSubstring(rest), - isDefinition, - isWriteAccess: isDefinition, - lineText, - }; - } - interface MakeReferenceEntry extends DocumentSpanFromSubstring { isDefinition: boolean; } diff --git a/src/testRunner/unittests/tsserver/getExportReferences.ts b/src/testRunner/unittests/tsserver/getExportReferences.ts new file mode 100644 index 00000000000..45bd08e39b8 --- /dev/null +++ b/src/testRunner/unittests/tsserver/getExportReferences.ts @@ -0,0 +1,185 @@ +namespace ts.projectSystem { + describe("unittests:: tsserver:: getExportReferences", () => { + const exportVariable = "export const value = 0;"; + const exportArrayDestructured = "export const [valueA, valueB] = [0, 1];"; + const exportObjectDestructured = "export const { valueC, valueD: renamedD } = { valueC: 0, valueD: 1 };"; + const exportNestedObject = "export const { nest: [valueE, { valueF }] } = { nest: [0, { valueF: 1 }] };"; + + const mainTs: File = { + path: "/main.ts", + content: 'import { value, valueA, valueB, valueC, renamedD, valueE, valueF } from "./mod";', + }; + const modTs: File = { + path: "/mod.ts", + content: `${exportVariable} +${exportArrayDestructured} +${exportObjectDestructured} +${exportNestedObject} +`, + }; + const tsconfig: File = { + path: "/tsconfig.json", + content: "{}", + }; + + function makeSampleSession() { + const host = createServerHost([mainTs, modTs, tsconfig]); + const session = createSession(host); + openFilesForSession([mainTs, modTs], session); + return session; + } + + const referenceMainTs = (mainTs: File, text: string): protocol.ReferencesResponseItem => + makeReferenceItem({ + file: mainTs, + isDefinition: true, + lineText: mainTs.content, + contextText: mainTs.content, + text, + }); + + const referenceModTs = ( + texts: { text: string; lineText: string; contextText?: string }, + override: Partial = {}, + ): protocol.ReferencesResponseItem => + makeReferenceItem({ + file: modTs, + isDefinition: true, + ...texts, + ...override, + }); + + it("should get const variable declaration references", () => { + const session = makeSampleSession(); + + const response = executeSessionRequest( + session, + protocol.CommandTypes.References, + protocolFileLocationFromSubstring(modTs, "value"), + ); + + const expectResponse = { + refs: [ + referenceModTs({ text: "value", lineText: exportVariable, contextText: exportVariable }), + referenceMainTs(mainTs, "value"), + ], + symbolDisplayString: "const value: 0", + symbolName: "value", + symbolStartOffset: protocolLocationFromSubstring(modTs.content, "value").offset, + }; + + assert.deepEqual(response, expectResponse); + }); + + it("should get array destructuring declaration references", () => { + const session = makeSampleSession(); + const response = executeSessionRequest( + session, + protocol.CommandTypes.References, + protocolFileLocationFromSubstring(modTs, "valueA"), + ); + + const expectResponse = { + refs: [ + referenceModTs({ + text: "valueA", + lineText: exportArrayDestructured, + contextText: exportArrayDestructured, + }), + referenceMainTs(mainTs, "valueA"), + ], + symbolDisplayString: "const valueA: number", + symbolName: "valueA", + symbolStartOffset: protocolLocationFromSubstring(modTs.content, "valueA").offset, + }; + + assert.deepEqual(response, expectResponse); + }); + + it("should get object destructuring declaration references", () => { + const session = makeSampleSession(); + const response = executeSessionRequest( + session, + protocol.CommandTypes.References, + protocolFileLocationFromSubstring(modTs, "valueC"), + ); + const expectResponse = { + refs: [ + referenceModTs({ + text: "valueC", + lineText: exportObjectDestructured, + contextText: exportObjectDestructured, + }), + referenceMainTs(mainTs, "valueC"), + referenceModTs( + { text: "valueC", lineText: exportObjectDestructured, contextText: "valueC: 0" }, + { options: { index: 1 } }, + ), + ], + symbolDisplayString: "const valueC: number", + symbolName: "valueC", + symbolStartOffset: protocolLocationFromSubstring(modTs.content, "valueC").offset, + }; + + assert.deepEqual(response, expectResponse); + }); + + it("should get object declaration references that renames destructured property", () => { + const session = makeSampleSession(); + const response = executeSessionRequest( + session, + protocol.CommandTypes.References, + protocolFileLocationFromSubstring(modTs, "renamedD"), + ); + + const expectResponse = { + refs: [ + referenceModTs({ + text: "renamedD", + lineText: exportObjectDestructured, + contextText: exportObjectDestructured, + }), + referenceMainTs(mainTs, "renamedD"), + ], + symbolDisplayString: "const renamedD: number", + symbolName: "renamedD", + symbolStartOffset: protocolLocationFromSubstring(modTs.content, "renamedD").offset, + }; + + assert.deepEqual(response, expectResponse); + }); + + it("should get nested object declaration references", () => { + const session = makeSampleSession(); + const response = executeSessionRequest( + session, + protocol.CommandTypes.References, + protocolFileLocationFromSubstring(modTs, "valueF"), + ); + + const expectResponse = { + refs: [ + referenceModTs({ + text: "valueF", + lineText: exportNestedObject, + contextText: exportNestedObject, + }), + referenceMainTs(mainTs, "valueF"), + referenceModTs( + { + text: "valueF", + lineText: exportNestedObject, + contextText: "valueF: 1", + }, + { options: { index: 1 } }, + ), + ], + symbolDisplayString: "const valueF: number", + symbolName: "valueF", + symbolStartOffset: protocolLocationFromSubstring(modTs.content, "valueF").offset, + }; + + assert.deepEqual(response, expectResponse); + }); + }); +} diff --git a/src/testRunner/unittests/tsserver/helpers.ts b/src/testRunner/unittests/tsserver/helpers.ts index 37165307322..22a091d3937 100644 --- a/src/testRunner/unittests/tsserver/helpers.ts +++ b/src/testRunner/unittests/tsserver/helpers.ts @@ -519,6 +519,8 @@ namespace ts.projectSystem { file: File; text: string; options?: SpanFromSubstringOptions; + contextText?: string; + contextOptions?: SpanFromSubstringOptions; } export function protocolFileSpanFromSubstring({ file, text, options }: DocumentSpanFromSubstring): protocol.FileSpan { return { file: file.path, ...protocolTextSpanFromSubstring(file.content, text, options) }; @@ -727,4 +729,18 @@ namespace ts.projectSystem { assert.strictEqual(outputs.length, index + 1, JSON.stringify(outputs)); } } + + export interface MakeReferenceItem extends DocumentSpanFromSubstring { + isDefinition: boolean; + lineText: string; + } + + export function makeReferenceItem({ isDefinition, lineText, ...rest }: MakeReferenceItem): protocol.ReferencesResponseItem { + return { + ...protocolFileSpanWithContextFromSubstring(rest), + isDefinition, + isWriteAccess: isDefinition, + lineText, + }; + } } diff --git a/tests/baselines/reference/amdModuleConstEnumUsage.js b/tests/baselines/reference/amdModuleConstEnumUsage.js new file mode 100644 index 00000000000..a15bdb42ea3 --- /dev/null +++ b/tests/baselines/reference/amdModuleConstEnumUsage.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/amdModuleConstEnumUsage.ts] //// + +//// [cc.ts] +export const enum CharCode { + A, + B +} +//// [file.ts] +import { CharCode } from 'defs/cc'; +export class User { + method(input: number) { + if (CharCode.A === input) {} + } +} + + +//// [cc.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + exports.__esModule = true; + var CharCode; + (function (CharCode) { + CharCode[CharCode["A"] = 0] = "A"; + CharCode[CharCode["B"] = 1] = "B"; + })(CharCode = exports.CharCode || (exports.CharCode = {})); +}); +//// [file.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + exports.__esModule = true; + var User = /** @class */ (function () { + function User() { + } + User.prototype.method = function (input) { + if (0 /* A */ === input) { } + }; + return User; + }()); + exports.User = User; +}); diff --git a/tests/baselines/reference/amdModuleConstEnumUsage.symbols b/tests/baselines/reference/amdModuleConstEnumUsage.symbols new file mode 100644 index 00000000000..d6831b01814 --- /dev/null +++ b/tests/baselines/reference/amdModuleConstEnumUsage.symbols @@ -0,0 +1,29 @@ +=== /proj/defs/cc.ts === +export const enum CharCode { +>CharCode : Symbol(CharCode, Decl(cc.ts, 0, 0)) + + A, +>A : Symbol(CharCode.A, Decl(cc.ts, 0, 28)) + + B +>B : Symbol(CharCode.B, Decl(cc.ts, 1, 6)) +} +=== /proj/component/file.ts === +import { CharCode } from 'defs/cc'; +>CharCode : Symbol(CharCode, Decl(file.ts, 0, 8)) + +export class User { +>User : Symbol(User, Decl(file.ts, 0, 35)) + + method(input: number) { +>method : Symbol(User.method, Decl(file.ts, 1, 19)) +>input : Symbol(input, Decl(file.ts, 2, 11)) + + if (CharCode.A === input) {} +>CharCode.A : Symbol(CharCode.A, Decl(cc.ts, 0, 28)) +>CharCode : Symbol(CharCode, Decl(file.ts, 0, 8)) +>A : Symbol(CharCode.A, Decl(cc.ts, 0, 28)) +>input : Symbol(input, Decl(file.ts, 2, 11)) + } +} + diff --git a/tests/baselines/reference/amdModuleConstEnumUsage.types b/tests/baselines/reference/amdModuleConstEnumUsage.types new file mode 100644 index 00000000000..2070c5733a0 --- /dev/null +++ b/tests/baselines/reference/amdModuleConstEnumUsage.types @@ -0,0 +1,30 @@ +=== /proj/defs/cc.ts === +export const enum CharCode { +>CharCode : CharCode + + A, +>A : CharCode.A + + B +>B : CharCode.B +} +=== /proj/component/file.ts === +import { CharCode } from 'defs/cc'; +>CharCode : typeof CharCode + +export class User { +>User : User + + method(input: number) { +>method : (input: number) => void +>input : number + + if (CharCode.A === input) {} +>CharCode.A === input : boolean +>CharCode.A : CharCode.A +>CharCode : typeof CharCode +>A : CharCode.A +>input : number + } +} + diff --git a/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.js b/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.js new file mode 100644 index 00000000000..0edacd183ef --- /dev/null +++ b/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/constEnumNoPreserveDeclarationReexport.ts] //// + +//// [ConstEnum.d.ts] +export const enum MyConstEnum { + Foo, + Bar +} +//// [ImportExport.d.ts] +import { MyConstEnum } from './ConstEnum'; +export default MyConstEnum; +//// [ReExport.d.ts] +export { MyConstEnum as default } from './ConstEnum'; +//// [usages.ts] +import {MyConstEnum} from "./ConstEnum"; +import AlsoEnum from "./ImportExport"; +import StillEnum from "./ReExport"; + +MyConstEnum.Foo; +AlsoEnum.Foo; +StillEnum.Foo; + + +//// [usages.js] +"use strict"; +exports.__esModule = true; +0 /* Foo */; +0 /* Foo */; +0 /* Foo */; diff --git a/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.symbols b/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.symbols new file mode 100644 index 00000000000..62f839e02dd --- /dev/null +++ b/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.symbols @@ -0,0 +1,47 @@ +=== tests/cases/compiler/ConstEnum.d.ts === +export const enum MyConstEnum { +>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.d.ts, 0, 0)) + + Foo, +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31)) + + Bar +>Bar : Symbol(MyConstEnum.Bar, Decl(ConstEnum.d.ts, 1, 8)) +} +=== tests/cases/compiler/ImportExport.d.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.d.ts, 0, 8)) + +export default MyConstEnum; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.d.ts, 0, 8)) + +=== tests/cases/compiler/ReExport.d.ts === +export { MyConstEnum as default } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.d.ts, 0, 0)) +>default : Symbol(default, Decl(ReExport.d.ts, 0, 8)) + +=== tests/cases/compiler/usages.ts === +import {MyConstEnum} from "./ConstEnum"; +>MyConstEnum : Symbol(MyConstEnum, Decl(usages.ts, 0, 8)) + +import AlsoEnum from "./ImportExport"; +>AlsoEnum : Symbol(AlsoEnum, Decl(usages.ts, 1, 6)) + +import StillEnum from "./ReExport"; +>StillEnum : Symbol(StillEnum, Decl(usages.ts, 2, 6)) + +MyConstEnum.Foo; +>MyConstEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31)) +>MyConstEnum : Symbol(MyConstEnum, Decl(usages.ts, 0, 8)) +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31)) + +AlsoEnum.Foo; +>AlsoEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31)) +>AlsoEnum : Symbol(AlsoEnum, Decl(usages.ts, 1, 6)) +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31)) + +StillEnum.Foo; +>StillEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31)) +>StillEnum : Symbol(StillEnum, Decl(usages.ts, 2, 6)) +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31)) + diff --git a/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.types b/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.types new file mode 100644 index 00000000000..f68ae116a18 --- /dev/null +++ b/tests/baselines/reference/constEnumNoPreserveDeclarationReexport.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/ConstEnum.d.ts === +export const enum MyConstEnum { +>MyConstEnum : MyConstEnum + + Foo, +>Foo : MyConstEnum + + Bar +>Bar : MyConstEnum +} +=== tests/cases/compiler/ImportExport.d.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : typeof MyConstEnum + +export default MyConstEnum; +>MyConstEnum : MyConstEnum + +=== tests/cases/compiler/ReExport.d.ts === +export { MyConstEnum as default } from './ConstEnum'; +>MyConstEnum : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum +>default : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum + +=== tests/cases/compiler/usages.ts === +import {MyConstEnum} from "./ConstEnum"; +>MyConstEnum : typeof MyConstEnum + +import AlsoEnum from "./ImportExport"; +>AlsoEnum : typeof MyConstEnum + +import StillEnum from "./ReExport"; +>StillEnum : typeof MyConstEnum + +MyConstEnum.Foo; +>MyConstEnum.Foo : MyConstEnum +>MyConstEnum : typeof MyConstEnum +>Foo : MyConstEnum + +AlsoEnum.Foo; +>AlsoEnum.Foo : MyConstEnum +>AlsoEnum : typeof MyConstEnum +>Foo : MyConstEnum + +StillEnum.Foo; +>StillEnum.Foo : MyConstEnum +>StillEnum : typeof MyConstEnum +>Foo : MyConstEnum + diff --git a/tests/baselines/reference/constEnumPreserveEmitReexport.js b/tests/baselines/reference/constEnumPreserveEmitReexport.js new file mode 100644 index 00000000000..24914ee899b --- /dev/null +++ b/tests/baselines/reference/constEnumPreserveEmitReexport.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/constEnumPreserveEmitReexport.ts] //// + +//// [ConstEnum.ts] +export const enum MyConstEnum { + Foo, + Bar +}; +//// [ImportExport.ts] +import { MyConstEnum } from './ConstEnum'; +export default MyConstEnum; +//// [ReExport.ts] +export { MyConstEnum as default } from './ConstEnum'; + +//// [ConstEnum.js] +"use strict"; +exports.__esModule = true; +var MyConstEnum; +(function (MyConstEnum) { + MyConstEnum[MyConstEnum["Foo"] = 0] = "Foo"; + MyConstEnum[MyConstEnum["Bar"] = 1] = "Bar"; +})(MyConstEnum = exports.MyConstEnum || (exports.MyConstEnum = {})); +; +//// [ImportExport.js] +"use strict"; +exports.__esModule = true; +var ConstEnum_1 = require("./ConstEnum"); +exports["default"] = ConstEnum_1.MyConstEnum; +//// [ReExport.js] +"use strict"; +exports.__esModule = true; +var ConstEnum_1 = require("./ConstEnum"); +exports["default"] = ConstEnum_1.MyConstEnum; diff --git a/tests/baselines/reference/constEnumPreserveEmitReexport.symbols b/tests/baselines/reference/constEnumPreserveEmitReexport.symbols new file mode 100644 index 00000000000..0e4e240b4f4 --- /dev/null +++ b/tests/baselines/reference/constEnumPreserveEmitReexport.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/ConstEnum.ts === +export const enum MyConstEnum { +>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.ts, 0, 0)) + + Foo, +>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.ts, 0, 31)) + + Bar +>Bar : Symbol(MyConstEnum.Bar, Decl(ConstEnum.ts, 1, 8)) + +}; +=== tests/cases/compiler/ImportExport.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.ts, 0, 8)) + +export default MyConstEnum; +>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.ts, 0, 8)) + +=== tests/cases/compiler/ReExport.ts === +export { MyConstEnum as default } from './ConstEnum'; +>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.ts, 0, 0)) +>default : Symbol(default, Decl(ReExport.ts, 0, 8)) + diff --git a/tests/baselines/reference/constEnumPreserveEmitReexport.types b/tests/baselines/reference/constEnumPreserveEmitReexport.types new file mode 100644 index 00000000000..d003cdd878a --- /dev/null +++ b/tests/baselines/reference/constEnumPreserveEmitReexport.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/ConstEnum.ts === +export const enum MyConstEnum { +>MyConstEnum : MyConstEnum + + Foo, +>Foo : MyConstEnum.Foo + + Bar +>Bar : MyConstEnum.Bar + +}; +=== tests/cases/compiler/ImportExport.ts === +import { MyConstEnum } from './ConstEnum'; +>MyConstEnum : typeof MyConstEnum + +export default MyConstEnum; +>MyConstEnum : MyConstEnum + +=== tests/cases/compiler/ReExport.ts === +export { MyConstEnum as default } from './ConstEnum'; +>MyConstEnum : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum +>default : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum + diff --git a/tests/baselines/reference/exportAsNamespaceConflict.errors.txt b/tests/baselines/reference/exportAsNamespaceConflict.errors.txt index 02d7f859a69..4b08c736069 100644 --- a/tests/baselines/reference/exportAsNamespaceConflict.errors.txt +++ b/tests/baselines/reference/exportAsNamespaceConflict.errors.txt @@ -1,12 +1,9 @@ -/a.d.ts(2,10): error TS2708: Cannot use namespace 'N' as a value. /a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'. -==== /a.d.ts (2 errors) ==== +==== /a.d.ts (1 errors) ==== declare global { namespace N {} } export = N; - ~ -!!! error TS2708: Cannot use namespace 'N' as a value. export as namespace N; ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2303: Circular definition of import alias 'N'. diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=amd,target=es5).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=amd,target=es5).js new file mode 100644 index 00000000000..a116fcf0d32 --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=amd,target=es5).js @@ -0,0 +1,10 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var _a; + Object.defineProperty(exports, "__esModule", { value: true }); + exports._b = _a = []; +}); diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=amd,target=esnext).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=amd,target=esnext).js new file mode 100644 index 00000000000..792a6ebbc59 --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=amd,target=esnext).js @@ -0,0 +1,10 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var _a; + Object.defineProperty(exports, "__esModule", { value: true }); + _a = []; +}); diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=commonjs,target=es5).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=commonjs,target=es5).js new file mode 100644 index 00000000000..f6d59500611 --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=commonjs,target=es5).js @@ -0,0 +1,8 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._b = _a = []; diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=commonjs,target=esnext).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=commonjs,target=esnext).js new file mode 100644 index 00000000000..f7f8c3af8ed --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=commonjs,target=esnext).js @@ -0,0 +1,8 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +_a = []; diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=es2015,target=es5).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=es2015,target=es5).js new file mode 100644 index 00000000000..5884c8a996b --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=es2015,target=es5).js @@ -0,0 +1,6 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +var _a; +export var _b = _a = []; diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=es2015,target=esnext).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=es2015,target=esnext).js new file mode 100644 index 00000000000..f2845fa1801 --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=es2015,target=esnext).js @@ -0,0 +1,5 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +export const [] = []; diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=esnext,target=es5).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=esnext,target=es5).js new file mode 100644 index 00000000000..5884c8a996b --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=esnext,target=es5).js @@ -0,0 +1,6 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +var _a; +export var _b = _a = []; diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=esnext,target=esnext).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=esnext,target=esnext).js new file mode 100644 index 00000000000..f2845fa1801 --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=esnext,target=esnext).js @@ -0,0 +1,5 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +export const [] = []; diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=system,target=es5).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=system,target=es5).js new file mode 100644 index 00000000000..73694099aa4 --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=system,target=es5).js @@ -0,0 +1,15 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var _a, _b; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + exports_1("_b", _b = _a = []); + } + }; +}); diff --git a/tests/baselines/reference/exportEmptyArrayBindingPattern(module=system,target=esnext).js b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=system,target=esnext).js new file mode 100644 index 00000000000..4e6607b8d5b --- /dev/null +++ b/tests/baselines/reference/exportEmptyArrayBindingPattern(module=system,target=esnext).js @@ -0,0 +1,15 @@ +//// [exportEmptyArrayBindingPattern.ts] +export const [] = []; + +//// [exportEmptyArrayBindingPattern.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var _a; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + _a = []; + } + }; +}); diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=amd,target=es5).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=amd,target=es5).js new file mode 100644 index 00000000000..99fda139158 --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=amd,target=es5).js @@ -0,0 +1,10 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var _a; + Object.defineProperty(exports, "__esModule", { value: true }); + exports._b = _a = {}; +}); diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=amd,target=esnext).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=amd,target=esnext).js new file mode 100644 index 00000000000..5e145123912 --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=amd,target=esnext).js @@ -0,0 +1,10 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var _a; + Object.defineProperty(exports, "__esModule", { value: true }); + _a = {}; +}); diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=commonjs,target=es5).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=commonjs,target=es5).js new file mode 100644 index 00000000000..880d9a68f7e --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=commonjs,target=es5).js @@ -0,0 +1,8 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._b = _a = {}; diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=commonjs,target=esnext).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=commonjs,target=esnext).js new file mode 100644 index 00000000000..dd4f0e703ce --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=commonjs,target=esnext).js @@ -0,0 +1,8 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +_a = {}; diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=es2015,target=es5).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=es2015,target=es5).js new file mode 100644 index 00000000000..983588eed3f --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=es2015,target=es5).js @@ -0,0 +1,6 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +var _a; +export var _b = _a = {}; diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=es2015,target=esnext).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=es2015,target=esnext).js new file mode 100644 index 00000000000..8fa77b37a6c --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=es2015,target=esnext).js @@ -0,0 +1,5 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +export const {} = {}; diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=esnext,target=es5).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=esnext,target=es5).js new file mode 100644 index 00000000000..983588eed3f --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=esnext,target=es5).js @@ -0,0 +1,6 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +var _a; +export var _b = _a = {}; diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=esnext,target=esnext).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=esnext,target=esnext).js new file mode 100644 index 00000000000..8fa77b37a6c --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=esnext,target=esnext).js @@ -0,0 +1,5 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +export const {} = {}; diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=system,target=es5).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=system,target=es5).js new file mode 100644 index 00000000000..4514b6e6827 --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=system,target=es5).js @@ -0,0 +1,15 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var _a, _b; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + exports_1("_b", _b = _a = {}); + } + }; +}); diff --git a/tests/baselines/reference/exportEmptyObjectBindingPattern(module=system,target=esnext).js b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=system,target=esnext).js new file mode 100644 index 00000000000..5ce16afefd8 --- /dev/null +++ b/tests/baselines/reference/exportEmptyObjectBindingPattern(module=system,target=esnext).js @@ -0,0 +1,15 @@ +//// [exportEmptyObjectBindingPattern.ts] +export const {} = {}; + +//// [exportEmptyObjectBindingPattern.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var _a; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + _a = {}; + } + }; +}); diff --git a/tests/baselines/reference/exportObjectRest(module=amd,target=es5).js b/tests/baselines/reference/exportObjectRest(module=amd,target=es5).js new file mode 100644 index 00000000000..b265cc92f10 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=amd,target=es5).js @@ -0,0 +1,10 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var _a; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.x = (_a = { x: 'x', y: 'y' }, _a).x, exports.rest = __rest(_a, ["x"]); +}); diff --git a/tests/baselines/reference/exportObjectRest(module=amd,target=esnext).js b/tests/baselines/reference/exportObjectRest(module=amd,target=esnext).js new file mode 100644 index 00000000000..17295b35d20 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=amd,target=esnext).js @@ -0,0 +1,10 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var _a; + Object.defineProperty(exports, "__esModule", { value: true }); + _a = { x: 'x', y: 'y' }, exports.x = _a.x, exports.rest = __rest(_a, ["x"]); +}); diff --git a/tests/baselines/reference/exportObjectRest(module=commonjs,target=es5).js b/tests/baselines/reference/exportObjectRest(module=commonjs,target=es5).js new file mode 100644 index 00000000000..8ee5bc8229f --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=commonjs,target=es5).js @@ -0,0 +1,8 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = (_a = { x: 'x', y: 'y' }, _a).x, exports.rest = __rest(_a, ["x"]); diff --git a/tests/baselines/reference/exportObjectRest(module=commonjs,target=esnext).js b/tests/baselines/reference/exportObjectRest(module=commonjs,target=esnext).js new file mode 100644 index 00000000000..9776a14af53 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=commonjs,target=esnext).js @@ -0,0 +1,8 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +_a = { x: 'x', y: 'y' }, exports.x = _a.x, exports.rest = __rest(_a, ["x"]); diff --git a/tests/baselines/reference/exportObjectRest(module=es2015,target=es5).js b/tests/baselines/reference/exportObjectRest(module=es2015,target=es5).js new file mode 100644 index 00000000000..e6ac6b0e622 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=es2015,target=es5).js @@ -0,0 +1,6 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +var _a; +export var x = (_a = { x: 'x', y: 'y' }, _a).x, rest = __rest(_a, ["x"]); diff --git a/tests/baselines/reference/exportObjectRest(module=es2015,target=esnext).js b/tests/baselines/reference/exportObjectRest(module=es2015,target=esnext).js new file mode 100644 index 00000000000..ad3fec1da45 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=es2015,target=esnext).js @@ -0,0 +1,5 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +export const { x, ...rest } = { x: 'x', y: 'y' }; diff --git a/tests/baselines/reference/exportObjectRest(module=esnext,target=es5).js b/tests/baselines/reference/exportObjectRest(module=esnext,target=es5).js new file mode 100644 index 00000000000..e6ac6b0e622 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=esnext,target=es5).js @@ -0,0 +1,6 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +var _a; +export var x = (_a = { x: 'x', y: 'y' }, _a).x, rest = __rest(_a, ["x"]); diff --git a/tests/baselines/reference/exportObjectRest(module=esnext,target=esnext).js b/tests/baselines/reference/exportObjectRest(module=esnext,target=esnext).js new file mode 100644 index 00000000000..ad3fec1da45 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=esnext,target=esnext).js @@ -0,0 +1,5 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +export const { x, ...rest } = { x: 'x', y: 'y' }; diff --git a/tests/baselines/reference/exportObjectRest(module=system,target=es5).js b/tests/baselines/reference/exportObjectRest(module=system,target=es5).js new file mode 100644 index 00000000000..0d833ee8a68 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=system,target=es5).js @@ -0,0 +1,15 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var _a, x, rest; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + exports_1("x", x = (_a = { x: 'x', y: 'y' }, _a).x), exports_1("rest", rest = __rest(_a, ["x"])); + } + }; +}); diff --git a/tests/baselines/reference/exportObjectRest(module=system,target=esnext).js b/tests/baselines/reference/exportObjectRest(module=system,target=esnext).js new file mode 100644 index 00000000000..81a45acaec4 --- /dev/null +++ b/tests/baselines/reference/exportObjectRest(module=system,target=esnext).js @@ -0,0 +1,15 @@ +//// [exportObjectRest.ts] +export const { x, ...rest } = { x: 'x', y: 'y' }; + +//// [exportObjectRest.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var _a, x, rest; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + _a = { x: 'x', y: 'y' }, exports_1("x", x = _a.x), exports_1("rest", rest = __rest(_a, ["x"])); + } + }; +}); diff --git a/tests/baselines/reference/exportsAndImports1-amd.errors.txt b/tests/baselines/reference/exportsAndImports1-amd.errors.txt new file mode 100644 index 00000000000..713f464a608 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports1-amd.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. +tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + + +==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== + var v = 1; + function f() { } + class C { + } + interface I { + } + enum E { + A, B, C + } + const enum D { + A, B, C + } + module M { + export var x; + } + module N { + export interface I { + } + } + type T = number; + import a = M.x; + + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export { v, f, C, I, E, D, M, N, T, a } from "./t1"; + +==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== + import { v, f, C, I, E, D, M, N, T, a } from "./t1"; + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports1-es6.errors.txt b/tests/baselines/reference/exportsAndImports1-es6.errors.txt new file mode 100644 index 00000000000..713f464a608 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports1-es6.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. +tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + + +==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== + var v = 1; + function f() { } + class C { + } + interface I { + } + enum E { + A, B, C + } + const enum D { + A, B, C + } + module M { + export var x; + } + module N { + export interface I { + } + } + type T = number; + import a = M.x; + + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export { v, f, C, I, E, D, M, N, T, a } from "./t1"; + +==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== + import { v, f, C, I, E, D, M, N, T, a } from "./t1"; + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports1.errors.txt b/tests/baselines/reference/exportsAndImports1.errors.txt new file mode 100644 index 00000000000..713f464a608 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports1.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. +tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + + +==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== + var v = 1; + function f() { } + class C { + } + interface I { + } + enum E { + A, B, C + } + const enum D { + A, B, C + } + module M { + export var x; + } + module N { + export interface I { + } + } + type T = number; + import a = M.x; + + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export { v, f, C, I, E, D, M, N, T, a } from "./t1"; + +==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== + import { v, f, C, I, E, D, M, N, T, a } from "./t1"; + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports3-amd.errors.txt b/tests/baselines/reference/exportsAndImports3-amd.errors.txt new file mode 100644 index 00000000000..b084c1193f4 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports3-amd.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. +tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + + +==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== + export var v = 1; + export function f() { } + export class C { + } + export interface I { + } + export enum E { + A, B, C + } + export const enum D { + A, B, C + } + export module M { + export var x; + } + export module N { + export interface I { + } + } + export type T = number; + export import a = M.x; + + export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + +==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== + import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports3-es6.errors.txt b/tests/baselines/reference/exportsAndImports3-es6.errors.txt new file mode 100644 index 00000000000..b084c1193f4 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports3-es6.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. +tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + + +==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== + export var v = 1; + export function f() { } + export class C { + } + export interface I { + } + export enum E { + A, B, C + } + export const enum D { + A, B, C + } + export module M { + export var x; + } + export module N { + export interface I { + } + } + export type T = number; + export import a = M.x; + + export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + +==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== + import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + \ No newline at end of file diff --git a/tests/baselines/reference/exportsAndImports3.errors.txt b/tests/baselines/reference/exportsAndImports3.errors.txt new file mode 100644 index 00000000000..b084c1193f4 --- /dev/null +++ b/tests/baselines/reference/exportsAndImports3.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. +tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + + +==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ==== + export var v = 1; + export function f() { } + export class C { + } + export interface I { + } + export enum E { + A, B, C + } + export const enum D { + A, B, C + } + export module M { + export var x; + } + export module N { + export interface I { + } + } + export type T = number; + export import a = M.x; + + export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + +==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ==== + export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + +==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ==== + import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1"; + export { v, f, C, I, E, D, M, N, T, a }; + ~ +!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. + \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck28.types b/tests/baselines/reference/generatorTypeCheck28.types index 6921c946a39..abd66af518e 100644 --- a/tests/baselines/reference/generatorTypeCheck28.types +++ b/tests/baselines/reference/generatorTypeCheck28.types @@ -5,10 +5,10 @@ function* g(): IterableIterator<(x: string) => number> { yield * { >yield * { *[Symbol.iterator]() { yield x => x.length; } } : void ->{ *[Symbol.iterator]() { yield x => x.length; } } : { [Symbol.iterator](): Generator<(x: string) => number, void, unknown>; } +>{ *[Symbol.iterator]() { yield x => x.length; } } : { [Symbol.iterator](): Generator<(x: string) => number, void, undefined>; } *[Symbol.iterator]() { ->[Symbol.iterator] : () => Generator<(x: string) => number, void, unknown> +>[Symbol.iterator] : () => Generator<(x: string) => number, void, undefined> >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol diff --git a/tests/baselines/reference/generatorTypeCheck45.types b/tests/baselines/reference/generatorTypeCheck45.types index 18d3e9a5fc2..f8f88191e56 100644 --- a/tests/baselines/reference/generatorTypeCheck45.types +++ b/tests/baselines/reference/generatorTypeCheck45.types @@ -11,7 +11,7 @@ foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, sh >foo("", function* () { yield x => x.length }, p => undefined) : string >foo : (x: T, fun: () => Iterator<(x: T) => U, any, undefined>, fun2: (y: U) => T) => T >"" : "" ->function* () { yield x => x.length } : () => Generator<(x: string) => number, void, unknown> +>function* () { yield x => x.length } : () => Generator<(x: string) => number, void, undefined> >yield x => x.length : undefined >x => x.length : (x: string) => number >x : string diff --git a/tests/baselines/reference/generatorTypeCheck46.types b/tests/baselines/reference/generatorTypeCheck46.types index 283188193b7..3beb73892ce 100644 --- a/tests/baselines/reference/generatorTypeCheck46.types +++ b/tests/baselines/reference/generatorTypeCheck46.types @@ -11,14 +11,14 @@ foo("", function* () { >foo("", function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }}, p => undefined) : string >foo : (x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T) => T >"" : "" ->function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => Generator<(x: string) => number, void, unknown> +>function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => Generator<(x: string) => number, void, undefined> yield* { >yield* { *[Symbol.iterator]() { yield x => x.length } } : void ->{ *[Symbol.iterator]() { yield x => x.length } } : { [Symbol.iterator](): Generator<(x: string) => number, void, unknown>; } +>{ *[Symbol.iterator]() { yield x => x.length } } : { [Symbol.iterator](): Generator<(x: string) => number, void, undefined>; } *[Symbol.iterator]() { ->[Symbol.iterator] : () => Generator<(x: string) => number, void, unknown> +>[Symbol.iterator] : () => Generator<(x: string) => number, void, undefined> >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol diff --git a/tests/baselines/reference/generatorTypeCheck62.types b/tests/baselines/reference/generatorTypeCheck62.types index ed957295c31..52eb65fbb63 100644 --- a/tests/baselines/reference/generatorTypeCheck62.types +++ b/tests/baselines/reference/generatorTypeCheck62.types @@ -12,7 +12,7 @@ export function strategy(stratName: string, gen: (a: T >a : T return function*(state) { ->function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator +>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator >state : T for (const next of gen(state)) { @@ -53,7 +53,7 @@ export const Nothing1: Strategy = strategy("Nothing", function*(state: St >strategy("Nothing", function*(state: State) { return state;}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function*(state: State) { return state;} : (state: State) => Generator +>function*(state: State) { return state;} : (state: State) => Generator >state : State return state; @@ -66,7 +66,7 @@ export const Nothing2: Strategy = strategy("Nothing", function*(state: St >strategy("Nothing", function*(state: State) { yield state;}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function*(state: State) { yield state;} : (state: State) => Generator +>function*(state: State) { yield state;} : (state: State) => Generator >state : State yield state; @@ -80,7 +80,7 @@ export const Nothing3: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) { yield ; return state;}) : (a: any) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { yield ; return state;} : (state: State) => Generator +>function* (state: State) { yield ; return state;} : (state: State) => Generator >state : State yield ; diff --git a/tests/baselines/reference/generatorTypeCheck63.errors.txt b/tests/baselines/reference/generatorTypeCheck63.errors.txt index f77488edc4d..60dfb089822 100644 --- a/tests/baselines/reference/generatorTypeCheck63.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck63.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. - Type 'Generator' is not assignable to type 'IterableIterator'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. + Type 'Generator' is not assignable to type 'IterableIterator'. Types of property 'next' are incompatible. - Type '(...args: [] | [unknown]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. + Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. Type 'IteratorResult' is not assignable to type 'IteratorResult'. Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. @@ -34,10 +34,10 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): err export const Nothing: Strategy = strategy("Nothing", function* (state: State) { ~~~~~~~~ -!!! error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. -!!! error TS2345: Type 'Generator' is not assignable to type 'IterableIterator'. +!!! error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. +!!! error TS2345: Type 'Generator' is not assignable to type 'IterableIterator'. !!! error TS2345: Types of property 'next' are incompatible. -!!! error TS2345: Type '(...args: [] | [unknown]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. +!!! error TS2345: Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. !!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. !!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. !!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. diff --git a/tests/baselines/reference/generatorTypeCheck63.types b/tests/baselines/reference/generatorTypeCheck63.types index 64d67083e61..12d78bac5df 100644 --- a/tests/baselines/reference/generatorTypeCheck63.types +++ b/tests/baselines/reference/generatorTypeCheck63.types @@ -12,7 +12,7 @@ export function strategy(stratName: string, gen: (a: T >a : T return function*(state) { ->function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator +>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator >state : T for (const next of gen(state)) { @@ -53,7 +53,7 @@ export const Nothing: Strategy = strategy("Nothing", function* (state: St >strategy("Nothing", function* (state: State) { yield 1; return state;}) : any >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { yield 1; return state;} : (state: State) => Generator +>function* (state: State) { yield 1; return state;} : (state: State) => Generator >state : State yield 1; @@ -70,7 +70,7 @@ export const Nothing1: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) {}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) {} : (state: State) => Generator +>function* (state: State) {} : (state: State) => Generator >state : State }); @@ -80,7 +80,7 @@ export const Nothing2: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) { return 1;}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { return 1;} : (state: State) => Generator +>function* (state: State) { return 1;} : (state: State) => Generator >state : State return 1; @@ -93,7 +93,7 @@ export const Nothing3: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) { yield state; return 1;}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { yield state; return 1;} : (state: State) => Generator +>function* (state: State) { yield state; return 1;} : (state: State) => Generator >state : State yield state; diff --git a/tests/baselines/reference/generatorYieldContextualType.types b/tests/baselines/reference/generatorYieldContextualType.types index 5caccffa933..a90bbd040a1 100644 --- a/tests/baselines/reference/generatorYieldContextualType.types +++ b/tests/baselines/reference/generatorYieldContextualType.types @@ -6,7 +6,7 @@ declare function f1(gen: () => Generator): void; f1<0, 0, 1>(function* () { >f1<0, 0, 1>(function* () { const a = yield 0; return 0;}) : void >f1 : (gen: () => Generator) => void ->function* () { const a = yield 0; return 0;} : () => Generator<0, 0, unknown> +>function* () { const a = yield 0; return 0;} : () => Generator<0, 0, 1> const a = yield 0; >a : 1 @@ -25,7 +25,7 @@ declare function f2(gen: () => Generator | AsyncGenerator(async function* () { >f2<0, 0, 1>(async function* () { const a = yield 0; return 0;}) : void >f2 : (gen: () => Generator | AsyncGenerator) => void ->async function* () { const a = yield 0; return 0;} : () => AsyncGenerator<0, 0, unknown> +>async function* () { const a = yield 0; return 0;} : () => AsyncGenerator<0, 0, 1> const a = yield 0; >a : 1 diff --git a/tests/baselines/reference/showConfig/Show TSConfig with compileOnSave and more/tsconfig.json b/tests/baselines/reference/showConfig/Show TSConfig with compileOnSave and more/tsconfig.json new file mode 100644 index 00000000000..373e81d1f75 --- /dev/null +++ b/tests/baselines/reference/showConfig/Show TSConfig with compileOnSave and more/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "target": "es5", + "module": "commonjs", + "strict": true + }, + "references": [ + { + "path": "./test" + } + ], + "include": [ + "src/*" + ], + "exclude": [ + "dist" + ], + "compileOnSave": true +} diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.1.types b/tests/baselines/reference/types.asyncGenerators.es2018.1.types index 24da9312c15..54db9b890ec 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.1.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.1.types @@ -75,7 +75,7 @@ async function * inferReturnType8() { } const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator ->async function * () { yield 1;} : () => AsyncGenerator +>async function * () { yield 1;} : () => AsyncGenerator yield 1; >yield 1 : undefined @@ -84,7 +84,7 @@ const assignability1: () => AsyncIterableIterator = async function * () }; const assignability2: () => AsyncIterableIterator = async function * () { >assignability2 : () => AsyncIterableIterator ->async function * () { yield Promise.resolve(1);} : () => AsyncGenerator +>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); >yield Promise.resolve(1) : undefined @@ -135,7 +135,7 @@ const assignability5: () => AsyncIterableIterator = async function * () }; const assignability6: () => AsyncIterable = async function * () { >assignability6 : () => AsyncIterable ->async function * () { yield 1;} : () => AsyncGenerator +>async function * () { yield 1;} : () => AsyncGenerator yield 1; >yield 1 : undefined @@ -144,7 +144,7 @@ const assignability6: () => AsyncIterable = async function * () { }; const assignability7: () => AsyncIterable = async function * () { >assignability7 : () => AsyncIterable ->async function * () { yield Promise.resolve(1);} : () => AsyncGenerator +>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); >yield Promise.resolve(1) : undefined @@ -195,7 +195,7 @@ const assignability10: () => AsyncIterable = async function * () { }; const assignability11: () => AsyncIterator = async function * () { >assignability11 : () => AsyncIterator ->async function * () { yield 1;} : () => AsyncGenerator +>async function * () { yield 1;} : () => AsyncGenerator yield 1; >yield 1 : undefined @@ -204,7 +204,7 @@ const assignability11: () => AsyncIterator = async function * () { }; const assignability12: () => AsyncIterator = async function * () { >assignability12 : () => AsyncIterator ->async function * () { yield Promise.resolve(1);} : () => AsyncGenerator +>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); >yield Promise.resolve(1) : undefined diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt index 1ca77aebc86..d7ec011bced 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(2,12): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(8,12): error TS2504: Type 'Promise' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. - Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. Types of property 'next' are incompatible. - Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. + Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. Type 'Promise>' is not assignable to type 'Promise>'. Type 'IteratorResult' is not assignable to type 'IteratorResult'. Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. @@ -11,20 +11,12 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(13,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. - Type 'Promise>' is not assignable to type 'Promise>'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(16,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. - Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. - Types of property '[Symbol.asyncIterator]' are incompatible. - Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. - Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. - Type 'Promise>' is not assignable to type 'Promise>'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. + Types of property 'next' are incompatible. + Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. + Type 'Promise>' is not assignable to type 'Promise>'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. Types of property '[Symbol.asyncIterator]' are incompatible. Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. @@ -32,10 +24,18 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( Types of property 'next' are incompatible. Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. Type 'Promise>' is not assignable to type 'Promise>'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(25,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. - Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. + Types of property '[Symbol.asyncIterator]' are incompatible. + Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. + Types of property 'next' are incompatible. + Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. + Type 'Promise>' is not assignable to type 'Promise>'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(31,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(34,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. @@ -76,10 +76,10 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( } const assignability1: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. +!!! error TS2322: Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. !!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. !!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. !!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. @@ -91,31 +91,19 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. -!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. yield* ["a", "b"]; }; const assignability3: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. +!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. yield* (async function * () { yield "a"; })(); }; const assignability4: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. -!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. -!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. -!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. - yield "a"; - }; - const assignability5: () => AsyncIterable = async function * () { - ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. !!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. @@ -124,18 +112,30 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( !!! error TS2322: Types of property 'next' are incompatible. !!! error TS2322: Type '(...args: [] | [PromiseLike]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. !!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. + yield "a"; + }; + const assignability5: () => AsyncIterable = async function * () { + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. yield* ["a", "b"]; }; const assignability6: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. !!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. +!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '(...args: [] | [unknown]) => Promise>' is not assignable to type '(...args: [] | [PromiseLike]) => Promise>'. +!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. yield* (async function * () { yield "a"; })(); }; const assignability7: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. yield "a"; }; const assignability8: () => AsyncIterator = async function * () { diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.types b/tests/baselines/reference/types.asyncGenerators.es2018.2.types index 022ddd297a2..83524871199 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.types @@ -29,7 +29,7 @@ async function * inferReturnType3() { } const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator ->async function * () { yield "a";} : () => AsyncGenerator +>async function * () { yield "a";} : () => AsyncGenerator yield "a"; >yield "a" : undefined @@ -62,7 +62,7 @@ const assignability3: () => AsyncIterableIterator = async function * () }; const assignability4: () => AsyncIterable = async function * () { >assignability4 : () => AsyncIterable ->async function * () { yield "a";} : () => AsyncGenerator +>async function * () { yield "a";} : () => AsyncGenerator yield "a"; >yield "a" : undefined @@ -95,7 +95,7 @@ const assignability6: () => AsyncIterable = async function * () { }; const assignability7: () => AsyncIterator = async function * () { >assignability7 : () => AsyncIterator ->async function * () { yield "a";} : () => AsyncGenerator +>async function * () { yield "a";} : () => AsyncGenerator yield "a"; >yield "a" : undefined diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index 02ededf7b1f..a321593c11a 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -819,7 +819,7 @@ interface Context { const o3: Context = { >o3 : Context ->{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: unique symbol): unique symbol; } +>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: unique symbol): unique symbol; } method1() { >method1 : () => unique symbol @@ -836,7 +836,7 @@ const o3: Context = { }, async * method3() { ->method3 : () => AsyncGenerator +>method3 : () => AsyncGenerator yield s; // yield type should not widen due to contextual type >yield s : undefined @@ -844,7 +844,7 @@ const o3: Context = { }, * method4() { ->method4 : () => Generator +>method4 : () => Generator yield s; // yield type should not widen due to contextual type >yield s : undefined diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.types b/tests/baselines/reference/uniqueSymbolsDeclarations.types index db198153153..bacdafc5680 100644 --- a/tests/baselines/reference/uniqueSymbolsDeclarations.types +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.types @@ -812,7 +812,7 @@ interface Context { const o4: Context = { >o4 : Context ->{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: unique symbol): unique symbol; } +>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: unique symbol): unique symbol; } method1() { >method1 : () => unique symbol @@ -829,7 +829,7 @@ const o4: Context = { }, async * method3() { ->method3 : () => AsyncGenerator +>method3 : () => AsyncGenerator yield s; // yield type should not widen due to contextual type >yield s : undefined @@ -837,7 +837,7 @@ const o4: Context = { }, * method4() { ->method4 : () => Generator +>method4 : () => Generator yield s; // yield type should not widen due to contextual type >yield s : undefined diff --git a/tests/cases/compiler/amdModuleConstEnumUsage.ts b/tests/cases/compiler/amdModuleConstEnumUsage.ts new file mode 100644 index 00000000000..6778aee0cdd --- /dev/null +++ b/tests/cases/compiler/amdModuleConstEnumUsage.ts @@ -0,0 +1,16 @@ +// @module: amd +// @preserveConstEnums: true +// @baseUrl: /proj +// @filename: /proj/defs/cc.ts +export const enum CharCode { + A, + B +} +// @filename: /proj/component/file.ts + +import { CharCode } from 'defs/cc'; +export class User { + method(input: number) { + if (CharCode.A === input) {} + } +} diff --git a/tests/cases/compiler/constEnumNoPreserveDeclarationReexport.ts b/tests/cases/compiler/constEnumNoPreserveDeclarationReexport.ts new file mode 100644 index 00000000000..293aade8d57 --- /dev/null +++ b/tests/cases/compiler/constEnumNoPreserveDeclarationReexport.ts @@ -0,0 +1,18 @@ +// @filename: ConstEnum.d.ts +export const enum MyConstEnum { + Foo, + Bar +} +// @filename: ImportExport.d.ts +import { MyConstEnum } from './ConstEnum'; +export default MyConstEnum; +// @filename: ReExport.d.ts +export { MyConstEnum as default } from './ConstEnum'; +// @filename: usages.ts +import {MyConstEnum} from "./ConstEnum"; +import AlsoEnum from "./ImportExport"; +import StillEnum from "./ReExport"; + +MyConstEnum.Foo; +AlsoEnum.Foo; +StillEnum.Foo; diff --git a/tests/cases/compiler/constEnumPreserveEmitReexport.ts b/tests/cases/compiler/constEnumPreserveEmitReexport.ts new file mode 100644 index 00000000000..d53345e6380 --- /dev/null +++ b/tests/cases/compiler/constEnumPreserveEmitReexport.ts @@ -0,0 +1,11 @@ +// @preserveConstEnums: true +// @filename: ConstEnum.ts +export const enum MyConstEnum { + Foo, + Bar +}; +// @filename: ImportExport.ts +import { MyConstEnum } from './ConstEnum'; +export default MyConstEnum; +// @filename: ReExport.ts +export { MyConstEnum as default } from './ConstEnum'; \ No newline at end of file diff --git a/tests/cases/compiler/exportEmptyArrayBindingPattern.ts b/tests/cases/compiler/exportEmptyArrayBindingPattern.ts new file mode 100644 index 00000000000..b12beac7c59 --- /dev/null +++ b/tests/cases/compiler/exportEmptyArrayBindingPattern.ts @@ -0,0 +1,5 @@ +// @module: commonjs,amd,system,es2015,esnext +// @target: esnext,es5 +// @noEmitHelpers: true +// @noTypesAndSymbols: true +export const [] = []; \ No newline at end of file diff --git a/tests/cases/compiler/exportEmptyObjectBindingPattern.ts b/tests/cases/compiler/exportEmptyObjectBindingPattern.ts new file mode 100644 index 00000000000..6db95fb094b --- /dev/null +++ b/tests/cases/compiler/exportEmptyObjectBindingPattern.ts @@ -0,0 +1,5 @@ +// @module: commonjs,amd,system,es2015,esnext +// @target: esnext,es5 +// @noEmitHelpers: true +// @noTypesAndSymbols: true +export const {} = {}; \ No newline at end of file diff --git a/tests/cases/compiler/exportObjectRest.ts b/tests/cases/compiler/exportObjectRest.ts new file mode 100644 index 00000000000..cbc314a7e11 --- /dev/null +++ b/tests/cases/compiler/exportObjectRest.ts @@ -0,0 +1,5 @@ +// @module: commonjs,amd,system,es2015,esnext +// @target: esnext,es5 +// @noEmitHelpers: true +// @noTypesAndSymbols: true +export const { x, ...rest } = { x: 'x', y: 'y' }; \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_templateLiteral.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_templateLiteral.ts new file mode 100644 index 00000000000..1075fb7dddb --- /dev/null +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_templateLiteral.ts @@ -0,0 +1,16 @@ +/// + +////function /*a*/insert/*b*/(template: string, overwriteBefore = 0) {} +////insert(`this is \${not} a substitution`); + + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", + newContent: [ + 'function insert({ template, overwriteBefore = 0 }: { template: string; overwriteBefore?: number; }) {}', + 'insert({ template: `this is \\${not} a substitution` });' + ].join('\n') +});