Skip to content

Handle empty package.json files #39937

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

Merged
merged 1 commit into from
Aug 6, 2020

Conversation

andrewbranch
Copy link
Member

Fixes #39923

Thanks for investigating @DanielRosenwasser; it was easier for me just to throw this together since I knew where to put a test.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Aug 6, 2020
@@ -2735,9 +2735,7 @@ namespace ts {

type PackageJsonRaw = Record<typeof dependencyKeys[number], Record<string, string> | undefined>;
const dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"] as const;
const stringContent = host.readFile(fileName);
if (!stringContent) return undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the problem. Non-empty package.jsons with parse errors were already handled, but empty files were not.

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 6, 2020

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

@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-4.0

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 6, 2020

Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into release-4.0 on this PR at 0b9b321. You can monitor the build here.

const result: PackageJsonInfo[] = [];
forEachAncestorDirectory(getDirectoryPath(filePath), function processDirectory(directory): boolean | undefined {
const processDirectory = (directory: Path): boolean | undefined => {
Copy link
Member Author

Choose a reason for hiding this comment

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

All the changes in this file are just to eliminate the .bind(this) which you noticed were any.

@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-4.0 and LKG

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 6, 2020

Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into release-4.0 on this PR at 0b9b321. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've opened #39938 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Aug 6, 2020
Component commits:
0b9b321 Handle empty package.json files
@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-4.0 manually.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Aug 6, 2020
Component commits:
0b9b321 Handle empty package.json files
@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 6, 2020

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/81659/artifacts?artifactName=tgz&fileId=EA9AEEC76287DF1230FBEC4FB83CCE0A9FCEE03F1F09316CB26AB65E2F7BA12902&fileName=/typescript-4.1.0-insiders.20200806.tgz"
    }
}

and then running npm install.


There is also a playground for this build.

@DanielRosenwasser
Copy link
Member

Confirmed, no longer crashes for me.

DanielRosenwasser pushed a commit that referenced this pull request Aug 6, 2020
…39938)

* Cherry-pick PR #39937 into release-4.0

Component commits:
0b9b321 Handle empty package.json files

* Update LKG

Co-authored-by: Andrew Branch <[email protected]>
Co-authored-by: typescript-bot <[email protected]>
@andrewbranch andrewbranch merged commit 87a3b42 into microsoft:master Aug 6, 2020
@andrewbranch andrewbranch deleted the bug/39923 branch August 6, 2020 18:04
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
None yet
Development

Successfully merging this pull request may close these issues.

TS Server fatal error: Maximum call stack size exceeded
4 participants