From de78f6dcfce9c7a0711a2cf7adb3da441df5a28c Mon Sep 17 00:00:00 2001 From: Repo Assist Date: Sun, 22 Feb 2026 01:45:48 +0000 Subject: [PATCH] Fix docs: clarify why Tweet fields are inferred as optional in JsonProvider Twitter example The previous text said 'meaning that a tweet might not have an author?', which is misleading. The real reason is that TwitterStream.json contains both tweet objects and delete-event objects with different schemas; when the type provider merges heterogeneous samples, fields absent from some samples are inferred as optional. Closes #1073 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/library/JsonProvider.fsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/library/JsonProvider.fsx b/docs/library/JsonProvider.fsx index 28e121ab4..e753d2b01 100644 --- a/docs/library/JsonProvider.fsx +++ b/docs/library/JsonProvider.fsx @@ -369,9 +369,12 @@ printfn "%s (retweeted %d times)\n:%s" tweet.User.Value.Name tweet.RetweetCount. (** After creating the `Tweet` type, we parse a single sample tweet and print some details about the -tweet. As you can see, the `tweet.User` property has been inferred as optional (meaning that a -tweet might not have an author?) so we unsafely get the value using the `Value` property. -The `RetweetCount` and `Text` properties may be also missing, so we also access them unsafely. +tweet. As you can see, the `tweet.User` property has been inferred as optional, and so are +`RetweetCount` and `Text`. The reason is that `TwitterStream.json` contains not only tweet objects +but also other event types (such as `delete` events) with a completely different schema. When the +type provider merges multiple heterogeneous sample objects, any field that does not appear in all +samples is inferred as optional. We unsafely get the values using the `Value` property since we +know our input is a tweet. ## Getting and creating GitHub issues