red-blox / zap

A lightning fast networking solution for roblox.
https://zap.redblox.dev
MIT License
95 stars 16 forks source link

[BUG] TypeScript type generation should use `declare` keyword #71

Closed osyrisrblx closed 4 months ago

osyrisrblx commented 8 months ago

Describe the bug

Given an input like

opt typescript = true

event MyEvent = {
    from: Server,
    type: Reliable,
    call: ManyAsync,
    data: u8,
}

Zap will generate

// Server generated by Zap v0.6.1 (https://github.com/red-blox/zap)
export const MyEvent: {
    Fire: (Player: Player, Value: number) => void
    FireAll: (Value: number) => void
    FireExcept: (Except: Player, Value: number) => void
    FireList: (List: Player[], Value: number) => void
};

This is missing the declare keyword. Not technically a requirement, but good practice. TypeScript docs

Reproduction

playground link

Expected behavior

// Server generated by Zap v0.6.1 (https://github.com/red-blox/zap)
export declare const MyEvent: {
    Fire: (Player: Player, Value: number) => void
    FireAll: (Value: number) => void
    FireExcept: (Except: Player, Value: number) => void
    FireList: (List: Player[], Value: number) => void
};