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

Documentation: --strictNullChecks behaves slightly different than doc says #18103

Closed
bodawei opened this issue Aug 29, 2017 · 1 comment
Closed
Labels
Spec Issues related to the TypeScript language specification

Comments

@bodawei
Copy link

bodawei commented Aug 29, 2017

Code

In https://www.typescriptlang.org/play/index.html

let x: void = undefined;
let x1: void = null;

let x2: null = undefined;
let x3: undefined = null;

Expected behavior:
According to the doc:
https://www.typescriptlang.org/docs/handbook/basic-types.html

However, when using the --strictNullChecks flag, null and undefined are only assignable to void and their respective types. This helps avoid many common errors. In cases where you want to pass in either a string or null or undefined, you can use the union type string | null | undefined. Once again, more on union types later on.

when --strictNullChecks is on, x2 and x3 should be errors.

Actual behavior:

x1, x2 and x3 are all reporting errors.

(in truth, I don't know if the doc or the implementation is wrong)

@mhegazy mhegazy added the Spec Issues related to the TypeScript language specification label Aug 29, 2017
@RyanCavanaugh
Copy link
Member

The spec is now an "archived" artifact and we won't be tracking defects against it anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Spec Issues related to the TypeScript language specification
Projects
None yet
Development

No branches or pull requests

3 participants