Help with Types

How do you make them stop being orange? (Code works fine I just find this annoying)

export type Logger = {
    newLog: (self: any, message: string, important: boolean?) -> (),
}

export type Notifications = {
    create: (Player: Player, message: string) -> (),
}

export type Server = {

    JoinPlayer: (senderId: number, userId: number) -> (),
    Shutdown: () -> (),
    Migrate: () -> (),
    UniversalShutdown: () -> (),
    UniversalMigrate : () -> (),
    Lock : (rank: Instance) -> (),
    Announce : (sender: Player | number, message: string) -> (),
    UniversalAnnounce : (sender: Player, message: string) -> (),
    Unlock : () -> (),
    UniversalLock : (rank: Instance) -> (),
    UniversalUnlock : () -> (),

} 

export type Data = {

    UpdateValue : ( valueName : (any) , newValue : (any) , player : Player ) -> (),
    ReturnValue : ( valueName : (any), player : Player ) -> (),

}

export type BanHandler = {

    IsBanned : (Player: number | string) -> (),
    PermBan : (Player: Player, Reason: string) -> (),
    TimeBan : (Player: Player, Reason: string, Duration: number) -> (),
    ServerBan : (Player: Player, Reason: string) -> (),
    UnBan : (Player : Player ) -> (),

}

export type WarningHandler = {

    Warn : ( Player : Player, Reason : string, Admin : Player) -> (),
    GetWarningsByUserId : ( Player : Player | number ) -> (),
    ClearAllWarnings : ( Player : Player | number ) -> (),

}

export type Core = {
    File: Instance,
    Client: Instance,
    Logger: Logger,
    Notifications: Notifications,
    Server: Server,
    Data: Data,
    BanHandler: BanHandler,
    WarningHandler:  WarningHandler,
    
    ProtectedRun: (thread: () -> ()) -> (),
    AdminCount: () -> number,

}

return {

    Logger = Logger,
    Notifications = Notifications,
    Server = Server,
    Data = Data,
    BanHandler = BanHandler,
    WarningHandler = WarningHandler,

    Core = Core,
}

2 Likes

just hover on them

1 Like

The issue is that you can’t set types as variables so that’s not possible (Atleast from my knowledge)

oh, but variables you set are not defined still.

type infer doesn’t start with = symbol in luau, but : instead. and besides local variables i don’t see how it’s possible to infer them without “typecast”.

so you have to write smth like Logger = {} :: Logger to make it work, or {Logger = nil} :: {Logger: Logger} should work too

1 Like

I’ll have a look at this tomorrow thank you :blue_heart:

WAIT. you probably want to use types from a module you require. then you don’t have to write anything else, export will already return your types. just return an empty table, you’re good

1 Like

Oh, that’s great :joy:, I’ll give that a try tomorrow

1 Like

Thank you so much for the help :blue_heart:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.