type JsonType<T> = {
[P in keyof T as Exclude<P, "salt" | "hash">]: string;
};
type Test = {
salt: string;
hash: string;
};
const testObject: JsonType<Test> = {
hash: "...",
salt: "...",
};
I am puzzled as to why I am not receiving any errors when defining an object named testObject
of type JsonType<Test>
. Even though I excluded "salt" and "hash" from the type, I can still use them in an object when they should be considered invalid.
Even after trying the modified code below, the issue remains unresolved:
type JsonType<T> = {
[P in Exclude<keyof T, "salt" | "hash">]: string;
};