Skip to content

Commit

Permalink
fix typing and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Dec 3, 2023
1 parent 9305930 commit fead976
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/tracing/span.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ declare namespace Span {
time: number;
elapsed: number;
}

export interface SpanServiceInfo {
name: string;
version?: string | number;
fullName?: string;
}
}

declare class Span {
Expand All @@ -42,11 +48,7 @@ declare class Span {
traceID: string;
parentID: string | null;

service?: {
name: string;
version?: string | number;
fullName?: string;
};
service: Span.SpanServiceInfo;

priority: number;
sampled: boolean;
Expand All @@ -56,7 +58,7 @@ declare class Span {
finishTime: number | null;
duration: number | null;

error: Error | null;
error: Error | boolean | null;

logs: Span.SpanLogEntry[];
tags: Record<string, any>;
Expand Down
13 changes: 13 additions & 0 deletions src/tracing/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function defProp(instance, propName, value, readOnly = false) {
* @typedef {import("./tracer")} Tracer
* @typedef {import("./span")} SpanClass
* @typedef {import("./span").SpanOptions} SpanOptions
* @typedef {import("./span").SpanServiceInfo} SpanServiceInfo
* @typedef {import("../logger-factory").Logger} Logger
*/

/**
Expand All @@ -32,6 +34,17 @@ function defProp(instance, propName, value, readOnly = false) {
* @implements {SpanClass}
*/
class Span {
/** @type {Tracer} */
tracer;
/** @type {SpanOptions} */
opts;
/** @type {Object} */
meta;
/** @type {Logger} */
logger;
/** @type {SpanServiceInfo} */
service;

/**
* Creates an instance of Span.
* @param {Tracer} tracer
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/tsd/ServiceActions.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ServiceSettingSchema,
} from "../../../index";

const broker = new ServiceBroker({ logger: false, transporter: "fake" });
const broker = new ServiceBroker({ logger: false, transporter: "Fake" });

class TestService extends Service {
constructor(broker: ServiceBroker) {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/tsd/ServiceSchema_lifecycles.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expectType } from "tsd";
import { Service, ServiceBroker, ServiceSchema } from "../../../index";

const broker = new ServiceBroker({ logger: false, transporter: "fake" });
const broker = new ServiceBroker({ logger: false, transporter: "Fake" });

class TestService1 extends Service {
constructor(broker: ServiceBroker) {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/tsd/ServiceSettings.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "../../../index";

// set up some test globals
const broker = new ServiceBroker({ logger: false, transporter: "fake" });
const broker = new ServiceBroker({ logger: false, transporter: "Fake" });
interface ExtendedSettings extends ServiceSettingSchema {
foo: string;
}
Expand Down

0 comments on commit fead976

Please sign in to comment.