Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide TypeScript definitions #40

Open
ustun opened this issue Feb 18, 2022 · 4 comments
Open

Provide TypeScript definitions #40

ustun opened this issue Feb 18, 2022 · 4 comments

Comments

@ustun
Copy link

ustun commented Feb 18, 2022

Could you please provide TypeScript definitions either in the repo, or in DefinitelyTyped?

@phosfake
Copy link

phosfake commented May 2, 2022

I used the following typescript definition internally in my project. I extracted it from the Perl library docs that this package ports (Geo::StreetAddress::US)

Can we get some feedback from the contributors on the accuracy?
I'm willing to add this to DefinitelyTyped if we do. I had to comment out the "intersection specifier" because I wasn't sure if it was populated in this package.

declare module 'parse-address' {
  export function parseLocation(address: string): StreetAddress;

  export class StreetAddress {
    /**
     * House or street number.
     * @type {string}
     */
    number?: string;

    /**
     * Directional prefix for the street, such as N, NE, E, etc. A given prefix should be one to two characters long.
     * @type {string}
     */
    prefix?: string;

    /**
     * Name of the street, without directional or type qualifiers.
     * @type {string}
     */
    street?: string;

    /**
     * Abbreviated street type, e.g. Rd, St, Ave, etc. See the USPS official type abbreviations at http:https://pe.usps.com/text/pub28/pub28apc.html for a list of abbreviations used.
     * @type {string}
     */
    type?: string;

    /**
     * Directional suffix for the street, as above.
     * @type {string}
     */
    suffix?: string;

    /**
     * Name of the city, town, or other locale that the address is situated in.
     * @type {string}
     */
    city?: string;

    /**
     * The state which the address is situated in, given as its two-letter postal abbreviation. for a list of abbreviations used.
     * @type {string}
     */
    state?: string;

    /**
     * Five digit ZIP postal code for the address, including leading zero, if needed.
     * @type {string}
     */
    zip?: string;

    /**
     * If the address includes a Secondary Unit Designator, such as a room, suite or appartment, the sec_unit_type field will indicate the type of unit.
     * @type {string}
     */
    sec_unit_type?: string;

    /**
     * If the address includes a Secondary Unit Designator, such as a room, suite or appartment, the sec_unit_num field will indicate the number of the unit (which may not be numeric).
     * @type {string}
     */
    sec_unit_num?: string;

    // INTERSECTION_SPECIFIER
    // https://metacpan.org/release/TIMB/Geo-StreetAddress-US-1.04/view/US.pm#INTERSECTION-SPECIFIER

    // /**
    //  * Directional prefixes for the streets in question.
    //  * @type {string}
    //  */
    // prefix1?: string;

    // /**
    //  * Directional prefixes for the streets in question.
    //  * @type {string}
    //  */
    // prefix2?: string;

    // /**
    //  * Names of the streets in question.
    //  * @type {string}
    //  */
    // street1?: string;

    // /**
    //  * Names of the streets in question.
    //  * @type {string}
    //  */
    // street2?: string;

    // /**
    //  * Street types for the streets in question.
    //  * @type {string}
    //  */
    // type1?: string;

    // /**
    //  * Street types for the streets in question.
    //  * @type {string}
    //  */
    // type2?: string;

    // /**
    //  * Directional suffixes for the streets in question.
    //  * @type {string}
    //  */
    // suffix1?: string;

    // /**
    //  * Directional suffixes for the streets in question.
    //  * @type {string}
    //  */
    // suffix2?: string;

    // /**
    //  * City or locale containing the intersection, as above.
    //  * @type {string}
    //  */
    // city?: string;

    // /**
    //  * State abbreviation, as above.
    //  * @type {string}
    //  */
    // state?: string;

    // /**
    //  * Five digit ZIP code, as above.
    //  * @type {string}
    //  */
    // zip?: string;
  }
}

@serrg
Copy link

serrg commented Dec 1, 2022

@phosfake Are you planning to add above types to DefinitelyTyped?

@roofleDev
Copy link

A DefinitelyTyped package would be much appreciated

@draperj
Copy link

draperj commented Mar 31, 2023

Plus one to adding type file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants