akebe / address-parse

🌏对国内地址地区进行智能解析,提取关键数据,如有识别不准的地址请Issues
MIT License
417 stars 149 forks source link

如何导入TS #46

Open babyba2009 opened 2 years ago

babyba2009 commented 2 years ago

如何导入Type Script?

Tithy commented 2 years ago

同求tyepscript类型定义文件

ouchuji commented 2 years ago
// @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]
}