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

Tool generates a non-completely correct file for package-json #479

Closed
FStefanni opened this issue Aug 5, 2022 · 1 comment
Closed

Tool generates a non-completely correct file for package-json #479

FStefanni opened this issue Aug 5, 2022 · 1 comment

Comments

@FStefanni
Copy link

Hi,

I have used this tool to generate a package.json type description, starting from the official JSON schema.

The generated output file is almost correct, but it requires few manual fixes.
So here I report the issues I have found, to allow to improve the tool.

1 Linter

Yes, this is not a bug, but since tslint is deprecated since a lot of time, it could be nice to replace:

/* tslint:disable */

with:

/* eslint-disable */

2 Error in compiling

There are some places where something as this is generated:

{
        "."?: PackageExportsEntry | PackageExportsFallback;
        [k: string]: PackageExportsEntry | PackageExportsFallback;
}

And it fails to compile:

Property '"."' of type 'PackageExportsEntry | PackageExportsFallback | undefined' 
is not assignable to 'string' index type 'PackageExportsEntry | PackageExportsFallback'.

15443         "."?: PackageExportsEntry | PackageExportsFallback;

The error is that the field "." is optional (it is declared with ?:, but also an "or" with undefined would result in the same error),
and its type is the same of the "index type" ([k: string]: PackageExportsEntry | PackageExportsFallback;), except that the index type is not optional.
So the fix is to make also the index type optional:

{
        "."?: PackageExportsEntry | PackageExportsFallback;
        [k: string]: PackageExportsEntry | PackageExportsFallback | undefined;
}

Regards

@bcherny
Copy link
Owner

bcherny commented Aug 6, 2022

#1 is fixed in #474.
#2 is tracked in #299 (suggestions welcome!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants