|
| 1 | +//// [tests/cases/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.ts] //// |
| 2 | + |
| 3 | +=== declarationEmitMappedTypePreservesTypeParameterConstraint.ts === |
| 4 | +// repro from https://github.com/microsoft/TypeScript/issues/54560 |
| 5 | + |
| 6 | +declare type requiredKeys<T extends object> = { |
| 7 | +>requiredKeys : Symbol(requiredKeys, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 0, 0)) |
| 8 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 2, 26)) |
| 9 | + |
| 10 | + [k in keyof T]: undefined extends T[k] ? never : k; |
| 11 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 3, 3)) |
| 12 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 2, 26)) |
| 13 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 2, 26)) |
| 14 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 3, 3)) |
| 15 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 3, 3)) |
| 16 | + |
| 17 | +}[keyof T]; |
| 18 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 2, 26)) |
| 19 | + |
| 20 | +declare type addQuestionMarks< |
| 21 | +>addQuestionMarks : Symbol(addQuestionMarks, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 4, 11)) |
| 22 | + |
| 23 | + T extends object, |
| 24 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 6, 30)) |
| 25 | + |
| 26 | + R extends keyof T = requiredKeys<T> |
| 27 | +>R : Symbol(R, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 7, 19)) |
| 28 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 6, 30)) |
| 29 | +>requiredKeys : Symbol(requiredKeys, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 0, 0)) |
| 30 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 6, 30)) |
| 31 | + |
| 32 | +> = Pick<Required<T>, R> & Partial<T>; |
| 33 | +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) |
| 34 | +>Required : Symbol(Required, Decl(lib.es5.d.ts, --, --)) |
| 35 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 6, 30)) |
| 36 | +>R : Symbol(R, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 7, 19)) |
| 37 | +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) |
| 38 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 6, 30)) |
| 39 | + |
| 40 | +declare type identity<T> = T; |
| 41 | +>identity : Symbol(identity, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 9, 38)) |
| 42 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 11, 22)) |
| 43 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 11, 22)) |
| 44 | + |
| 45 | +declare type flatten<T> = identity<{ |
| 46 | +>flatten : Symbol(flatten, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 11, 29)) |
| 47 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 13, 21)) |
| 48 | +>identity : Symbol(identity, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 9, 38)) |
| 49 | + |
| 50 | + [k in keyof T]: T[k]; |
| 51 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 14, 3)) |
| 52 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 13, 21)) |
| 53 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 13, 21)) |
| 54 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 14, 3)) |
| 55 | + |
| 56 | +}>; |
| 57 | + |
| 58 | +export declare abstract class ZodType<Output = any> { |
| 59 | +>ZodType : Symbol(ZodType, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 15, 3)) |
| 60 | +>Output : Symbol(Output, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 17, 38)) |
| 61 | + |
| 62 | + readonly _output: Output; |
| 63 | +>_output : Symbol(ZodType._output, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 17, 53)) |
| 64 | +>Output : Symbol(Output, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 17, 38)) |
| 65 | +} |
| 66 | + |
| 67 | +export declare class ZodLiteral<T> extends ZodType<T> {} |
| 68 | +>ZodLiteral : Symbol(ZodLiteral, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 19, 1)) |
| 69 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 21, 32)) |
| 70 | +>ZodType : Symbol(ZodType, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 15, 3)) |
| 71 | +>T : Symbol(T, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 21, 32)) |
| 72 | + |
| 73 | +export declare type ZodTypeAny = ZodType<any>; |
| 74 | +>ZodTypeAny : Symbol(ZodTypeAny, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 21, 56)) |
| 75 | +>ZodType : Symbol(ZodType, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 15, 3)) |
| 76 | + |
| 77 | +export declare type baseObjectOutputType<Shape extends ZodRawShape> = { |
| 78 | +>baseObjectOutputType : Symbol(baseObjectOutputType, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 23, 46)) |
| 79 | +>Shape : Symbol(Shape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 25, 41)) |
| 80 | +>ZodRawShape : Symbol(ZodRawShape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 31, 2)) |
| 81 | + |
| 82 | + [k in keyof Shape]: Shape[k]["_output"]; |
| 83 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 26, 3)) |
| 84 | +>Shape : Symbol(Shape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 25, 41)) |
| 85 | +>Shape : Symbol(Shape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 25, 41)) |
| 86 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 26, 3)) |
| 87 | + |
| 88 | +}; |
| 89 | + |
| 90 | +export declare type objectOutputType<Shape extends ZodRawShape> = flatten< |
| 91 | +>objectOutputType : Symbol(objectOutputType, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 27, 2)) |
| 92 | +>Shape : Symbol(Shape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 29, 37)) |
| 93 | +>ZodRawShape : Symbol(ZodRawShape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 31, 2)) |
| 94 | +>flatten : Symbol(flatten, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 11, 29)) |
| 95 | + |
| 96 | + addQuestionMarks<baseObjectOutputType<Shape>> |
| 97 | +>addQuestionMarks : Symbol(addQuestionMarks, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 4, 11)) |
| 98 | +>baseObjectOutputType : Symbol(baseObjectOutputType, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 23, 46)) |
| 99 | +>Shape : Symbol(Shape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 29, 37)) |
| 100 | + |
| 101 | +>; |
| 102 | + |
| 103 | +export declare type ZodRawShape = { |
| 104 | +>ZodRawShape : Symbol(ZodRawShape, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 31, 2)) |
| 105 | + |
| 106 | + [k: string]: ZodTypeAny; |
| 107 | +>k : Symbol(k, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 34, 3)) |
| 108 | +>ZodTypeAny : Symbol(ZodTypeAny, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 21, 56)) |
| 109 | + |
| 110 | +}; |
| 111 | + |
| 112 | +export const buildSchema = <V extends string>( |
| 113 | +>buildSchema : Symbol(buildSchema, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 37, 12)) |
| 114 | +>V : Symbol(V, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 37, 28)) |
| 115 | + |
| 116 | + version: V |
| 117 | +>version : Symbol(version, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 37, 46)) |
| 118 | +>V : Symbol(V, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 37, 28)) |
| 119 | + |
| 120 | +): objectOutputType<{ |
| 121 | +>objectOutputType : Symbol(objectOutputType, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 27, 2)) |
| 122 | + |
| 123 | + version: ZodLiteral<V>; |
| 124 | +>version : Symbol(version, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 39, 21)) |
| 125 | +>ZodLiteral : Symbol(ZodLiteral, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 19, 1)) |
| 126 | +>V : Symbol(V, Decl(declarationEmitMappedTypePreservesTypeParameterConstraint.ts, 37, 28)) |
| 127 | + |
| 128 | +}> => ({} as any); |
| 129 | + |
0 commit comments