Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## instanceof-typeof-annotations #8948 +/- ##
=================================================================
- Coverage 81.21% 81.18% -0.04%
=================================================================
Files 457 457
Lines 63927 63927
=================================================================
- Hits 51921 51899 -22
- Misses 12006 12028 +22 🚀 New features to boost your workflow:
|
Why:
Untagged variants recognized stdlib classes only by type name, with no
relation between them, so a `Blob` case declared before a `File` case
also caught files (#8938).
Types whose values are instances of a global class now say so with
`@instanceOf` instead of `@notUndefined`, `Symbol.t` with
`@typeOf("symbol")`, and `File.t` is a private abbreviation of `Blob.t`.
`JsError.t`, `Symbol.t` and the `Intl` classes can be untagged variant
cases too. Fixes #8938.
JS modified (Blob and File cases):
Example:
@unboxed
type upload = Blob(Blob.t) | File(File.t)
let kind = upload =>
switch upload {
| Blob(_) => "blob"
| File(_) => "file"
}
Before (js):
if (upload instanceof Blob) {
return "blob";
} else {
return "file";
}
After (js):
if (upload instanceof Blob && !(upload instanceof File)) {
return "blob";
} else {
return "file";
}
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fc7LEuyEfynjaKCVEBPmTF
Signed-off-by: Christoph Knittel <ck@cca.io>
1107e5d to
42175d8
Compare
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
Fixes #8938. Stacked on the
@instanceOf/@typeOfPR.The stdlib's class-backed types now declare their class instead of only
@notUndefined:ArrayBuffer,DataView,Date,RegExp,Map,Set,WeakMap,WeakSet,JsError(Error), and theIntlclasses (Intl.Collator,Intl.DateTimeFormat,Intl.ListFormat,Intl.Locale,Intl.NumberFormat,Intl.PluralRules,Intl.RelativeTimeFormat,Intl.Segmenter) get@instanceOf.Symbol.tgets@typeOf("symbol").@instanceOf.FileandBlob:Blob.tgets@instanceOf("Blob"), andFile.tbecomes@instanceOf("File") type t = private Blob.t. A file is now known to be a blob, so aBlobcase excludes files, and(file :> Blob.t)upcasts.JsError.t,Symbol.tand theIntlclasses can now be untagged variant cases, which they couldn't before.Unchanged, because their values have no single class or
typeof, so they keep@notUndefined:Jsx.elementandJsx.component: anything React accepts.Iterator/AsyncIterator: protocol objects.TypedArray.t<'a>:%TypedArray%is not a global.Intl.Segments: no global constructor.Intl.NumberFormat.Grouping: a boolean or a string.Lazy.Generated code changes only where
BlobandFilecases meet: inUntaggedVariants.mjs, theBlobcase now excludes files.Test:
tests/tests/src/untagged_file_blob_test.resdeclaresBlobbeforeFile, and checks aBlobcase matched alone and the upcast.🤖 Generated with Claude Code
https://claude.ai/code/session_01Fc7LEuyEfynjaKCVEBPmTF