Skip to content

Commit

Permalink
Fix omit and intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasavila00 committed Dec 14, 2024
1 parent 95620e9 commit f1b6322
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 9 deletions.
8 changes: 8 additions & 0 deletions e2e-tests/standalone-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# node-server

## 1.0.61

### Patch Changes

- Updated dependencies
- @beff/cli@0.0.63
- @beff/client@0.0.64

## 1.0.60

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/standalone-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "standalone-parser",
"version": "1.0.60",
"version": "1.0.61",
"description": "",
"main": "index.js",
"scripts": {
Expand All @@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@beff/cli": "workspace:^0.0.62",
"@beff/cli": "workspace:^0.0.63",
"@beff/client": "workspace:^",
"vitest": "^0.34.4",
"zod": "^3.23.5"
Expand Down
6 changes: 6 additions & 0 deletions packages/beff-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @beff/cli

## 0.0.63

### Patch Changes

- fix omit and intersection

## 0.0.62

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/beff-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beff/cli",
"version": "0.0.62",
"version": "0.0.63",
"description": "",
"bin": {
"beff": "./bin/index.js"
Expand Down
8 changes: 8 additions & 0 deletions packages/beff-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @beff/client

## 0.0.64

### Patch Changes

- fix omit and intersection
- Updated dependencies
- @beff/cli@0.0.63

## 0.0.63

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/beff-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beff/client",
"version": "0.0.63",
"version": "0.0.64",
"description": "",
"main": "dist/cjs/index.js",
"scripts": {
Expand All @@ -20,7 +20,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@beff/cli": "workspace:^0.0.62",
"@beff/cli": "workspace:^0.0.63",
"zod": "^3.23.5"
},
"devDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions packages/beff-core/src/type_to_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ impl<'a, 'b, R: FileManager> TypeToSchema<'a, 'b, R> {
_ => self.error(span, DiagnosticInfoMessage::ShouldHaveObjectAsTypeArgument),
}
}
JsonSchema::AllOf(vs) => {
let mut acc = BTreeMap::new();

for v in vs {
let extracted = self.extract_object(v, span)?;
acc.extend(extracted);
}

Ok(acc)
}
_ => self.error(span, DiagnosticInfoMessage::ShouldHaveObjectAsTypeArgument),
}
}
Expand Down
11 changes: 11 additions & 0 deletions packages/beff-core/tests/print_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,17 @@ mod tests {
export type ABC = {}
export type KABC = keyof ABC
parse.buildParsers<{ KABC: KABC }>();
"#));
}
#[test]
fn ok_omit_intersection() {
insta::assert_snapshot!(ok(r#"
export type A = {a: string}
export type B = {b: string}
export type KABC = Omit<A & B, 'a'>
parse.buildParsers<{ KABC: KABC }>();
"#));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: packages/beff-core/tests/print_parser.rs
assertion_line: 630
expression: "ok(r#\"\n export type A = {a: string}\n export type B = {b: string}\n\n export type KABC = Omit<A & B, 'a'>\n \n parse.buildParsers<{ KABC: KABC }>();\n \"#)"
---
type A = { "a": string };
type B = { "b": string };
type KABC = { "b": string };
type KABC = KABC;

2 changes: 1 addition & 1 deletion packages/beff-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@babel/code-frame": "^7.22.13",
"@beff/cli": "workspace:^0.0.62",
"@beff/cli": "workspace:^0.0.63",
"@types/babel__code-frame": "^7.0.4",
"@types/node": "^20.6.2",
"@types/vscode": "^1.73.0",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f1b6322

Please sign in to comment.