Skip to content

Commit f109d91

Browse files
Copilot fixes
1 parent b7f92e6 commit f109d91

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

blog/2025-02-14-typescript-sdk-release.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Today we are excited to announce the availability of version 0.14 of our TypeScr
88

99
This release is a big step forward, significantly improving the type safety of our `@atproto/api` package. Let’s take a look at the highlights:
1010

11-
- **Lexicon derived interfaces now have an explicitly defined `$type` property**, allowing to properly discriminate unions.
11+
- **Lexicon derived interfaces now have an explicitly defined `$type` property**, allowing proper discrimination of unions.
1212
- **Lexicon derived `is*` utility methods no longer unsafely type cast their input**.
1313
- **Lexicon derived `validate*` utility methods now return a more precise type**.
1414

@@ -28,7 +28,7 @@ This release is a big step forward, significantly improving the type safety of o
2828

2929
## Context
3030

31-
Atproto is an "open protocol" which means a lot of things. One of these things is that the data structures handled through the protocol are extensible. Lexicons (which is the syntax used to define the schema of the data structures) can be used to describe placeholders where arbitrary data types (defined through third party Lexicons) can be used.
31+
Atproto is an "open protocol" which means a lot of things. One of these things is that the data structures handled through the protocol are extensible. Lexicons (which is the syntax used to define the schema of the data structures) can be used to describe placeholders where arbitrary data types (defined through third-party Lexicons) can be used.
3232

3333
An example of such a placeholder exists in the Lexicon definition of a Bluesky post
3434
([`app.bsky.feed.post`](https://github.com/bluesky-social/atproto/blob/5ece8c6aeab9c5c3f51295d93ed6e27c3c6095c2/lexicons/app/bsky/feed/post.json#L5-L64)), which enables posts to have an `embed` property defined as follows:
@@ -46,7 +46,7 @@ An example of such a placeholder exists in the Lexicon definition of a Bluesky p
4646
}
4747
```
4848

49-
The type of the `embed` property is what is called an "open union". It means that the `embed` field can basically contain anything, although we usually expect it to be one of the known types defined in the `refs` array of the Lexicon schema (an image, a video, a link or another post).
49+
The type of the `embed` property is what is called an "open union". It means that the `embed` field can basically contain anything, although we usually expect it to be one of the known types defined in the `refs` array of the Lexicon schema (an image, a video, a link, or another post).
5050

5151
Systems consuming Bluesky posts need to be able to determine what type of embed they are dealing with. This is where the `$type` property comes in. This property allows systems to uniquely determine the Lexicon schema that must be used to interpret the data, and it **must** be provided everywhere a union is expected. For example, a post with a video would look like this:
5252

@@ -191,7 +191,7 @@ const recordWithMedia: $Typed<RecordWithMedia> = {
191191
}
192192
```
193193

194-
Because the `$type` property of objects is required in some contexts while optional in others, we introduced a new utility type to make it required when needed. The `$Typed` utility allows to mark an interface’s `$type` property non optional in contexts where it is required:
194+
Because the `$type` property of objects is required in some contexts while optional in others, we introduced a new utility type to make it required when needed. The `$Typed` utility allows marking an interface’s `$type` property non-optional in contexts where it is required:
195195

196196
```typescript
197197
export type $Typed<V> = V & { $type: string }
@@ -221,7 +221,7 @@ import { AppBskyFeedPost } from '@atproto/api'
221221
type BlueskyPost = AppBskyFeedPost.Main
222222

223223
// Say we got some random post somehow (typically
224-
// via an api call)
224+
// via an API call)
225225
declare const post: BlueskyPost
226226

227227
// And we want to know what kind of embed it contains
@@ -230,7 +230,7 @@ const { embed } = post
230230
// We can now use the `$type` property to disambiguate
231231
if (embed?.$type === 'app.bsky.embed.images') {
232232
// The `embed` variable is fully typed as
233-
// `$Typed<AppBskyEmbedImages.Main>` here !
233+
// `$Typed<AppBskyEmbedImages.Main>` here!
234234
}
235235
```
236236

@@ -248,7 +248,7 @@ export interface Main {
248248
[x: string]: unknown
249249
}
250250

251-
export function isMain(value: unknown): values is Main {
251+
export function isMain(value: unknown): value is Main {
252252
return (
253253
value != null &&
254254
typeof value === 'object' &&
@@ -311,7 +311,7 @@ declare const post: AppBskyEmbedImages.isMain
311311
// discriminate **valid** data based on their `$type`
312312
if (isImages(post.embed)) {
313313
// `post.embed` is fully typed as
314-
// `$Typed<AppBskyEmbedImages.Main>` here !
314+
// `$Typed<AppBskyEmbedImages.Main>` here!
315315
}
316316
```
317317

@@ -362,7 +362,7 @@ if (result.success) {
362362

363363
### New `asPredicate` function
364364

365-
The SDK exposes a new `asPredicate` function. This function allows to convert a `validate*` function into a predicate function. This can be useful when working with libraries that expect a predicate function to be passed as an argument.
365+
The SDK exposes a new `asPredicate` function. This function allows converting a `validate*` function into a predicate function. This can be useful when working with libraries that expect a predicate function to be passed as an argument.
366366

367367
```typescript
368368
import { AppBskyEmbedImages, asPredicate } from '@atproto/api'
@@ -402,7 +402,7 @@ const embed: AppBskyEmbedVideo.Main = {
402402
}
403403
```
404404

405-
We removed that signature, requiring any un-specified fields intentionally added to be now explicitly marked as such:
405+
We removed that signature, requiring any unspecified fields intentionally added to be now explicitly marked as such:
406406

407407
```typescript
408408
import { AppBskyEmbedVideo } from '@atproto/api'
@@ -415,7 +415,7 @@ const embed: AppBskyEmbedVideo.Main = {
415415
// error (a string is expected).
416416
alt: 123,
417417

418-
// Un-specified fields must now be explicitly
418+
// Unspecified fields must now be explicitly
419419
// marked as such:
420420

421421
// @ts-expect-error - custom field

0 commit comments

Comments
 (0)