Skip to content

Add TypeScript type definitions #198

@konard

Description

@konard

Summary

Request to add TypeScript type definitions to the JavaScript package for better developer experience.

Background

When building links-queue, we use TypeScript for better type safety and developer tooling. Having TypeScript definitions for links-notation would enable:

  • IntelliSense/autocomplete in editors
  • Compile-time type checking
  • Better documentation of API through types

Desired Types

// Example of what would be helpful

export interface Link {
  id?: number;
  source: LinkRef;
  target: LinkRef;
}

export type LinkRef = number | string | Link;

export interface ParseOptions {
  strict?: boolean;
}

export interface FormatOptions {
  pretty?: boolean;
  indent?: string;
}

export function parse(notation: string, options?: ParseOptions): Link[];
export function format(links: Link | Link[], options?: FormatOptions): string;

Workaround

Currently, we can create local type definitions, but having official types would be better maintained and accurate.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions