ardatan / feTS

🗹 TypeScript HTTP Framework focusing on e2e type-safety, easy setup, performance & great developer experience
https://the-guild.dev/openapi/fets
MIT License
617 stars 28 forks source link

Type 'string' does not satisfy the constraint 'never' when using 'properties' keyword in OAS schema #1829

Open ahm3tcelik opened 3 weeks ago

ahm3tcelik commented 3 weeks ago

Describe the bug

I'm encountering a TypeScript error when defining a schema in my OpenAPI Specification (OAS) model using feTS. The error occurs when I try to use the properties keyword within my schema.

Here is a simplified version of my OAS model:

import type { NormalizeOAS, OASModel } from 'fets';

export const sampleOAS = {
    openapi: '3.0.1',
    info: {
        title: 'title',
        license: {
            name: 'Licensed by',
            url: 'https://sss.com',
        },
        version: '1.0.0',
    },
    externalDocs: {
        description: 'Project Documentation',
        url: '',
    },
    servers: [
        {
            url: 'https://sss.com',
            description: 'Generated server url',
        },
    ],
    tags: [],
    components: {
        schemas: {
            CheckDeviceResponse: {
                title: 'CheckDeviceResponse',
                type: 'object',
                properties: {
                    expiryDate: {
                        type: 'string',
                        description: 'expiryDate',
                        format: 'date-time',
                    },
                    properties: {
                        type: 'object',
                        additionalProperties: { type: 'string' },
                    },
                    sessionValidated: {
                        type: 'boolean',
                        example: false,
                    },
                },
            },
        },
    },
} as const;

export type CheckDeviceResponse = OASModel<
    NormalizeOAS<typeof sampleOAS>,
    'CheckDeviceResponse'
>

Type 'string' does not satisfy the constraint 'never'.

To Reproduce Steps to reproduce the behavior:

  1. Define a schema using the properties keyword within the components.schemas.
  2. Attempt to generate TypeScript types using feTS with the schema.

Expected behavior

TypeScript should successfully infer the types without error.

Actual behavior

TypeScript throws an error indicating that the type 'string' does not satisfy the constraint 'never'. This error seems to be related to the use of the properties keyword in the schema.

Link to Reproduction

Typescript Playground

Environment:

Additional context

The issue seems to arise when the properties keyword is used within a schema definition, conflicting with feTS type detection.