TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Type Guard Documentation Is Incorrectly Labeled as Deprecated

Open ryanoboril opened this issue 7 months ago • 5 comments

🔎 Search Terms

The only source of online information for the proper use of typescript type guards (value is someType, asserts value is someType) is this page, which has a big DEPRECATED banner at the top. Please REMOVE THIS BANNER until this documentation has a replacement, then make the "Go To New Page" button link to the updated documentation, not some top level page where user needs to once again search for this new page that actually does not exist. THIS IS VALUABLE INFORMATION and it needs to be easier to find and trust, this is one of the most important features of typescript!

Image

🕗 Version & Regression Information

This is not code, it's documentation and I can't figure out how else to submit this bug but none of the "code questions" fit here. This documentation page has been like this for at least 2 years. Please fix 🙏

⏯ Playground Link

https://www.typescriptlang.org/docs/handbook/advanced-types.html

💻 Code

https://www.typescriptlang.org/docs/handbook/advanced-types.html

🙁 Actual behavior

Valid and important typescript documentation has deprecation banner and link to new page that does not link to new page and there is no new page, so it's difficult to understand how to use type-guards to get that awesome control flow analysis-based type narrowing. Instead, it looks like typscript is removing the feature (please don't!)

🙂 Expected behavior

Valid and important typescript documentation does not have deprecation banner. OR it has deprecation banner but the link to new page actually goes to the new and updated page. Users can find out how to use type-guards and actually trust the information and can use it with confidence.

Additional information about the issue

Please tell me how to properly submit this bug if this is not the correct location or approach, I don't know what else to do

ryanoboril avatar Jun 16 '25 14:06 ryanoboril

The entire old handbook is deprecated, this is correct.

The new link for this section is: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates

MartinJohns avatar Jun 16 '25 14:06 MartinJohns

Ah, in that case it should just be a matter of updating the URL pointed to by the "Go to New Page" buttons on the old page. These are currently going to this link, which is not the same topic sub-page of the new handbook. This is the actual cause of the confusion and the root of the issue I am reporting.

ryanoboril avatar Jun 16 '25 15:06 ryanoboril

Submitted for review on Typescript-Website repo 🙏

https://github.com/microsoft/TypeScript-Website/pull/3406

ryanoboril avatar Jun 17 '25 03:06 ryanoboril

The Advanced Types page is sprawling, covering everything from UDTGs to enums to instanceof to conditional types to mapped types to nullability. For good reason, there isn't a single page in the v2 Handbook that covers that much stuff at once. Instead of just assuming that everyone who goes to the page that covers "Every Type Since 1.6" wants to read about UDTGs, we'd really want per-section deprecation headers.

RyanCavanaugh avatar Jun 17 '25 16:06 RyanCavanaugh

The problem is that when user clicks "Go to New Page" button on old handbook Advanced Types page, they are taken to "types of types" section in the middle of the new handbook. Instead of just assuming that everyone who goes to the page that covers "Every Type Since 1.6" wants to read about types of types, I think the "Go to New Page" button should take user to the top-level handbook page instead of the "types of types" section of the new handbook, maybe that is a fix that makes sense?

ryanoboril avatar Jun 18 '25 05:06 ryanoboril