Skip to content

Using an index.ts file to export multiple types that would be deserialized causes silent failures #318

@danfma

Description

@danfma

If you have multiple files like bellow:

data/stat-weight-unit.ts

export type StatWeightUnit = 'lbs' | 'kg';

data/stat-engine-power-unit.ts

export type StatEnginePowerUnit = 'hp';

data/index.ts

export { StatWeightUnit } from './stat-weight-unit';
export { StatEnginePowerUnit } from './stat-engine-power-unit';

test.ts

import { StatEnginePowerUnit } from './data';

console.log(cast<StatEnginePowerUnit>('kg'));

The serializer will return undefined always, and it will not emit the value, no matter if the serialized value is valid or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions