diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fd69b99c1522d..dec4d1c21ae85 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24526,7 +24526,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), typeParameter); } - /** Create an object with properties named in the string literal type. Every property has type `any` */ + /** Create an object with properties named in the string literal type. Every property has type `unknown` */ function createEmptyObjectTypeFromStringLiteral(type: Type) { const members = createSymbolTable(); forEachType(type, t => { @@ -24535,7 +24535,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const name = escapeLeadingUnderscores((t as StringLiteralType).value); const literalProp = createSymbol(SymbolFlags.Property, name); - literalProp.links.type = anyType; + literalProp.links.type = unknownType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; literalProp.valueDeclaration = t.symbol.valueDeclaration; diff --git a/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.types b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.types index ea8bf07b9354a..d96ab05f13ef1 100644 --- a/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.types +++ b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.types @@ -14,8 +14,8 @@ declare var two: "a" | "d"; >two : "a" | "d" const x = inference1(two); ->x : { a: any; d: any; } ->inference1(two) : { a: any; d: any; } +>x : { a: unknown; d: unknown; } +>inference1(two) : { a: unknown; d: unknown; } >inference1 : (name: keyof T) => T >two : "a" | "d" diff --git a/tests/baselines/reference/keyofInferenceIntersectsResults.types b/tests/baselines/reference/keyofInferenceIntersectsResults.types index 069dba76c5996..69ed1de4d3890 100644 --- a/tests/baselines/reference/keyofInferenceIntersectsResults.types +++ b/tests/baselines/reference/keyofInferenceIntersectsResults.types @@ -27,15 +27,15 @@ const a = foo('a', 'b'); // compiles cleanly >'b' : "b" const b = foo('a', 'b'); // also clean ->b : { a: any; } & { b: any; } ->foo('a', 'b') : { a: any; } & { b: any; } +>b : { a: unknown; } & { b: unknown; } +>foo('a', 'b') : { a: unknown; } & { b: unknown; } >foo : (x: keyof T, y: keyof T) => T >'a' : "a" >'b' : "b" const c = bar('a', 'b'); // still clean ->c : { a: any; } & { b: any; } ->bar('a', 'b') : { a: any; } & { b: any; } +>c : { a: unknown; } & { b: unknown; } +>bar('a', 'b') : { a: unknown; } & { b: unknown; } >bar : (x: keyof T, y: keyof T) => T >'a' : "a" >'b' : "b"