pcoet commented on code in PR #22316:
URL: https://github.com/apache/beam/pull/22316#discussion_r923915280
##########
sdks/typescript/src/apache_beam/coders/standard_coders.ts:
##########
@@ -28,52 +28,44 @@ import {
} from "./coders";
import { BytesCoder, InstantCoder } from "./required_coders";
import Long from "long";
-import {
- Window,
- Instant,
- IntervalWindow,
- KV,
- PaneInfo,
- Timing,
- WindowedValue,
-} from "../values";
+import { IntervalWindow } from "../values";
// Historical
export * from "./required_coders";
/**
* @fileoverview Defines all of the Apache Beam standard coders.
*
- * Beyond required coders, standard coders provide a efficient ways of encode
+ * Beyond required coders, standard coders provide an efficient way to encode
* data for communication between the runner and various Beam workers for
* types that commonly cross process boundaries. Though none of these coders
- * are strictly necessary, if encodings are given for these types it is highly
+ * is strictly necessary, if encodings are given for these types it is highly
* advised to use these definitions that are interoperable with runners and
* other SDKs.
*
- * For schema-aware transforms RowCoder, which is a coder for rows of data
- * with a predetermined schema, is also advised.
+ * For the schema-aware transform RowCoder, which is a coder for rows of data
+ * with a predetermined schema, it is also advised.
*
* The formal specifications for these coders can be found in
* model/pipeline/src/main/proto/beam_runner_api.proto
*/
-export class StrUtf8Coder implements Coder<String> {
- static URN: string = "beam:coder:string_utf8:v1";
- type: string = "stringutf8coder";
+export class StrUtf8Coder implements Coder<string> {
+ static URN = "beam:coder:string_utf8:v1";
+ type = "stringutf8coder";
encoder = new TextEncoder();
decoder = new TextDecoder();
- encode(element: String, writer: Writer, context: Context) {
- const encodedElement = this.encoder.encode(element as string);
+ encode(element: string, writer: Writer, context: Context) {
+ const encodedElement = this.encoder.encode(element);
BytesCoder.INSTANCE.encode(encodedElement, writer, context);
}
- decode(reader: Reader, context: Context): String {
+ decode(reader: Reader, context: Context): string {
return this.decoder.decode(BytesCoder.INSTANCE.decode(reader, context));
}
- toProto(pipelineContext: ProtoContext): runnerApi.Coder {
+ toProto(): runnerApi.Coder {
Review Comment:
It will work, because `toProto()` is assignable to `toProto(pipelineContext:
ProtoContext)` in TypeScript. See [this
doc](https://www.typescriptlang.org/docs/handbook/type-compatibility.html#comparing-two-functions)
and this example:
```typescript
let x = (a: number) => 0;
let y = (b: number, s: string) => 0;
y = x; // OK
x = y; // Error
```
We could use an underscore (`_pipelineContext: ProtoContext`) for
documentation, but it wouldn't make the code more correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]