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

CFA not work in function #13142

Closed
k8w opened this issue Dec 23, 2016 · 1 comment · Fixed by #56908
Closed

CFA not work in function #13142

k8w opened this issue Dec 23, 2016 · 1 comment · Fixed by #56908
Labels
Duplicate An existing issue was already created

Comments

@k8w
Copy link

k8w commented Dec 23, 2016

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)
2.1.4

Code

let f:string | null = 'xx';
let v:string;
if(f){
    [].forEach(item=>{
        v = f;
    })
}

Expected behavior:
Compile successfully

Actual behavior:

test.ts(5,9): error TS2322: Type 'string | null' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'.

@HerringtonDarkholme
Copy link
Contributor

#9998

@mhegazy mhegazy added the Duplicate An existing issue was already created label Dec 26, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants