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

Can't narrow {} to Record<string, any> using custom type guards/assertions - Post 4.8 beta regression #50001

Closed
dragomirtitian opened this issue Jul 22, 2022 · 2 comments

Comments

@dragomirtitian
Copy link
Contributor

Bug Report

πŸ”Ž Search Terms

narrow {} custom type guard type assertion Record<string,any>

πŸ•— Version & Regression Information

  • This changed between versions 4.8.0-dev.20220715 and 4.8.0-dev.20220716

⏯ Playground Link

Playground Link

πŸ’» Code

function isObject(o: unknown): o is Record<string, any> {
    return true;
}

function assertObject(o: unknown): asserts o is Record<string, any> {
    
}

let value: {} = null!;
if(isObject(value)) {
    value.aything // error since 4.8.0-dev.20220716
}

assertObject(value)

value.aything // error since 4.8.0-dev.20220716

πŸ™ Actual behavior

value.aything is an error even after the custom type assertions/guards. value still apears as {} instead of Record<string, any>

πŸ™‚ Expected behavior

Should be able to access value.aything after custom assertion/guard and value should be of type Record<string, any> in if, after assertion.

@MartinJohns
Copy link
Contributor

This sounds like a duplicate of #49988.

@dragomirtitian
Copy link
Contributor Author

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants