Skip to content

Comments and utility types #405

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 12 commits into from
Feb 23, 2021

Conversation

marneborn
Copy link
Contributor

Please:

  • Make your pull request atomic, fixing one issue at a time unless there are many relevant issues that cannot be decoupled.
  • Provide a test case & update the documentation in the Readme.md

Currently (since PR #395 ) types created with utility types get the description on the type in lib.es5.d.ts.
For example:

/**
 * This comment is ignored. Should it be included?
 */
export type MyObject = Pick<BigThing, "prop1">;
interface BigThing {
  prop1: string;
  prop2: string;
};

Results in:

{
  "description": "From T, pick a set of properties whose keys are in the union K",
  "type": "object",
  "properties": {
    "prop1": {
      "type": "string"
    }
  },
  "required": [
    "prop1"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

This is the definition from lib.es5.d.ts

/**
 * From T, pick a set of properties whose keys are in the union K
 */
type Pick<T, K extends keyof T> = {
    [P in K]: T[P];
};

This PR results in:

{
  "type": "object",
  "properties": {
    "prop1": {
      "type": "string"
    }
  },
  "required": [
    "prop1"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

This matches (I think) the functionality before PR #395 for this case. Should I try to get this comment into the description?
Ie, should the this test give this instead?

{
  "description": "This comment is ignored. Should it be included?",
  "type": "object",
  "properties": {
    "prop1": {
      "type": "string"
    }
  },
  "required": [
    "prop1"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

@domoritz domoritz self-requested a review February 23, 2021 10:59
Copy link
Collaborator

@domoritz domoritz left a comment

Choose a reason for hiding this comment

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

Yes, I think the comment should be included (as in your test case).

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 this pull request may close these issues.

2 participants