Typescript --strictNullChecks vs. stream zero sequence checking

If I run "typescript --strictNullChecks" with the code below, I get no errors. If I run a thread through it, it gives me an error about the incompatibility of null type and number. Why aren't typescript also a mistake on this? Is this a feature or issue in the magazine?

// @flow
var f = function f( x ) {
    var y = x * 2;
}
f(null);
+4
source share
1 answer

TypeScript does not perform site analysis.

TypeScript sees this, this is normal:

var f = function f( x: any ) {
    var y = x * 2;
}
f(null);

The stream sees:

var f = function f( x: ??? ) {
    var y = x * 2;
}
f(null);

where is ???determined by viewing calls in the current file. In this case it xhas a bare type nulland is in error.

TypeScript ? , , - , , , , ( ), , , . - fileName, fileName, , , ? TypeScript - " , , ", .

, . , Flow , , "" , . , , , .

+9

All Articles