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

fix: Make nested objects show in typescript .d.ts file and in the doc… #231

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

kpears201
Copy link
Contributor

…umentation

@kpears201
Copy link
Contributor Author

kpears201 commented Nov 19, 2024

Currently in both the documentation and the .d.ts file that ships with the SDK a type that has an inline-nested object which might look like:

{
  "SectionIntent": {
    "description": "A Firebolt compliant representation of a user intention to navigate an app to a section not covered by `home`, `entity`, `player`, or `search`, and bring that app to the foreground if needed.",
    "title": "SectionIntent",
    "allOf": [
      {
        "$ref": "#/definitions/Intent"
      },
      {
        "$ref": "#/definitions/IntentProperties"
      },
      {
        "type": "object",
        "properties": {
          "action": {
            "const": "section"
          },
          "data": {
            "type": "object",
            "required": [
              "sectionName"
            ],
            "properties": {
              "sectionName": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "data"
        ]
      }
    ]
  }
}

Has generated typescript like this:

type SectionIntent = {
  action: 'section'
  data: object
  context: object
}

After this change it now looks like this:

type SectionIntent = {
    action: 'section'
    data: {
      sectionName: string
    }
    context: {
      source: string
    }
  }

This allows developers looking at the documentation to actually know all the fields that are a part of this schema.
It also makes it so when developing a typescript app in an IDE, it can autocomplete all the fields instead of just the root object.

This will fix it for many schemas, most the intents have nested inline objects and have this issue.

kevinshahfws
kevinshahfws previously approved these changes Nov 19, 2024
@kpears201 kpears201 merged commit 31217ce into next Nov 21, 2024
6 checks passed
@kpears201 kpears201 deleted the nested-object-types branch November 21, 2024 17:56
kschrief pushed a commit that referenced this pull request Nov 21, 2024
# [3.2.0-next.10](v3.2.0-next.9...v3.2.0-next.10) (2024-11-21)

### Bug Fixes

* Make nested objects show in typescript .d.ts file and in the doc… ([#231](#231)) ([31217ce](31217ce))
@kschrief
Copy link
Contributor

🎉 This PR is included in version 3.2.0-next.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants