Skip to content
Discussion options

You must be logged in to vote

With the latest 0.676 release, this should now be possible!

I wrote this type function to demonstrate:

type function TransformList(ty)
	if not ty:is("table") then
		error(`expected argument #1 to TransformList to be a table, got {ty.tag}`)
	end

	local resultTable = types.newtable()

	for key, value in ty:properties() do
		if value.read ~= value.write then
			error(`Key {key} had different read and write types, unknown what to do`)
		end

		resultTable:setproperty(key, Generic(value.read))
	end

	return resultTable
end

-- type TransformedList = { Example1: Generic<boolean> } now becomes
type TransformedList = TransformList<List>

-- TransformedList will be of type `{ Example1: { Value: b…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@quartz708
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by quartz708
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants