TypeScript-Handbook icon indicating copy to clipboard operation
TypeScript-Handbook copied to clipboard

In Object subsection of Basic Types section, last line with function call that passes undefined does not error out

Open nbkhope opened this issue 6 years ago • 1 comments

Regarding the Object subsection of the Basic Types section of the handbook.

The last line in the example says it should error out, but when compiled, there is no error.

declare function create(o: object | null): void;

// ...

create(undefined); // Error

I am using tsc Version 3.4.5

nbkhope avatar May 15 '19 02:05 nbkhope

Following up to clarify: the previously mentioned line will pass if the compiler does not have the --strictNullChecks option.

Maybe the handbook (or this section in particular?) should mention that it is assumed the compiler is using the --strictNullChecks option.

Update: FYI this section of the handbook says it does not assume --strictNullChecks.

nbkhope avatar Aug 12 '19 02:08 nbkhope