-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
rustdoc search: increase strictness of typechecking #137981
rustdoc search: increase strictness of typechecking #137981
Conversation
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
we encode "if the argument is a non-empty string, this will never return null" into the type signature.
This comment has been minimized.
This comment has been minimized.
ideally we would encode that it is a string before convertTypeFilterOnElem is called, and a number after, but i'm not sure that's possible without significant refactoring.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
some of the fields of rustdoc.Row were confusing null and undefined.
@bors r+ rollup |
For "bool-returning closures," do you mean the onEach and onEachLazy callbacks? Or something else? |
@notriddle those, but also also oops, I pushed more changes before I saw the approval, sorry. |
if i un-push the changes, will the approval re-activate? |
8920167
to
4f6772d
Compare
doesn't look like it (also wow github does not seem to like me rewinding and replaying the PR) |
I'll leave this PR alone now, so you can properly review it. |
@notriddle CI is green again, sorry for the hassle. |
@bors r+ |
@@ -1586,7 +1573,6 @@ class DocSearch { | |||
/** | |||
* @type {Array<rustdoc.Row>} | |||
*/ | |||
// @ts-expect-error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for helping clean all this stuff up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, hopefully this should make things easier to maintain going forward.
I always planned on working on the migration if typescript got the ok, you just went and implemented half of it before I could do anything :p
I was a bit worried you were going to be put off by some of the conditional type wizardry, since it's doing things that the rust type system can't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust doesn't have literal types, conditional types, or overloading.
But TypeScript can't do this, because type parameters are erased.
my_function(my_iterator.collect())
// ^^^^^^^ magically uses the correct `FromIterator`
I don't want to hammer that square peg into Rust's round hole. Writing in JS means giving up some power while accepting power elsewhere.
…kingjubilee Rollup of 15 pull requests Successful merges: - rust-lang#137829 (Stabilize [T]::split_off... methods) - rust-lang#137850 (Stabilize `box_uninit_write`) - rust-lang#137912 (Do not recover missing lifetime with random in-scope lifetime) - rust-lang#137913 (Allow struct field default values to reference struct's generics) - rust-lang#137923 (Simplify `<Postorder as Iterator>::size_hint`) - rust-lang#137949 (Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Windows 10/11 SDK) - rust-lang#137963 (Add ``dyn`` keyword to `E0373` examples) - rust-lang#137975 (Remove unused `PpMode::needs_hir`) - rust-lang#137981 (rustdoc search: increase strictness of typechecking) - rust-lang#137986 (Fix some typos) - rust-lang#137991 (Add `avr-none` to SUMMARY.md and platform-support.md) - rust-lang#137993 (Remove obsolete comment from DeduceReadOnly) - rust-lang#137996 (Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync"") - rust-lang#138019 (Pretty-print `#[deprecated]` attribute in HIR.) - rust-lang#138026 (Make CrateItem::body() function return an option) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#137981 - lolbinarycat:rustdoc-js-less-expect-error, r=notriddle rustdoc search: increase strictness of typechecking r? `@notriddle` The signature of `makePrimitiveElement` is now more accurate. I believe the intent of the code is that `name` cannot be null if `bindingName.name` is null, and I believe typescript is expressive enough to encode this, but I'm not quite sure how, or if this would be desirable. I'm also introducing mapped types into `rustdoc.d.ts`, but I think it's worth it in order to avoid keeping two interfaces in sync. I may add more commits onto this to remove more ``@ts-expect-error`` instances.
r? @notriddle
The signature of
makePrimitiveElement
is now more accurate.I believe the intent of the code is that
name
cannot be null ifbindingName.name
is null, and I believe typescript is expressive enough to encode this, but I'm not quite sure how, or if this would be desirable.I'm also introducing mapped types into
rustdoc.d.ts
, but I think it's worth it in order to avoid keeping two interfaces in sync.I may add more commits onto this to remove more
@ts-expect-error
instances.