-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Problem description:
The indexer definition [index: string]: unknown; on the IEntity
export interface IEntity {
id?: Guid | null;
logicalName: string;
[index: string]: unknown; // indexer here
formattedValues?: Dictionary<string>;
}
Is stopping usage of strongly type property pickers / intellisense
Minimal Example:
interface Person {
dateOfBirth: Date;
[index: string]: unknown; // comment out to get intellisense on line 7
}
const prop1: keyof Person = ""; // when indexer present => no intellisense
const prop2: keyof Person = ""; // when indexer removed => "dateOfBirth" present
Realistic use case:
export interface IEntity {
id?: Guid | null;
logicalName: string;
[index: string]: unknown; // indexer here
formattedValues?: Dictionary<string>;
}
export interface myOrg_Person extends IEntity {
myOrg_FirstName: string;
myOrg_DateOfBirth: string;
}
// any builder, schema definition, entity mapper, predicate function, property whitelisting
const p = create<myOrg_Person>()
.with("myOrg_FirstName", () => faker.person.firstname()) // intellisense due to with<T>(p: keyof T) {...}
.with("myOrg_DateOfBirth", () => faker.person.dob()) // intellisense
.build();
Questions
- Is this indexer actually used / needed ?
- Can it be done using
additionalProps: Map<string, unknown>;or similar container for dynamic properties? or an associated type for holding it? - What is the temporary solution to make
keyof Twork?
PS: Publisher prefixing sucks big time. Aliasing for prop name mapping or let the consumer take the risk of namespace collision.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels