Skip to content

StripEnums drops types for key-optional fields #252

@Eazash

Description

@Eazash

Environment

  • typescript@5.9.2
  • pkg-types@2.3.0

Reproduction

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAysBOBLMBRAdgVwLYGcA8AKlBAB7ARoAmOUAShAMYD28leOCiaA5gDRQBDNCAB8IqAF4oAbwBQUBVADaAaShcoAawggmAMygEAugC5Dqo8TIVqUAEZMmAGwhD5igPzmVR9wrMEFlbkVDQcSDx+UF6BPlEBQaQhtkx2AFaMwFExFvHelkk2NACC8PACIHhCotn5ebEF1qFQGFQQelwQlLWtlO2d3YpQZtUA3LIAvuOyFNhQAFoy7nqOvO52AvBQk7KyoJBQABqSS0MCHmYOzq5oUXYXCzt74NAAmidwSKiYuHiHIkA

Describe the bug

When used on records with optional types (e.g. CompilerOptions), the StripEnums type utility drops those types and reverts to an any. This leads to compilerOptions being typed as below

(property) TSConfig.compilerOptions?: {
    [x: string]: any;
    allowImportingTsExtensions?: any;
    allowJs?: any;
    allowArbitraryExtensions?: any;
    allowSyntheticDefaultImports?: any;
    ... 104 more ...;
    useDefineForClassFields?: any;
} | undefined

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions