address-parse icon indicating copy to clipboard operation
address-parse copied to clipboard

如何导入TS

Open babyba2009 opened this issue 3 years ago • 2 comments

如何导入Type Script?

babyba2009 avatar Sep 27 '21 14:09 babyba2009

同求tyepscript类型定义文件

Tithy avatar Nov 12 '21 03:11 Tithy

// @ts-ignore
import {ParseAddress} from 'address-parse'

const PARSER = new ParseAddress() as Parser

interface Parser {
    parse(content: string): readonly Address[]
}

export interface Address {
    readonly province: string
    readonly city: string
    readonly area: string
    readonly details: string
    readonly name: string
    readonly code: string,
    readonly mobile: string,
    readonly zip_code: string,
    readonly phone: string
}

export function parse(content: string): Address {
    return PARSER.parse(content)[0]
}

ouchuji avatar Jan 23 '22 06:01 ouchuji