You can alias the type within your component's unit using an identical name:
type
TDataSet = Db.TDataSet;
Whenever you drop your component on a form, Delphi should add its unit to the uses clause. Then whether or not you use Db
in that form, there's a valid TDataSet
equivalent to the one from Db
.
Could there be any side effects/implications/conflicts issues to such type aliasing?
From a language perspective, no.
Generally it's ill-advised to have types with the same name as this can cause problems when 2 pieces of code (sometimes even within the same unit) seem to use the same type, but they are actually different types internally. However, in this case the types are actually the same.
From an IDE perspective, not much.
- A minor issue is that "Find Declaration" in the IDE will require an extra step to reach the underlying type.
- The other issue is related to code completion. I have experienced that some versions of Delphi would occasionally struggle with code completion when this slightly unusual referencing technique
<unit-name>.<type-name>
is used. (I don't recall how (or even if) Delphi 5 was affected though.)
Are there any other known components that uses this trick?
I don't know of any components using the technique. But I've used aliasing for various reasons on quite a few occasions. Primarily just to avoid forcing knock-on dependencies on client units.