You can pseudonize a type inside your component using an identical name:
type TDataSet = Db.TDataSet;
Whenever you drop your component on the form, Delphi must add its block to the uses clause. Then, regardless of whether you use Db in this form, a valid TDataSet equivalent to 1 << 21>.
Could there be any side effects / consequences / conflict problems for such type aliases?
In terms of language, no.
As a rule, it is not recommended to have types with the same name as this can cause problems when two pieces of code (sometimes even within the same device) seem to use the same type, but they are actually different types inside. However, in this case, the types are actually the same .
From the point of view of the IDE, not so much.
- An insignificant problem is that for “Declaration Search” in the IDE, an additional step is required to get the base type.
- Another problem is code completion. I experienced that some versions of Delphi will sometimes struggle with code completion when this slightly unusual
<unit-name>.<type-name> binding method is used. (I don’t remember how (or even if) Delphi 5 was affected.)
Are there other known components that use this trick?
I do not know any components using this technique. But I used aliasing for various reasons quite often. First of all, to avoid forced dependencies on client blocks.
source share