Skip to content

Renaming types #405

Closed
Closed

Description

@Mike-Dax

I have a series of documents which look like this:

{
  "name": "useMessageIDSeenTimestamp",
  "parameters": [{ "name": "messageID", "type": "MessageID" }],
  "module": "@electricui/components-core",
  "returnType": "number | null"
}

However I'm having trouble typing the parameters field well enough. Using a nested type, the type parameter is overwritten:

{
  "name": "useMessageIDSeenTimestamp",
  "module": "@electricui/components-core",
  "parameters": [
    {
      "name": "messageID",
      "type": "Parameter",
      "_raw": {}
    }
  ]
}

Currently we're just using the json type and the TypeScript type is reverting to any, which gives us the data but means we lose TypeScript typing.

Is there a way to 'rename' my type parameter to something like tsType, to avoid having to do it upstream?

Activity

  1. cangSDARM commented on Mar 29, 2023

    @cangSDARM

    you may use typeFieldName to resolve this

  2. Mike-Dax commented on Mar 29, 2023

    @Mike-Dax
    Author

    Ah thank you.

    For future Googlers (since this was difficult to search):

    https://www.contentlayer.dev/docs/reference/source-files/make-source#fieldoptions

  3. locked and limited conversation to collaborators on Mar 29, 2023
  4. converted this issue into a discussion #406 on Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions