Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 11 additions & 8 deletions test/types/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,16 @@ const timerCallback = () => {};
// $ExpectType Timer
const timer = node.createTimer(BigInt(100000), timerCallback);

// $ExpectType number
// $ExpectType bigint
timer.period;

// $ExpectType boolean
timer.isReady();

// $ExpectType number
// $ExpectType bigint
timer.timeSinceLastCall();

// $ExpectType number
// $ExpectType bigint
timer.timeUntilNextCall();

// $ExpectType boolean
Expand Down Expand Up @@ -366,9 +366,12 @@ timer.cancel();
// $ExpectType Duration
const duration1: rclnodejs.Duration = new rclnodejs.Duration();

const duration2: rclnodejs.Duration = new rclnodejs.Duration(100, '1000');
const duration2: rclnodejs.Duration = new rclnodejs.Duration(
BigInt(100),
BigInt(1000)
);

// $ExpectType string | number
// $ExpectType bigint
duration1.nanoseconds;

// $ExpectType boolean
Expand All @@ -391,7 +394,7 @@ duration1.gte(duration2);

// ---- Time ----
// $ExpectType Time
const time1 = new rclnodejs.Time(100, 100);
const time1 = new rclnodejs.Time(BigInt(100), BigInt(100));

// $ExpectType Time
const time2 = rclnodejs.Time.fromMsg({ sec: 0, nanosec: 0 });
Expand All @@ -405,10 +408,10 @@ const time3 = rclnodejs.Time.fromMsg(
// $ExpectType ClockType
time1.clockType;

// $ExpectType string | number
// $ExpectType bigint
time1.nanoseconds;

// $ExpectType { seconds: number; nanoseconds: number; }
// $ExpectType { seconds: bigint; nanoseconds: bigint; }
time1.secondsAndNanoseconds;

// $ExpectType Time
Expand Down
7 changes: 3 additions & 4 deletions types/duration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ declare module 'rclnodejs' {
* @param seconds - The seconds component of the duration, default = 0.
* @param nanoseconds - The nanoseconds component of the duration, default = 0.
*/
constructor(seconds?: number | string, nanoseconds?: number | string);
constructor(seconds?: bigint, nanoseconds?: bigint);

/**
* Get the nanosecond component of the Duration.
*
* @returns The nanoseconds, if the value is greater than Number.MAX_SAFE_INTEGER (2^53-1),
* will be presented in a string of decimal format.
* @returns The nanoseconds.
*/
readonly nanoseconds: number | string;
readonly nanoseconds: bigint;

/**
* Test if this Duration is equal to another Duration.
Expand Down
12 changes: 3 additions & 9 deletions types/time.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ declare module 'rclnodejs' {
* @param nanoseconds - The nanoseconds component of the time, default = 0.
* @param clockType - The clock type, default = Clock.ClockType.SYSTEM_TIME
*/
constructor(
seconds?: number | string,
nanoseconds?: number | string,
clockType?: ClockType
);
constructor(seconds?: bigint, nanoseconds?: bigint, clockType?: ClockType);

/**
* Get the the clock type of the Time object.
Expand All @@ -27,15 +23,13 @@ declare module 'rclnodejs' {

/**
* Get the nanosecond part of the time.
* If the value is greater than Number.MAX_SAFE_INTEGER (2^53-1) it
* will be returned in a string of decimal format.
*/
readonly nanoseconds: number | string;
readonly nanoseconds: bigint;

/**
* Get the time as a plain JavaScript object.
*/
readonly secondsAndNanoseconds: { seconds: number; nanoseconds: number };
readonly secondsAndNanoseconds: { seconds: bigint; nanoseconds: bigint };

/**
* Add a duration to this time object.
Expand Down
12 changes: 6 additions & 6 deletions types/timer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ declare module 'rclnodejs' {
*/
interface Timer {
/**
* Time between callbacks in milliseconds.
* Time between callbacks in nanoseconds.
*/
readonly period: number;
readonly period: bigint;

/**
* Check if the timer is ready.
Expand Down Expand Up @@ -35,15 +35,15 @@ declare module 'rclnodejs' {
/**
* Get the interval since the last call of this timer.
*
* @returns The interval value in milliseconds.
* @returns The interval value in nanoseconds.
*/
timeSinceLastCall(): number;
timeSinceLastCall(): bigint;

/**
* Get the interval until the next call will happen.
*
* @returns The interval value in milliseconds
* @returns The interval value in nanoseconds
*/
timeUntilNextCall(): number;
timeUntilNextCall(): bigint;
}
}
Loading