knowbee / rwanda

🇷🇼This is a simple npm package that returns provinces, districts, sectors, villages and cells from Rwanda
https://www.npmjs.com/package/rwanda
MIT License
47 stars 20 forks source link

Add TypeScript Type Definitions #26

Open rukundo-kevin opened 1 year ago

rukundo-kevin commented 1 year ago

Hello,

The project currently lacks type definitions, and I'm willing to take on the task of creating them

songa1 commented 1 year ago

Wanted to say the same thing.

I am trying to use it in the Typescript App, but it lacks it. In the meantime, can you suggest another way to get Districts in Rwanda with Typescript? Or another package.

Thank you!

rukundo-kevin commented 1 year ago

Wanted to say the same thing.

I am trying to use it in the Typescript App, but it lacks it. In the meantime, can you suggest another way to get Districts in Rwanda with Typescript? Or another package.

Thank you!

I don't know another package with TS support but you can use these type definitions in your project.

declare module "rwanda" {
  export function Provinces(): string[];

  export function Districts(province?: string): string[] | undefined;

  export function Sectors(
    province?: string,
    district?: string
  ): string[] | undefined;

  export function Cells(
    province?: string,
    district?: string,
    sector?: string
  ): string[] | undefined;

  export function Villages(
    province?: string,
    district?: string,
    sector?: string,
    cell?: string
  ): string[] | undefined;
} 

Put them inside a file named rwanda.d.ts in your src or types directory

knowbee commented 1 year ago

@rukundo-kevin Go ahead, PRs are welcome

songa1 commented 1 year ago

Wanted to say the same thing. I am trying to use it in the Typescript App, but it lacks it. In the meantime, can you suggest another way to get Districts in Rwanda with Typescript? Or another package. Thank you!

I don't know another package with TS support but you can use these type definitions in your project.

declare module "rwanda" {
  export function Provinces(): string[];

  export function Districts(province?: string): string[] | undefined;

  export function Sectors(
    province?: string,
    district?: string
  ): string[] | undefined;

  export function Cells(
    province?: string,
    district?: string,
    sector?: string
  ): string[] | undefined;

  export function Villages(
    province?: string,
    district?: string,
    sector?: string,
    cell?: string
  ): string[] | undefined;
} 

Put them inside a file named rwanda.d.ts in your src or types directory

Thank you @rukundo-kevin

It is working well now!