mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Add tests
This commit is contained in:
parent
1c39cdc7ef
commit
d8ec85775a
119
tests/cases/compiler/controlFlowLetVar.ts
Normal file
119
tests/cases/compiler/controlFlowLetVar.ts
Normal file
@ -0,0 +1,119 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f9() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
function f() {
|
||||
const z = x;
|
||||
}
|
||||
}
|
||||
|
||||
function f10() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
const f = () => {
|
||||
const z = x;
|
||||
};
|
||||
}
|
||||
120
tests/cases/compiler/controlFlowNoImplicitAny.ts
Normal file
120
tests/cases/compiler/controlFlowNoImplicitAny.ts
Normal file
@ -0,0 +1,120 @@
|
||||
// @strictNullChecks: true
|
||||
// @noImplicitAny: true
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
}
|
||||
|
||||
function f9() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
function f() {
|
||||
const z = x;
|
||||
}
|
||||
}
|
||||
|
||||
function f10() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x;
|
||||
const f = () => {
|
||||
const z = x;
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user