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

bug?: Object literal may only specify known properties, and 'default' does not exist in type 'Schema' #394

Open
rxliuli opened this issue Jan 9, 2024 · 1 comment

Comments

@rxliuli
Copy link

rxliuli commented Jan 9, 2024

For example, the schema defined below is legal in json, but an error will occur if the Schema of the jsonschema package is defined in ts.

import { Schema } from 'jsonschema'

const s: Schema = {
    type: 'string',
    default: 'name' // Object literal may only specify known properties, and 'default' does not exist in type 'Schema'
}

playground: https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgZQMYAsCmICGcC+cAZlBCHAOQBWAzhAHY0bY4UBQbqDN8NAXCma44AXkRs4kuDACeYTAIo8owegHMKAGglSAJpiI4ArgBsYi+jhCZ2+IA


Strangely, I noticed that the type definition in the github code does contain the default field, but it does not exist in the npm package. Why is it not published?

default?: any

@kruncher
Copy link

I spotted the same issue where attempting to use this in rewrite:

rewrite: (instance, schema) => instance ?? schema.default,

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

No branches or pull requests

2 participants