Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: types #476

Merged
merged 4 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ jobs:
run: npm i
- name: Test
run: npm t
- name: Check types
run: npm run check-types
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
types/test/
joscha marked this conversation as resolved.
Show resolved Hide resolved
56 changes: 55 additions & 1 deletion package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,21 @@
"node": ">=6.0.0"
},
"scripts": {
"check-types": "tsc --strict --noEmit types/test/*.ts",
"clean": "rm -rf coverage node_modules",
"cover": "nyc mocha -- --ui tdd",
"lint": "eslint etc/ lib/ test/ \"etc/scripts/**\"",
"perf": "node --expose-gc ./etc/scripts/perf etc/schemas/*",
"test": "mocha --ui tdd --reporter dot"
},
"devDependencies": {
"@types/node": "^22.5.5",
joscha marked this conversation as resolved.
Show resolved Hide resolved
"benchmark": "~2.1.4",
"eslint": "^8.30.0",
"mocha": "^10.2.0",
"nyc": "~15.0.0",
"tmp": "^0.1.0"
"tmp": "^0.1.0",
"typescript": "^5.6.2"
},
"author": {
"name": "Matthieu Monsch",
Expand Down
5 changes: 2 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
// `any` is appropriate.

import * as stream from 'stream';
import { EventEmitter } from 'events';

//"virtual" namespace (no JS, just types) for Avro Schema
declare namespace schema {
export type AvroSchema = DefinedType | DefinedType[] | Type | Type[];
type DefinedType = PrimitiveType | ComplexType | LogicalType | string;
export type AvroSchema = DefinedType | DefinedType[];
type DefinedType = PrimitiveType | ComplexType | LogicalType | Type | string;
mtth marked this conversation as resolved.
Show resolved Hide resolved
type PrimitiveType = 'null' | 'boolean' | 'int' | 'long' | 'float' | 'double' | 'bytes' | 'string';
type ComplexType = NamedType | RecordType | EnumType | MapType | ArrayType | FixedType;
type LogicalType = ComplexType & LogicalTypeExtension;
Expand Down
15 changes: 15 additions & 0 deletions types/test/461.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as Avro from '../index'

const e = Avro.Type.forSchema({
name: "enum",
type: "enum",
symbols: ["foo", "bar", "baz"],
});

const record = Avro.Type.forSchema({
name: "record",
type: "record",
fields: [
{ name: "enum", type: ["null", e], default: null },
],
});
joscha marked this conversation as resolved.
Show resolved Hide resolved
Loading