Skip to content

Commit

Permalink
Merge branch 'main' into baselineServer
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Sep 7, 2022
2 parents e149b82 + ab831d0 commit b10b197
Show file tree
Hide file tree
Showing 22 changed files with 306 additions and 26 deletions.
13 changes: 13 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
/tests/**
/lib/**
/src/lib/*.generated.d.ts
# Ignore all compiled script outputs
/scripts/*.js
# But, not the ones that are hand-written.
# TODO: remove once scripts are pure JS
!/scripts/browserIntegrationTest.js
!/scripts/createPlaygroundBuild.js
!/scripts/failed-tests.js
!/scripts/find-unused-diagnostic-messages.js
!/scripts/lint-hooks.js
!/scripts/perf-result-post.js
!/scripts/post-vsts-artifact-comment.js
!/scripts/regenerate-unicode-identifier-parts.js
!/scripts/run-sequence.js
!/scripts/update-experimental-branches.js
/scripts/eslint/built/**
/internal/**
/coverage/**
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//
// ESLint in VS Code will lint any opened file (so long as it's not eslintignore'd), so
// that will work regardless of the below.
{ "files": ["*.ts"] }
{ "files": ["*.ts", "*.mts", "*.cts", "*.mjs", "*.cjs"] }
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- run: npm ci

- name: Linter
run: npm run lint:ci
run: npm run lint

browser-integration:
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ const lint = eslint(".");
lint.displayName = "lint";
task("lint", lint);
task("lint").description = "Runs eslint on the compiler and scripts sources.";
task("lint").flags = {
" --ci": "Runs eslint additional rules",
};

const buildCancellationToken = () => buildProject("src/cancellationToken");
const cleanCancellationToken = () => cleanProject("src/cancellationToken");
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
"clean": "gulp clean",
"gulp": "gulp",
"lint": "gulp lint",
"lint:ci": "gulp lint --ci",
"setup-hooks": "node scripts/link-hooks.js"
},
"browser": {
Expand Down
10 changes: 7 additions & 3 deletions scripts/build/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
const minimist = require("minimist");
const os = require("os");

const ci = ["1", "true"].includes(process.env.CI);

/** @type {CommandLineOptions} */
module.exports = minimist(process.argv.slice(2), {
boolean: ["dirty", "light", "colors", "lint", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built"],
boolean: ["dirty", "light", "colors", "lint", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci"],
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
alias: {
/* eslint-disable quote-props */
Expand Down Expand Up @@ -33,12 +35,13 @@ module.exports = minimist(process.argv.slice(2), {
reporter: process.env.reporter || process.env.r,
lint: process.env.lint || true,
fix: process.env.fix || process.env.f,
workers: process.env.workerCount || ((os.cpus().length - (process.env.CI ? 0 : 1)) || 1),
workers: process.env.workerCount || ((os.cpus().length - (ci ? 0 : 1)) || 1),
failed: false,
keepFailed: false,
lkg: true,
dirty: false,
built: false
built: false,
ci,
}
});

Expand Down Expand Up @@ -67,6 +70,7 @@ if (module.exports.built) {
* @property {string|number} timeout
* @property {boolean} failed
* @property {boolean} keepFailed
* @property {boolean} ci
*
* @typedef {import("minimist").ParsedArgs & TypedOptions} CommandLineOptions
*/
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode)
errorStatus = exitCode;
error = new Error(`Process exited with status code ${errorStatus}.`);
}
else if (process.env.CI === "true") {
else if (cmdLineOptions.ci) {
// finally, do a sanity check and build the compiler with the built version of itself
log.info("Starting sanity check build...");
// Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them)
Expand Down
4 changes: 2 additions & 2 deletions scripts/failed-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
}
}

const newOptions = Object.assign({}, options, { reporterOptions: reporterOptions.reporterOptions || {} });
const newOptions = { ...options, reporterOptions: reporterOptions.reporterOptions || {} };
if (reporterOptions.reporter === "xunit") {
newOptions.reporterOptions.output = "TEST-results.xml";
}
Expand Down Expand Up @@ -142,4 +142,4 @@ class FailedTestsReporter extends Mocha.reporters.Base {
}
}

module.exports = FailedTestsReporter;
module.exports = FailedTestsReporter;
3 changes: 2 additions & 1 deletion scripts/find-unused-diganostic-messages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ startOfDiags.split(EOL).forEach(line => {
try {
execSync(`grep -rnw 'src' -e 'Diagnostics.${diagName}'`).toString();
process.stdout.write(".");
} catch (error) {
}
catch (error) {
missingNames.push(diagName);
process.stdout.write("x");
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/post-vsts-artifact-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ and then running \`npm install\`.

// Temporarily disable until we get access controls set up right
// Send a ping to https://github.com/microsoft/typescript-make-monaco-builds#pull-request-builds
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" }});
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" } });
}

main().catch(async e => {
Expand Down
3 changes: 1 addition & 2 deletions scripts/run-sequence.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check
const cp = require("child_process");
/**
*
* @param {[string, string[]][]} tasks
* @param {cp.SpawnSyncOptions} opts
*/
Expand All @@ -17,4 +16,4 @@ function runSequence(tasks, opts = { timeout: 100000, shell: true }) {
return lastResult && lastResult.stdout && lastResult.stdout.toString();
}

exports.runSequence = runSequence;
exports.runSequence = runSequence;
2 changes: 1 addition & 1 deletion scripts/update-experimental-branches.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const triggeredPR = process.env.SOURCE_ISSUE || process.env.SYSTEM_PULLREQUEST_P
* This program should be invoked as `node ./scripts/update-experimental-branches <GithubAccessToken>`
* TODO: the following is racey - if two experiment-enlisted PRs trigger simultaneously and witness one another in an unupdated state, they'll both produce
* 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
* of this task to 1 (so only one job is allowed to update experiments at a time).
* of this task to 1 (so only one job is allowed to update experiments at a time).
*/
async function main() {
const gh = new Octokit({
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19821,8 +19821,8 @@ namespace ts {
const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
if (result = skipTrue ? Ternary.True : isRelatedTo(source, getTrueTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false)) {
result &= skipFalse ? Ternary.True : isRelatedTo(source, getFalseTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false);
if (result = skipTrue ? Ternary.True : isRelatedTo(source, getTrueTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
result &= skipFalse ? Ternary.True : isRelatedTo(source, getFalseTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
if (result) {
return result;
}
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ namespace ts {
shortName: "h",
type: "boolean",
showInSimplifiedHelpView: true,
isCommandLineOnly: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Print_this_message,
defaultValueDescription: false,
Expand All @@ -200,6 +201,8 @@ namespace ts {
name: "help",
shortName: "?",
type: "boolean",
isCommandLineOnly: true,
category: Diagnostics.Command_line_Options,
defaultValueDescription: false,
},
{
Expand Down
6 changes: 5 additions & 1 deletion src/testRunner/unittests/config/initializeTSConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ts {
const outputFileName = `tsConfig/${name.replace(/[^a-z0-9\-. ]/ig, "")}/tsconfig.json`;

it(`Correct output for ${outputFileName}`, () => {
Harness.Baseline.runBaseline(outputFileName, initResult);
Harness.Baseline.runBaseline(outputFileName, initResult, { PrintDiff: true });
});
});
}
Expand All @@ -29,5 +29,9 @@ namespace ts {
initTSConfigCorrectly("Initialized TSConfig with incorrect compiler option value", ["--init", "--lib", "nonExistLib,es5,es2015.promise"]);

initTSConfigCorrectly("Initialized TSConfig with advanced options", ["--init", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]);

initTSConfigCorrectly("Initialized TSConfig with --help", ["--init", "--help"]);

initTSConfigCorrectly("Initialized TSConfig with --watch", ["--init", "--watch"]);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [excessPropertyCheckingIntersectionWithConditional.ts]
type Foo<K> = K extends unknown ? { a: number } : unknown
const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => {
return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2
}

//// [excessPropertyCheckingIntersectionWithConditional.js]
var createDefaultExample = function (x) {
return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== tests/cases/compiler/excessPropertyCheckingIntersectionWithConditional.ts ===
type Foo<K> = K extends unknown ? { a: number } : unknown
>Foo : Symbol(Foo, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 0))
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 9))
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 9))
>a : Symbol(a, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 35))

const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => {
>createDefaultExample : Symbol(createDefaultExample, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 5))
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30))
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 34))
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30))
>Foo : Symbol(Foo, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 0))
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30))
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 51))
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30))

return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2
>a : Symbol(a, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 2, 10))
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 2, 16))
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 34))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
=== tests/cases/compiler/excessPropertyCheckingIntersectionWithConditional.ts ===
type Foo<K> = K extends unknown ? { a: number } : unknown
>Foo : Foo<K>
>a : number

const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => {
>createDefaultExample : <K>(x: K) => Foo<K> & { x: K; }
><K,>(x: K): Foo<K> & { x: K; } => { return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2} : <K>(x: K) => Foo<K> & { x: K; }
>x : K
>x : K

return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2
>{ a: 1, x: x } : { a: number; x: K; }
>a : number
>1 : 1
>x : K
>x : K
}

0 comments on commit b10b197

Please sign in to comment.