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

Loosen "patternProperties" in package.json schema #715

Closed
G-Rath opened this issue Jun 13, 2019 · 1 comment · Fixed by #716
Closed

Loosen "patternProperties" in package.json schema #715

G-Rath opened this issue Jun 13, 2019 · 1 comment · Fixed by #716

Comments

@G-Rath
Copy link
Contributor

G-Rath commented Jun 13, 2019

schematoreupdate uses json-schema-to-typescript to generate type definitions for the schemas provided by schemastore, which are published to npm.

However, the definition generated for the schema for package.json currently has type errors, due to patternProperties.

This was raised on schematoreupdate here, and raised (separately) on json-schema-to-typescript here.

@bcherny provided a detailed explanation of the problem, along w/ a suggested fix that IMO sounds reasonable:

I think the best fix here is to replace the patternProperties section with a more lenient one:

  "patternProperties": {
    "^_": {
      "description": "Any property starting with _ is valid.",
      "type": "any"
    }
  },

This is a more correct definition, since _-prefixed package.json properties don't have to be objects.

If that's not an acceptable change to the schema, I'd like to get a discussion going to see if a middleground can be reached (here & w/ json-schema-to-typescript) that means we can have our schemas & type them too 😉

@G-Rath
Copy link
Contributor Author

G-Rath commented Jun 13, 2019

I've just realised the proposed solution uses an invalid type (any) - I've made a comment on the original issue.

As I said:

I'd like to get a discussion going to see if a middleground can be reached

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

Successfully merging a pull request may close this issue.

1 participant