docs: fix nullable return types in generated typedoc#2102
Open
spotlight21c wants to merge 1 commit intoredis:mainredis/ioredis:mainfrom
spotlight21c:fix/typedoc-nullable-typespotlight21c/ioredis:fix/typedoc-nullable-typeCopy head branch name to clipboard
Open
docs: fix nullable return types in generated typedoc#2102spotlight21c wants to merge 1 commit intoredis:mainredis/ioredis:mainfrom spotlight21c:fix/typedoc-nullable-typespotlight21c/ioredis:fix/typedoc-nullable-typeCopy head branch name to clipboard
spotlight21c wants to merge 1 commit intoredis:mainredis/ioredis:mainfrom
spotlight21c:fix/typedoc-nullable-typespotlight21c/ioredis:fix/typedoc-nullable-typeCopy head branch name to clipboard
Conversation
|
Hi, I鈥檓 Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you鈥檒l enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
Contributor
|
@spotlight21c thanks, I'll take a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The generated TypeDoc documentation strips
| nullfrom every command that can returnnull. For example,redis.get()is rendered asPromise<string>even though its declared signature isPromise<string | null>. The same issue affects 70+ commands acrossRedis,Cluster, andChainableCommander(e.g.get,getex,getdel,mget,hmget,zscore,zrank,bzpopmin,blpop,lpop,spop,geopos, ...).Root cause
strictNullChecksis off intsconfig.json. With it disabled, TypeScript treatsnullas assignable to every type, sostring | nullcollapses tostringduring type resolution. TypeDoc reads the collapsed type from the compiler and renders it asPromise<string>.Fix
Generate docs with
strictNullChecksenabled, without affecting the main build:tsconfig.docs.jsonthat extendstsconfig.jsonand setsstrictNullChecks: true.docsscript to pass--tsconfig ./tsconfig.docs.jsonand--skipErrorChecking(existing source has pre-existingstrictNullChecksviolations that are unrelated to docs generation).typedocfrom^0.22.18to^0.25.13.0.25is the newest TypeDoc line that still supports TypeScript4.6.x, and it's the minimum version providing--skipErrorChecking.No runtime code, build output, or public type declarations are changed.
Before / after
redis.get(key)signature indocs/classes/Redis.html:get(key, callback?): Promise<string>get(key, callback?): Promise<null | string>The same correction applies to all nullable-return commands
Note
Medium Risk
Medium risk because it upgrades
typedocand its dependency chain and changes the docs build to use a separate tsconfig, which may impact contributors/CI environments (notably Node version requirements) but does not affect runtime code.Overview
Fixes TypeDoc output for nullable return types by generating docs with a dedicated
tsconfig.docs.jsonthat enablesstrictNullChecks.Updates the
docsscript to use that tsconfig and--skipErrorChecking, and bumpstypedocto^0.25.13(with corresponding lockfile dependency updates such asshiki/marked/minimatch).Reviewed by Cursor Bugbot for commit 2104c1e. Bugbot is set up for automated code reviews on this repo. Configure here.