keveightysev / us-state-converter

An npm package to convert US state abbreviations to full names and back
MIT License
8 stars 5 forks source link

Typescript declaration is missing #4

Closed khitrenovich closed 2 months ago

khitrenovich commented 2 years ago

Providing TS declaration would help a lot in adoption.

This is the basic d.ts I've used internally -

// This is definitelty incomplete.
// For the full API, refer to https://github.com/keveightysev/us-state-converter/blob/master/README.md

declare module 'us-state-converter' {
  type StateInfo = {
    name: string;
    usps: string;
    demonym: string;
    iso: string;
    altAbbr: string[];
    uscg: string;
  };
  type Converter = (string) => StateInfo | undefined;
  const converter: Converter;
  export default converter;
}
tharinduAppno commented 2 years ago

thanks @khitrenovich and we can add other functions as well,

declare module 'us-state-converter' { type StateInfo = { name: string; usps: string; demonym: string; iso: string; altAbbr: string[]; uscg: string; }; type Converter = (string) => StateInfo | undefined; const converter: Converter; export function fullName(string): string {} export function abbr(string): string {} export default converter; } then import

import { fullName, abbr} from 'us-state-converter'

Dmitriyx commented 1 year ago

make pull request

FrenchMajesty commented 2 months ago

@keveightysev Any chance to have this merged in? Would be valuable for the community

keveightysev commented 2 months ago

@khitrenovich @tharinduAppno @Dmitriyx @FrenchMajesty

Apologies for the delay on getting this added. I just published an update to NPM with the declaration file