Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(29118): tsconfig.extends as array #50403

Merged
merged 15 commits into from
Dec 13, 2022
Merged

Fix(29118): tsconfig.extends as array #50403

merged 15 commits into from
Dec 13, 2022

Conversation

navya9singh
Copy link
Member

Fixes #29118

Copy link
Member

@sheetalkamat sheetalkamat left a comment

src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Show resolved Hide resolved
src/executeCommandLine/executeCommandLine.ts Outdated Show resolved Hide resolved
src/testRunner/unittests/config/configurationExtension.ts Outdated Show resolved Hide resolved
src/testRunner/unittests/config/configurationExtension.ts Outdated Show resolved Hide resolved
src/testRunner/unittests/config/showConfig.ts Outdated Show resolved Hide resolved
src/testRunner/unittests/tsbuildWatch/programUpdates.ts Outdated Show resolved Hide resolved
Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into other comments later

src/testRunner/unittests/tsbuildWatch/programUpdates.ts Outdated Show resolved Hide resolved
src/executeCommandLine/executeCommandLine.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
@@ -300,6 +300,14 @@ namespace ts {
// TODO: check infinite loop
possibleValues = getPossibleValues(option.element);
break;
case "listOrElement":
if (option.element.type === "string"){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (option.element.type === "string"){
if (option.element.type === "string") {

options[opt.name] = validateJsonOptionValue(opt, args[i] || "", errors);
i++;
}
else{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else{
else {

@@ -2986,34 +3029,52 @@ namespace ts {
if (ownConfig.extendedConfigPath) {
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
resolutionStack = resolutionStack.concat([resolvedPath]);
const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache);
const result: ExtendsResult = { options:{} };
if(isString(ownConfig.extendedConfigPath)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces throughout

i++;
}
}
Debug.fail();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Debug.fail();
Debug.fail("listOrElement not supported here");

src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/executeCommandLine/executeCommandLine.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/testRunner/unittests/tsbuildWatch/programUpdates.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/testRunner/unittests/tsbuildWatch/programUpdates.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
@@ -2513,6 +2529,7 @@ function serializeOptionBaseObject(
const value = options[name] as CompilerOptionsValue;
const optionDefinition = optionsNameMap.get(name.toLowerCase());
if (optionDefinition) {
Debug.assert(optionDefinition.type !== "listOrElement");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix formatting for some of the changes that has been indented by one extra tab

@andrewbranch
Copy link
Member

Example:

// @Filename: /tsconfig1.json
{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

// @Filename: /tsconfig2.json
{
  "compilerOptions": {
    "noImplicitAny": true
  }
}

// @Filename: /tsconfig.json
{
  "extends": ["./tsconfig1.json", "./tsconfig2.json"]
  "files": ["./index.ts"]
}

// @Filename: /index.ts
function f(x) {} // noImplicitAny error
let y: string;
y.toLowerCase(); // strictNullChecks error

@sheetalkamat
Copy link
Member

@andrewbranch the compiler tests are hard to add with tsconfig. https://github.com/microsoft/TypeScript/pull/50403/files#diff-0556827a3985d4ffd3ed2e51ac63c9d86ba98ab41dca5c7711fb2750188cbe8a shows the test case where multiple tsconfigs are working together ? https://github.com/microsoft/TypeScript/pull/50403/files#diff-97bc6a439e0f02498deab0f7c919e4e7a2f06c6b4832fd2fc7b042f56b141ff9R111 baseline.

While said that we could add test in non watch mode as well.

@andrewbranch
Copy link
Member

I saw that baseline, but I couldn’t find any indication in the baseline that the options in the extended configs were relevant. I was looking for a strictNullChecks or noImplicitAny error but didn’t see any. Maybe I missed it in the noise.

There are plenty of compiler tests with tsconfig files, but I don’t know if there are subtle gotchas with them.

@sheetalkamat
Copy link
Member

@navya9singh you probably want to add test like https://github.com/microsoft/TypeScript/blob/main/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts with the contents of test files as shown by @andrewbranch for better clarity

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 7, 2022

Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at bb0ae2f. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 7, 2022

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/139933/artifacts?artifactName=tgz&fileId=43D4A075BE928283C15303888F67D4786C1B8B67071DA37D39B422AFBEEC049702&fileName=/typescript-5.0.0-insiders.20221207.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.0.0-pr-50403-6".;

@andrewbranch
Copy link
Member

It looks like some changes landed in main that require you to update something in your unit tests. I’m guessing it’s #51798. You’ll want to manually merge main into this branch and then take a look at those test files that no longer build, using Sheetal’s PR as a reference for how to update them.

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the build is green, looks good to merge.

@andrewbranch
Copy link
Member

:shipit:

@navya9singh navya9singh merged commit 7267fca into main Dec 13, 2022
@navya9singh navya9singh deleted the fix(29118) branch December 13, 2022 19:16
@orta
Copy link
Contributor

orta commented Dec 14, 2022

Very cool

@bradley-marker-ck
Copy link

bradley-marker-ck commented Mar 31, 2023

Just a heads up if you're sharing a tsconfig from a package. It seems typescript@4.9.5 was not restricted by the exports from the package.json file. It is now with @typescript@5.0.3.

The tsconfig.json file not found error was the last error when running tsc.

In my case, it was also causing eslint (with @typescript-eslint/parser) to fail with out of memory errors. Since we run eslint before tsc, it was a few tries before I decided to skip eslint and run tsc and was able to find the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

tsconfig.extends as array
8 participants