Skip to content

Commit d178ea4

Browse files
committed
Merge branch 'main' into fix21732
# Conflicts: # src/compiler/checker.ts
2 parents 335d7c8 + 3c3820b commit d178ea4

File tree

451 files changed

+15662
-14699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

451 files changed

+15662
-14699
lines changed

.eslintignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@
33
/tests/**
44
/lib/**
55
/src/lib/*.generated.d.ts
6+
# Ignore all compiled script outputs
67
/scripts/*.js
8+
# But, not the ones that are hand-written.
9+
# TODO: remove once scripts are pure JS
10+
!/scripts/browserIntegrationTest.js
11+
!/scripts/createPlaygroundBuild.js
12+
!/scripts/failed-tests.js
13+
!/scripts/find-unused-diagnostic-messages.js
14+
!/scripts/lint-hooks.js
15+
!/scripts/perf-result-post.js
16+
!/scripts/post-vsts-artifact-comment.js
17+
!/scripts/regenerate-unicode-identifier-parts.js
18+
!/scripts/run-sequence.js
19+
!/scripts/update-experimental-branches.js
720
/scripts/eslint/built/**
821
/internal/**
922
/coverage/**

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//
2323
// ESLint in VS Code will lint any opened file (so long as it's not eslintignore'd), so
2424
// that will work regardless of the below.
25-
{ "files": ["*.ts"] }
25+
{ "files": ["*.ts", "*.mts", "*.cts", "*.mjs", "*.cjs"] }
2626
],
2727
"rules": {
2828
"@typescript-eslint/adjacent-overload-signatures": "error",

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- run: npm ci
4747

4848
- name: Linter
49-
run: npm run lint:ci
49+
run: npm run lint
5050

5151
browser-integration:
5252
runs-on: ubuntu-latest

Gulpfile.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ const lint = eslint(".");
372372
lint.displayName = "lint";
373373
task("lint", lint);
374374
task("lint").description = "Runs eslint on the compiler and scripts sources.";
375-
task("lint").flags = {
376-
" --ci": "Runs eslint additional rules",
377-
};
378375

379376
const buildCancellationToken = () => buildProject("src/cancellationToken");
380377
const cleanCancellationToken = () => cleanProject("src/cancellationToken");

package-lock.json

Lines changed: 110 additions & 221 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
"mocha-fivemat-progress-reporter": "latest",
9191
"ms": "^2.1.3",
9292
"node-fetch": "^2.6.7",
93-
"prex": "^0.4.7",
9493
"source-map-support": "latest",
9594
"typescript": "^4.8.2",
9695
"vinyl": "latest",
@@ -110,7 +109,6 @@
110109
"clean": "gulp clean",
111110
"gulp": "gulp",
112111
"lint": "gulp lint",
113-
"lint:ci": "gulp lint --ci",
114112
"setup-hooks": "node scripts/link-hooks.js"
115113
},
116114
"browser": {

scripts/build/options.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
const minimist = require("minimist");
33
const os = require("os");
44

5+
const ci = ["1", "true"].includes(process.env.CI);
6+
57
/** @type {CommandLineOptions} */
68
module.exports = minimist(process.argv.slice(2), {
7-
boolean: ["dirty", "light", "colors", "lint", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built"],
9+
boolean: ["dirty", "light", "colors", "lint", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci"],
810
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
911
alias: {
1012
/* eslint-disable quote-props */
@@ -33,12 +35,13 @@ module.exports = minimist(process.argv.slice(2), {
3335
reporter: process.env.reporter || process.env.r,
3436
lint: process.env.lint || true,
3537
fix: process.env.fix || process.env.f,
36-
workers: process.env.workerCount || ((os.cpus().length - (process.env.CI ? 0 : 1)) || 1),
38+
workers: process.env.workerCount || ((os.cpus().length - (ci ? 0 : 1)) || 1),
3739
failed: false,
3840
keepFailed: false,
3941
lkg: true,
4042
dirty: false,
41-
built: false
43+
built: false,
44+
ci,
4245
}
4346
});
4447

@@ -67,6 +70,7 @@ if (module.exports.built) {
6770
* @property {string|number} timeout
6871
* @property {boolean} failed
6972
* @property {boolean} keepFailed
73+
* @property {boolean} ci
7074
*
7175
* @typedef {import("minimist").ParsedArgs & TypedOptions} CommandLineOptions
7276
*/

scripts/build/tests.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const path = require("path");
66
const mkdirP = require("mkdirp");
77
const log = require("fancy-log");
88
const cmdLineOptions = require("./options");
9-
const { CancellationToken } = require("prex");
109
const { exec } = require("./utils");
1110
const { findUpFile } = require("./findUpDir");
1211

@@ -22,9 +21,8 @@ exports.localTest262Baseline = "internal/baselines/test262/local";
2221
* @param {string} defaultReporter
2322
* @param {boolean} runInParallel
2423
* @param {boolean} watchMode
25-
* @param {import("prex").CancellationToken} [cancelToken]
2624
*/
27-
async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, cancelToken = CancellationToken.none) {
25+
async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode) {
2826
let testTimeout = cmdLineOptions.timeout;
2927
const tests = cmdLineOptions.tests;
3028
const inspect = cmdLineOptions.break || cmdLineOptions.inspect;
@@ -38,7 +36,6 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
3836
const shardId = +cmdLineOptions.shardId || undefined;
3937
if (!cmdLineOptions.dirty) {
4038
await cleanTestDirs();
41-
cancelToken.throwIfCancellationRequested();
4239
}
4340

4441
if (fs.existsSync(testConfigFile)) {
@@ -121,19 +118,17 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
121118

122119
try {
123120
setNodeEnvToDevelopment();
124-
const { exitCode } = await exec(process.execPath, args, {
125-
cancelToken,
126-
});
121+
const { exitCode } = await exec(process.execPath, args);
127122
if (exitCode !== 0) {
128123
errorStatus = exitCode;
129124
error = new Error(`Process exited with status code ${errorStatus}.`);
130125
}
131-
else if (process.env.CI === "true") {
126+
else if (cmdLineOptions.ci) {
132127
// finally, do a sanity check and build the compiler with the built version of itself
133128
log.info("Starting sanity check build...");
134129
// Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them)
135-
await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"], { cancelToken });
136-
const { exitCode } = await exec("gulp", ["local", "--lkg=false"], { cancelToken });
130+
await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"]);
131+
const { exitCode } = await exec("gulp", ["local", "--lkg=false"]);
137132
if (exitCode !== 0) {
138133
errorStatus = exitCode;
139134
error = new Error(`Sanity check build process exited with status code ${errorStatus}.`);

scripts/build/utils.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const ts = require("../../lib/typescript");
1414
const chalk = require("chalk");
1515
const which = require("which");
1616
const { spawn } = require("child_process");
17-
const { CancellationToken, CancelError, Deferred } = require("prex");
1817
const { Readable, Duplex } = require("stream");
1918

2019
/**
@@ -25,26 +24,17 @@ const { Readable, Duplex } = require("stream");
2524
*
2625
* @typedef ExecOptions
2726
* @property {boolean} [ignoreExitCode]
28-
* @property {import("prex").CancellationToken} [cancelToken]
2927
* @property {boolean} [hidePrompt]
3028
* @property {boolean} [waitForExit=true]
3129
*/
3230
async function exec(cmd, args, options = {}) {
3331
return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => {
34-
const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options;
35-
cancelToken.throwIfCancellationRequested();
32+
const { ignoreExitCode, waitForExit = true } = options;
3633

3734
if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
3835
const proc = spawn(which.sync(cmd), args, { stdio: waitForExit ? "inherit" : "ignore" });
39-
const registration = cancelToken.register(() => {
40-
log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`);
41-
proc.kill("SIGINT");
42-
proc.kill("SIGTERM");
43-
reject(new CancelError());
44-
});
4536
if (waitForExit) {
4637
proc.on("exit", exitCode => {
47-
registration.unregister();
4838
if (exitCode === 0 || ignoreExitCode) {
4939
resolve({ exitCode });
5040
}
@@ -53,7 +43,6 @@ async function exec(cmd, args, options = {}) {
5343
}
5444
});
5545
proc.on("error", error => {
56-
registration.unregister();
5746
reject(error);
5847
});
5948
}
@@ -395,6 +384,15 @@ function rm(dest, opts) {
395384
}
396385
exports.rm = rm;
397386

387+
class Deferred {
388+
constructor() {
389+
this.promise = new Promise((resolve, reject) => {
390+
this.resolve = resolve;
391+
this.reject = reject;
392+
});
393+
}
394+
}
395+
398396
class Debouncer {
399397
/**
400398
* @param {number} timeout

scripts/failed-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
4545
}
4646
}
4747

48-
const newOptions = Object.assign({}, options, { reporterOptions: reporterOptions.reporterOptions || {} });
48+
const newOptions = { ...options, reporterOptions: reporterOptions.reporterOptions || {} };
4949
if (reporterOptions.reporter === "xunit") {
5050
newOptions.reporterOptions.output = "TEST-results.xml";
5151
}
@@ -142,4 +142,4 @@ class FailedTestsReporter extends Mocha.reporters.Base {
142142
}
143143
}
144144

145-
module.exports = FailedTestsReporter;
145+
module.exports = FailedTestsReporter;

scripts/find-unused-diganostic-messages.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ startOfDiags.split(EOL).forEach(line => {
1717
try {
1818
execSync(`grep -rnw 'src' -e 'Diagnostics.${diagName}'`).toString();
1919
process.stdout.write(".");
20-
} catch (error) {
20+
}
21+
catch (error) {
2122
missingNames.push(diagName);
2223
process.stdout.write("x");
2324
}

scripts/post-vsts-artifact-comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ and then running \`npm install\`.
4848

4949
// Temporarily disable until we get access controls set up right
5050
// Send a ping to https://github.com/microsoft/typescript-make-monaco-builds#pull-request-builds
51-
await gh.request("POST /repos/microsoft/typescript-make-monaco-builds/dispatches", { event_type: process.env.SOURCE_ISSUE, headers: { Accept: "application/vnd.github.everest-preview+json" }});
51+
await gh.request("POST /repos/microsoft/typescript-make-monaco-builds/dispatches", { event_type: process.env.SOURCE_ISSUE, headers: { Accept: "application/vnd.github.everest-preview+json" } });
5252
}
5353

5454
main().catch(async e => {

scripts/run-sequence.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @ts-check
22
const cp = require("child_process");
33
/**
4-
*
54
* @param {[string, string[]][]} tasks
65
* @param {cp.SpawnSyncOptions} opts
76
*/
@@ -17,4 +16,4 @@ function runSequence(tasks, opts = { timeout: 100000, shell: true }) {
1716
return lastResult && lastResult.stdout && lastResult.stdout.toString();
1817
}
1918

20-
exports.runSequence = runSequence;
19+
exports.runSequence = runSequence;

scripts/update-experimental-branches.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const triggeredPR = process.env.SOURCE_ISSUE || process.env.SYSTEM_PULLREQUEST_P
1010
* This program should be invoked as `node ./scripts/update-experimental-branches <GithubAccessToken>`
1111
* TODO: the following is racey - if two experiment-enlisted PRs trigger simultaneously and witness one another in an unupdated state, they'll both produce
1212
* a new experimental branch, but each will be missing a change from the other. There's no _great_ way to fix this beyond setting the maximum concurrency
13-
* of this task to 1 (so only one job is allowed to update experiments at a time).
13+
* of this task to 1 (so only one job is allowed to update experiments at a time).
1414
*/
1515
async function main() {
1616
const gh = new Octokit({

src/compiler/checker.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25101,7 +25101,7 @@ namespace ts {
2510125101
const narrowedPropType = narrowType(propType);
2510225102
return filterType(type, t => {
2510325103
const discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
25104-
return !(narrowedPropType.flags & TypeFlags.Never) && isTypeComparableTo(narrowedPropType, discriminantType);
25104+
return !(narrowedPropType.flags & TypeFlags.Never) && areTypesComparable(narrowedPropType, discriminantType);
2510525105
});
2510625106
}
2510725107

@@ -25301,14 +25301,19 @@ namespace ts {
2530125301
assumeTrue = !assumeTrue;
2530225302
}
2530325303
const valueType = getTypeOfExpression(value);
25304-
if ((type.flags & TypeFlags.Unknown) && assumeTrue && (operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken)) {
25304+
if (((type.flags & TypeFlags.Unknown) || isEmptyAnonymousObjectType(type) && !(valueType.flags & TypeFlags.Nullable)) &&
25305+
assumeTrue &&
25306+
(operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken)
25307+
) {
2530525308
if (valueType.flags & (TypeFlags.Primitive | TypeFlags.NonPrimitive)) {
2530625309
return valueType;
2530725310
}
2530825311
if (valueType.flags & TypeFlags.Object) {
2530925312
return nonPrimitiveType;
2531025313
}
25311-
return type;
25314+
if (type.flags & TypeFlags.Unknown) {
25315+
return type;
25316+
}
2531225317
}
2531325318
if (valueType.flags & TypeFlags.Nullable) {
2531425319
if (!strictNullChecks) {
@@ -28388,6 +28393,7 @@ namespace ts {
2838828393
*/
2838928394
function createJsxAttributesTypeFromAttributesProperty(openingLikeElement: JsxOpeningLikeElement, checkMode: CheckMode | undefined) {
2839028395
const attributes = openingLikeElement.attributes;
28396+
const attributesType = getContextualType(attributes, ContextFlags.None);
2839128397
const allAttributesTable = strictNullChecks ? createSymbolTable() : undefined;
2839228398
let attributesTable = createSymbolTable();
2839328399
let spread: Type = emptyJsxObjectType;
@@ -28416,6 +28422,12 @@ namespace ts {
2841628422
if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
2841728423
explicitlySpecifyChildrenAttribute = true;
2841828424
}
28425+
if (attributesType) {
28426+
const prop = getPropertyOfType(attributesType, member.escapedName);
28427+
if (prop && prop.declarations && isDeprecatedSymbol(prop)) {
28428+
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string);
28429+
}
28430+
}
2841928431
}
2842028432
else {
2842128433
Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute);

src/compiler/program.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,11 +3535,12 @@ namespace ts {
35353535
createDiagnosticForOptionName(Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules");
35363536
}
35373537

3538-
const firstNonExternalModuleSourceFile = find(files, f => !isExternalModule(f) && !isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== ScriptKind.JSON);
3539-
if (firstNonExternalModuleSourceFile) {
3540-
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
3541-
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length,
3542-
Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, getBaseFileName(firstNonExternalModuleSourceFile.fileName)));
3538+
for (const file of files) {
3539+
if (!isExternalModule(file) && !isSourceFileJS(file) && !file.isDeclarationFile && file.scriptKind !== ScriptKind.JSON) {
3540+
const span = getErrorSpanForNode(file, file);
3541+
programDiagnostics.add(createFileDiagnostic(file, span.start, span.length,
3542+
Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, getBaseFileName(file.fileName)));
3543+
}
35433544
}
35443545
}
35453546
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES2015 && options.module === ModuleKind.None) {

0 commit comments

Comments
 (0)