GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Differing types in main schema and create cause TypeScript problems · Issue #3623 · feathersjs/feathers

Differing types in main schema and create cause TypeScript problems #3623

New issue
Copy link
New issue
Copy link
Open
Open
Differing types in main schema and create cause TypeScript problems#3623
Copy link

Description

@AshotN
AshotN
opened on Oct 20, 2025
Issue body actions
// Main data model schema
export const companySchema = Type.Object(
  {
    id: Type.Number(),
    count: Type.String() //Stored as string in DB for example
  },
  { $id: 'Company', additionalProperties: false }
)


// Schema for creating new entries
export const companyDataSchema = Type.Object(
  {
    text: Type.String(),
    count: Type.Number() // Taken as number by API
  },
  {
    $id: 'CompanyData',
    additionalProperties: false
  }
)
export type CompanyData = Static<typeof companyDataSchema>

//Type error - Type string is not assignable to type PromiseOrLiteral<number | undefined>
export const companyDataResolver = resolve<CompanyData, HookContext<CompanyService>>({
  count: (value, obj, context, status) => {
    return value + ' People'
  }
})

Similarly, if you have differing types between the main and create schema. context.result in hooks get's typed as any

create: [
        async (context, next) => {
          const result = context.result
          // result is type any
          await next()
        }
      ]

Types should never fallback into any if there is a unexpected type, the output type should be never so you don't accidentally break bypass TypeScript.

Activity

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.