Use @deprecated attribute on typed functions

Hey guys,

I am wondering if we have a way to declare a typed function as @deprecated.

For example:

@[deprecated { use = "Moderation.banUserAsync(userId, reason, duration)"}]
local banUser: (userId: number, reason :string) -> boolean

Currently, to declare a normal function as @deprecated you’d do the following:

@[deprecated { use = "Moderation.banUserAsync(userId, reason, duration)"}]
local function banUser(userId: number, reason :string): boolean
  return true
end

I’m trying to build type definitions for my SDK I am working on, and would love to avoid having to create “fake” functions for it to work.

3 Likes

I guess you can do this?

type a = typeof(@deprecated function(a: number, b: string): boolean end)
local a: a
a()

local b: typeof(@deprecated function(a: number, b: string): boolean end)
b()

I found no other way

3 Likes

Ahh, nice idea. Though doesn’t seem to work in a ModuleScript for me.

1 Like

Probably a bug, I found an unconventional way

type test_1 = typeof((function()
  @deprecated
  local function _(a: number, b: string)
  end
  return _
end)())

local test_1: test_1 = nil :: any
test_1(1, "")

type test_2 = typeof((function()
  @deprecated function _(a: number, b: string)
  end
  return _
end)())

local test_2: test_2 = nil :: any
test_2(1, "")

Also --!strict seems to prioritize argument count versus --!nonstrict where it always give deprecated API

2 Likes

Definitely a very rough way, hope someone from ROBLOX can answer if we’ll be able to deprecate types.

1 Like