Skip to content

Change in type inference for Object.entries() #1164

Closed
@printfn

Description

@printfn
function foo(x?: object) {
    return Object.entries(x || {})
        .sort(([k1, v1], [k2, v2]) => v1.name.localeCompare(v2.name));
}

This passes typechecking in 5.8.3 but fails in b00279c. While tsc infers v1 and v2 as any, tsgo infers them as unknown.

tsconfig.json
{
	"compilerOptions": {
		"target": "ES2020",
		"useDefineForClassFields": true,
		"lib": ["esnext", "dom", "dom.iterable"],
		"module": "ESNext",
		"skipLibCheck": true,

		"moduleResolution": "Bundler",
		"allowImportingTsExtensions": true,
		"isolatedModules": true,
		"verbatimModuleSyntax": true,
		"moduleDetection": "force",
		"noEmit": true,
		"jsx": "react-jsx",
		"esModuleInterop": true,
		"allowJs": false,

		"strict": true,
		"forceConsistentCasingInFileNames": true,
		"noFallthroughCasesInSwitch": true,
		"sourceMap": false,
		"noImplicitAny": true,
		"checkJs": false,
		"strictBindCallApply": true,
		"strictFunctionTypes": true,
		"noImplicitThis": true,
		"alwaysStrict": true,
		"noUncheckedIndexedAccess": true,
		"useUnknownInCatchVariables": true,
		"strictNullChecks": true
	},
	"include": ["*.ts"]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Type CheckingRelated to type checking, grammar checkingType OrderingAn issue related to ordering of typesbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions