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

關於Typescript 支援 #121

Open
mxt305 opened this issue Jul 21, 2022 · 4 comments
Open

關於Typescript 支援 #121

mxt305 opened this issue Jul 21, 2022 · 4 comments

Comments

@mxt305
Copy link

mxt305 commented Jul 21, 2022

因為缺乏index.d.ts的定義檔案,因此沒辦法在ts的專案中直接使用。
所以個人弄了一個Typescipt相關的定義檔按給大家參考,如果沒問題的話我再送PR。

declare module "twzipcode-data" {
    export interface County {
        id: string;
        name: string;
    }
    export interface Zipcode {
        id: string;
        zipcode: number;
        county: string;
        city: string;
    }

    export interface TwZipcodeData {
        counties: County[];
        zipcodes: Zipcode[];
    }

    export default twzipcode = (locale?: string) => TwZipcodeData;
}
@mxt305 mxt305 changed the title Typescript 支援 關於Typescript 支援 Jul 21, 2022
@yyc1217
Copy link
Owner

yyc1217 commented Jul 21, 2022

@mxt305 您好
因為這個套件久未整理
請待我處理目前的PR,以及將支援的node版本提升到16後再發PR
謝謝

@yyc1217
Copy link
Owner

yyc1217 commented Jul 21, 2022

@mxt305 您好,我已整理完畢

@mxt305
Copy link
Author

mxt305 commented Jul 22, 2022

@yyc1217 已建立PR,請確認
註:放在套件內的d.ts檔案外層不需要再包一層declare module

@mxt305
Copy link
Author

mxt305 commented Mar 14, 2023

除了測試腳本外,試著把src底下的js全部轉成ts並導入typescript
有需要可以參考 https://github.com/mxt305/twzipcode-data/tree/typescript

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

2 participants