Make identifier aliasing optional
Opened this issue · 1 comments
I found a couple of mentions of the intention of making branding optional, like #433 and #444. It doesn't look like it happened yet, but supplying a custom generateIdentifierType
is easy enough:
{
// ...
generateIdentifierType: (column, details, config) => {
const name = kanel.escapeIdentifier(
pascalCase(details.name) + pascalCase(column.name),
);
const configWithoutGenerateIdentifierType = { ...config };
delete configWithoutGenerateIdentifierType.generateIdentifierType;
const innerType = kanel.resolveType(
column,
details,
configWithoutGenerateIdentifierType,
);
return {
declarationType: 'typeDeclaration',
name,
exportAs: 'named',
typeDefinition: [
typeof innerType === 'string' ? innerType : innerType.name,
],
typeImports: typeof innerType === 'string' ? [] : innerType.typeImports,
comment: [`Identifier type for ${details.schemaName}.${details.name}`],
};
},
}
However, I would also like to take this a step further and drop identifier aliasing altogether, so that instead of this:
export type UsersId = string;
export default interface UsersTable {
id: ColumnType<UsersId, UsersId | undefined, UsersId>;
}
It's just this:
export default interface UsersTable {
id: ColumnType<string, string | undefined, string>;
}
Type-wise this doesn't get in the way, so this is a low-priority request, of course, but it would be nice to get rid of *Id
entries in code completion tooltips. This can probably be accomplished with a plugin, but the number of edge cases feels intimidating.
Yeah, this is something I probably need to do since it a popular and reasonable request. The problem is, as you are identifying, that there are many edge cases and combinations possible, so it's not quite as trivial as it sounds.