-
Notifications
You must be signed in to change notification settings - Fork 734
Closed
Labels
Domain: Type CheckingRelated to type checking, grammar checkingRelated to type checking, grammar checkingbugSomething isn't workingSomething isn't working
Description
Steps to reproduce
function f() {
const v: unknown = "lol";
const acceptsRecord = (record: Record<string, string>) => {};
acceptsRecord(v || {});
}Behavior with [email protected]
src/record.ts:4:17 - error TS2345: Argument of type '{}' is not assignable to parameter of type 'Record<string, string>'.
Index signature for type 'string' is missing in type '{}'.
4 acceptsRecord(v || {});
~~~~~~~
Behavior with [email protected]
no error
Commentary
I think in principle tsc is correct here, because {} includes primitives, { asdf: 3 }, etc. But note that both tsc and tsgo allow this if we do const v: {} = "lol";! So maybe this is some intentional case of playing fast and loose with inexactness, and tsgo is more consistent about it?
Copilot
Metadata
Metadata
Assignees
Labels
Domain: Type CheckingRelated to type checking, grammar checkingRelated to type checking, grammar checkingbugSomething isn't workingSomething isn't working