Skip to content

Commit

Permalink
feat: Bump ts-poet for dprint, also use tsx (#660)
Browse files Browse the repository at this point in the history
* feat: Bump ts-poet for dprint.

* Use tsx instead of ts-node.

* Use preferSingleLine.
  • Loading branch information
stephenh committed Aug 27, 2022
1 parent b4a398e commit 348a465
Show file tree
Hide file tree
Showing 175 changed files with 10,279 additions and 11,552 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
- name: install dependencies
run: yarn install || echo "ignore failure"
- name: Prettier
run: yarn prettier:check
run: yarn format:check
env:
CI: true
6 changes: 2 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"printWidth": 120,
"bracketSpacing": true,
"singleQuote": true
}
"printWidth": 120
}
22 changes: 7 additions & 15 deletions integration/angular/simple-message.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
import * as _m0 from 'protobufjs/minimal';
import * as _m0 from "protobufjs/minimal";

export const protobufPackage = 'angular';
export const protobufPackage = "angular";

export interface SimpleMessage {
numberField: number;
Expand Down Expand Up @@ -38,9 +38,7 @@ export const SimpleMessage = {
},

fromJSON(object: any): SimpleMessage {
return {
numberField: isSet(object.numberField) ? Number(object.numberField) : 0,
};
return { numberField: isSet(object.numberField) ? Number(object.numberField) : 0 };
},

toJSON(message: SimpleMessage): unknown {
Expand All @@ -58,19 +56,13 @@ export const SimpleMessage = {

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin
? T
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
export type DeepPartial<T> = T extends Builtin ? T
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

function isSet(value: any): boolean {
Expand Down
42 changes: 17 additions & 25 deletions integration/async-iterable-services/simple.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* eslint-disable */
import * as _m0 from 'protobufjs/minimal';
import * as _m0 from "protobufjs/minimal";

export const protobufPackage = 'simple';
export const protobufPackage = "simple";

/** EchoMsg is the message body for Echo. */
export interface EchoMsg {
body: string;
}

function createBaseEchoMsg(): EchoMsg {
return { body: '' };
return { body: "" };
}

export const EchoMsg = {
encode(message: EchoMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.body !== '') {
if (message.body !== "") {
writer.uint32(10).string(message.body);
}
return writer;
Expand All @@ -41,7 +41,7 @@ export const EchoMsg = {
// encodeTransform encodes a source of message objects.
// Transform<EchoMsg, Uint8Array>
async *encodeTransform(
source: AsyncIterable<EchoMsg | EchoMsg[]> | Iterable<EchoMsg | EchoMsg[]>
source: AsyncIterable<EchoMsg | EchoMsg[]> | Iterable<EchoMsg | EchoMsg[]>,
): AsyncIterable<Uint8Array> {
for await (const pkt of source) {
if (Array.isArray(pkt)) {
Expand All @@ -57,7 +57,7 @@ export const EchoMsg = {
// decodeTransform decodes a source of encoded messages.
// Transform<Uint8Array, EchoMsg>
async *decodeTransform(
source: AsyncIterable<Uint8Array | Uint8Array[]> | Iterable<Uint8Array | Uint8Array[]>
source: AsyncIterable<Uint8Array | Uint8Array[]> | Iterable<Uint8Array | Uint8Array[]>,
): AsyncIterable<EchoMsg> {
for await (const pkt of source) {
if (Array.isArray(pkt)) {
Expand All @@ -71,9 +71,7 @@ export const EchoMsg = {
},

fromJSON(object: any): EchoMsg {
return {
body: isSet(object.body) ? String(object.body) : '',
};
return { body: isSet(object.body) ? String(object.body) : "" };
},

toJSON(message: EchoMsg): unknown {
Expand All @@ -84,7 +82,7 @@ export const EchoMsg = {

fromPartial<I extends Exact<DeepPartial<EchoMsg>, I>>(object: I): EchoMsg {
const message = createBaseEchoMsg();
message.body = object.body ?? '';
message.body = object.body ?? "";
return message;
},
};
Expand Down Expand Up @@ -112,25 +110,25 @@ export class EchoerClientImpl implements Echoer {
}
Echo(request: EchoMsg): Promise<EchoMsg> {
const data = EchoMsg.encode(request).finish();
const promise = this.rpc.request('simple.Echoer', 'Echo', data);
const promise = this.rpc.request("simple.Echoer", "Echo", data);
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
}

EchoServerStream(request: EchoMsg): AsyncIterable<EchoMsg> {
const data = EchoMsg.encode(request).finish();
const result = this.rpc.serverStreamingRequest('simple.Echoer', 'EchoServerStream', data);
const result = this.rpc.serverStreamingRequest("simple.Echoer", "EchoServerStream", data);
return EchoMsg.decodeTransform(result);
}

EchoClientStream(request: AsyncIterable<EchoMsg>): Promise<EchoMsg> {
const data = EchoMsg.encodeTransform(request);
const promise = this.rpc.clientStreamingRequest('simple.Echoer', 'EchoClientStream', data);
const promise = this.rpc.clientStreamingRequest("simple.Echoer", "EchoClientStream", data);
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
}

EchoBidiStream(request: AsyncIterable<EchoMsg>): AsyncIterable<EchoMsg> {
const data = EchoMsg.encodeTransform(request);
const result = this.rpc.bidirectionalStreamingRequest('simple.Echoer', 'EchoBidiStream', data);
const result = this.rpc.bidirectionalStreamingRequest("simple.Echoer", "EchoBidiStream", data);
return EchoMsg.decodeTransform(result);
}
}
Expand All @@ -142,25 +140,19 @@ interface Rpc {
bidirectionalStreamingRequest(
service: string,
method: string,
data: AsyncIterable<Uint8Array>
data: AsyncIterable<Uint8Array>,
): AsyncIterable<Uint8Array>;
}

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin
? T
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
export type DeepPartial<T> = T extends Builtin ? T
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

function isSet(value: any): boolean {
Expand Down
4 changes: 2 additions & 2 deletions integration/avoid-import-conflicts-types-only/simple.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
import type { SimpleEnum as SimpleEnum1, Simple as Simple2 } from './simple2';
import type { Simple as Simple2, SimpleEnum as SimpleEnum1 } from "./simple2";

export const protobufPackage = 'simple';
export const protobufPackage = "simple";

export enum SimpleEnum {
LOCAL_DEFAULT = 0,
Expand Down
2 changes: 1 addition & 1 deletion integration/avoid-import-conflicts-types-only/simple2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
export const protobufPackage = 'simple2';
export const protobufPackage = "simple2";

export enum SimpleEnum {
IMPORT_DEFAULT = 0,
Expand Down
67 changes: 28 additions & 39 deletions integration/avoid-import-conflicts/simple.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint-disable */
import {
SimpleEnum as SimpleEnum1,
FooService as FooService2,
fooServiceFromJSON,
fooServiceToJSON,
Simple as Simple3,
SimpleEnum as SimpleEnum1,
simpleEnumFromJSON as simpleEnumFromJSON4,
simpleEnumToJSON as simpleEnumToJSON5,
fooServiceFromJSON,
fooServiceToJSON,
} from './simple2';
import * as _m0 from 'protobufjs/minimal';
} from "./simple2";
import * as _m0 from "protobufjs/minimal";

export const protobufPackage = 'simple';
export const protobufPackage = "simple";

export enum SimpleEnum {
LOCAL_DEFAULT = 0,
Expand All @@ -22,16 +22,16 @@ export enum SimpleEnum {
export function simpleEnumFromJSON(object: any): SimpleEnum {
switch (object) {
case 0:
case 'LOCAL_DEFAULT':
case "LOCAL_DEFAULT":
return SimpleEnum.LOCAL_DEFAULT;
case 1:
case 'LOCAL_FOO':
case "LOCAL_FOO":
return SimpleEnum.LOCAL_FOO;
case 2:
case 'LOCAL_BAR':
case "LOCAL_BAR":
return SimpleEnum.LOCAL_BAR;
case -1:
case 'UNRECOGNIZED':
case "UNRECOGNIZED":
default:
return SimpleEnum.UNRECOGNIZED;
}
Expand All @@ -40,14 +40,14 @@ export function simpleEnumFromJSON(object: any): SimpleEnum {
export function simpleEnumToJSON(object: SimpleEnum): string {
switch (object) {
case SimpleEnum.LOCAL_DEFAULT:
return 'LOCAL_DEFAULT';
return "LOCAL_DEFAULT";
case SimpleEnum.LOCAL_FOO:
return 'LOCAL_FOO';
return "LOCAL_FOO";
case SimpleEnum.LOCAL_BAR:
return 'LOCAL_BAR';
return "LOCAL_BAR";
case SimpleEnum.UNRECOGNIZED:
default:
return 'UNRECOGNIZED';
return "UNRECOGNIZED";
}
}

Expand All @@ -70,12 +70,12 @@ export interface FooServiceCreateResponse {
}

function createBaseSimple(): Simple {
return { name: '', otherSimple: undefined };
return { name: "", otherSimple: undefined };
}

export const Simple = {
encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.name !== '') {
if (message.name !== "") {
writer.uint32(10).string(message.name);
}
if (message.otherSimple !== undefined) {
Expand Down Expand Up @@ -107,7 +107,7 @@ export const Simple = {

fromJSON(object: any): Simple {
return {
name: isSet(object.name) ? String(object.name) : '',
name: isSet(object.name) ? String(object.name) : "",
otherSimple: isSet(object.otherSimple) ? Simple3.fromJSON(object.otherSimple) : undefined,
};
},
Expand All @@ -122,11 +122,10 @@ export const Simple = {

fromPartial<I extends Exact<DeepPartial<Simple>, I>>(object: I): Simple {
const message = createBaseSimple();
message.name = object.name ?? '';
message.otherSimple =
object.otherSimple !== undefined && object.otherSimple !== null
? Simple3.fromPartial(object.otherSimple)
: undefined;
message.name = object.name ?? "";
message.otherSimple = (object.otherSimple !== undefined && object.otherSimple !== null)
? Simple3.fromPartial(object.otherSimple)
: undefined;
return message;
},
};
Expand Down Expand Up @@ -220,9 +219,7 @@ export const FooServiceCreateRequest = {
},

fromJSON(object: any): FooServiceCreateRequest {
return {
kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0,
};
return { kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0 };
},

toJSON(message: FooServiceCreateRequest): unknown {
Expand Down Expand Up @@ -269,9 +266,7 @@ export const FooServiceCreateResponse = {
},

fromJSON(object: any): FooServiceCreateResponse {
return {
kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0,
};
return { kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0 };
},

toJSON(message: FooServiceCreateResponse): unknown {
Expand Down Expand Up @@ -299,7 +294,7 @@ export class FooServiceClientImpl implements FooService {
}
Create(request: FooServiceCreateRequest): Promise<FooServiceCreateResponse> {
const data = FooServiceCreateRequest.encode(request).finish();
const promise = this.rpc.request('simple.FooService', 'Create', data);
const promise = this.rpc.request("simple.FooService", "Create", data);
return promise.then((data) => FooServiceCreateResponse.decode(new _m0.Reader(data)));
}
}
Expand All @@ -310,19 +305,13 @@ interface Rpc {

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin
? T
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
export type DeepPartial<T> = T extends Builtin ? T
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

function isSet(value: any): boolean {
Expand Down
Loading

0 comments on commit 348a465

Please sign in to comment.