Files
tsgo/testdata/baselines/reference/submodule/compiler/discriminatedUnionWithIndexSignature.js

44 lines
795 B
TypeScript

//// [tests/cases/compiler/discriminatedUnionWithIndexSignature.ts] ////
//// [discriminatedUnionWithIndexSignature.ts]
export interface UnionAltA {
type?: 'text';
}
export interface UnionAltB {
type?: 'image' | 'video' | 'document';
}
export type ValueUnion = UnionAltA | UnionAltB;
export type MapOrSingleton =
| {
[key: string]: ValueUnion;
}
| ValueUnion;
const withoutAsConst: MapOrSingleton = {
1: {
type: 'text' /*as const*/,
},
};
const withAsConst: MapOrSingleton = {
1: {
type: 'text' as const,
},
};
//// [discriminatedUnionWithIndexSignature.js]
const withoutAsConst = {
1: {
type: 'text' /*as const*/,
},
};
const withAsConst = {
1: {
type: 'text',
},
};
export {};