Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't error when function has an implicit return but its return type is assignable to undefined #53490

Merged
merged 10 commits into from
Mar 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update baseline
Maria Solano committed Mar 27, 2023
commit 6956159d25a0addb46662920c6f09e4c3d851c0b
5 changes: 1 addition & 4 deletions tests/baselines/reference/unknownType1.errors.txt
Original file line number Diff line number Diff line change
@@ -20,15 +20,14 @@ tests/cases/conformance/types/unknown/unknownType1.ts(128,5): error TS2322: Type
tests/cases/conformance/types/unknown/unknownType1.ts(129,5): error TS2322: Type 'number' is not assignable to type '{ [x: string]: unknown; }'.
tests/cases/conformance/types/unknown/unknownType1.ts(143,29): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/unknown/unknownType1.ts(144,29): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/unknown/unknownType1.ts(150,17): error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.
tests/cases/conformance/types/unknown/unknownType1.ts(156,14): error TS2700: Rest types may only be created from object types.
tests/cases/conformance/types/unknown/unknownType1.ts(162,5): error TS2564: Property 'a' has no initializer and is not definitely assigned in the constructor.
tests/cases/conformance/types/unknown/unknownType1.ts(170,9): error TS2322: Type 'T' is not assignable to type '{}'.
tests/cases/conformance/types/unknown/unknownType1.ts(171,9): error TS2322: Type 'U' is not assignable to type '{}'.
tests/cases/conformance/types/unknown/unknownType1.ts(181,5): error TS2322: Type 'T' is not assignable to type '{}'.


==== tests/cases/conformance/types/unknown/unknownType1.ts (27 errors) ====
==== tests/cases/conformance/types/unknown/unknownType1.ts (26 errors) ====
// In an intersection everything absorbs unknown

type T00 = unknown & null; // null
@@ -222,8 +221,6 @@ tests/cases/conformance/types/unknown/unknownType1.ts(181,5): error TS2322: Type
// Functions with unknown return type don't need return expressions

function f27(): unknown {
~~~~~~~
!!! error TS2847: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.
}

// Rest type cannot be created from unknown