You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently constants are marked as any and declared with let and after browsing the source they appear to be of either number or string mostly, as well as indeed const. The docs themselves do not directly inform if they are a number or a string constant, however it is not entirely important to type as they are exposed to lua from the C++ API.
In order to provide some additional TypeScript type safeness we could brand each constant per module so you do not use the wrong constant in the wrong namespace...
We could parse the docs for the use of the constant, and read the type from the call site, as so far it appears the constants at the call site are referred to as either a number i,e resource.set_texture(path,table,buffer), a constant i.e resource.store_manifest() a constant | vector i.e. go.animate().
In the case of go.animate() the types are not directly called out and we would need to rely on some pattern matching. The parameter is named easing it is a constant | vector and we have constants that start with the name EASING_...
The parser may need to be extended to store some additional context so that the generator can run some generation against the function calls in the module to determine naming convention and type.
Alternatively, constants could just be declared as constants scoped to the namespace, and the callsite itself go be modified when a number, vector, or some other constant type is presented to take either a scoped constant like ResourceConstant | type.
The text was updated successfully, but these errors were encountered:
Currently constants are marked as
any
and declared withlet
and after browsing the source they appear to be of either number or string mostly, as well as indeedconst
. The docs themselves do not directly inform if they are a number or a string constant, however it is not entirely important to type as they are exposed to lua from the C++ API.In order to provide some additional TypeScript type safeness we could brand each constant per module so you do not use the wrong constant in the wrong namespace...
We could parse the docs for the use of the constant, and read the type from the call site, as so far it appears the constants at the call site are referred to as either a
number
i,eresource.set_texture(path,table,buffer)
, aconstant
i.eresource.store_manifest()
aconstant | vector
i.e.go.animate()
.In the case of
go.animate()
the types are not directly called out and we would need to rely on some pattern matching. The parameter is namedeasing
it is aconstant | vector
and we have constants that start with the nameEASING_
...The parser may need to be extended to store some additional context so that the generator can run some generation against the function calls in the module to determine naming convention and type.
Alternatively, constants could just be declared as constants scoped to the namespace, and the callsite itself go be modified when a number, vector, or some other constant type is presented to take either a scoped constant like
ResourceConstant
|type
.The text was updated successfully, but these errors were encountered: