Skip to content

Commit

Permalink
Improve codegen typings (#2999)
Browse files Browse the repository at this point in the history
* Make codegen types stricter
* Add .js file extension to import statements in generated code
* Fixes a bug that would clear interests prefs when updating hidden posts prefs.
  • Loading branch information
matthieusieben authored Feb 13, 2025
1 parent f90eedc commit c53d943
Show file tree
Hide file tree
Showing 1,014 changed files with 17,461 additions and 14,622 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-trees-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/api": patch
---

Fixes a bug that would clear interests prefs when updating hidden posts
10 changes: 10 additions & 0 deletions .changeset/brown-flies-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@atproto/ozone": patch
"@atproto/bsky": patch
"@atproto/api": minor
"@atproto/pds": patch
---

Update Lexicon derived code to better reflect data typings. In particular, Lexicon derived interfaces will now explicitly include the `$type` property that can be present in the data.


5 changes: 5 additions & 0 deletions .changeset/fast-points-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/syntax": patch
---

Improve performance of isValidTid
5 changes: 5 additions & 0 deletions .changeset/fast-waves-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lex-cli": minor
---

Update the code generation to better reflect the data typings. In particular this change will cause generated code to explicit the `$type` property that can be present in the data.
5 changes: 5 additions & 0 deletions .changeset/green-cherries-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/pds": patch
---

Minor typing fixes
5 changes: 5 additions & 0 deletions .changeset/green-forks-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/api": minor
---

Helper functions (e.g. `NS.isRecord`) no longer casts the output value. Use `asPredicate(NS.validateRecord)` to create a predicate function that will ensure that an unknown value is indeed an `NS.Record`. The `isX` helper function's purpose is to discriminate between `$type`d values from unions.
5 changes: 5 additions & 0 deletions .changeset/late-worms-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lex-cli": patch
---

Add `.js` file extension to `import` statements in generated code.
5 changes: 5 additions & 0 deletions .changeset/popular-shirts-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lexicon": patch
---

Various performance improvements
5 changes: 5 additions & 0 deletions .changeset/shiny-suns-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lex-cli": patch
---

Type the generated `ids` object (that contains all the lexicon namespace ids) as `const`.
5 changes: 5 additions & 0 deletions .changeset/silly-starfishes-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lexicon": patch
---

Fully type `ValidationResult`'s `value` property, allowing `NS.validateMyType` helper functions to return a typed value in case of success.
5 changes: 5 additions & 0 deletions .changeset/spotty-bottles-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lex-cli": minor
---

Remove `[string]: unknown` index signature from custom user objects, input and output schemas.
5 changes: 5 additions & 0 deletions .changeset/tiny-carpets-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/lex-cli": patch
---

Ensures that empty `schemas` arrays are typed as `LexiconDoc[]`.
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ pnpm-lock.yaml
.pnpm*
.changeset
CHANGELOG.md

# Prettier is used to format the code during codegen
packages/api/src/client
packages/bsky/src/lexicon
packages/pds/src/lexicon
packages/ozone/src/lexicon
1 change: 1 addition & 0 deletions packages/api/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ module.exports = {
testTimeout: 60000,
setupFiles: ['<rootDir>/../../jest.setup.ts'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleNameMapper: { '^(\\.\\.?\\/.+)\\.js$': ['$1.ts', '$1.js'] },
}
Loading

0 comments on commit c53d943

Please sign in to comment.