Closed

Description
Search Terms
Suggestion
Use Cases
current Partial<T>
will make all properties of T
optional
I want to specify only some properties of T
optional
Examples
interface Message {
mid: number;
content: string;
}
interface MessageOptional {
mid?: number;
content: string;
}
const message: Message = assembleMessage({ content: 'hello' })
function assembleMessage(message: MessageOptional) : Message{
const mid = ... // generate mid somehow
message.mid = mid
return message
}
it's very often sometimes we want to omit some properties of an object and later supplement it.
currently typescript has concepts like Intersection
、Union
, how about Complement
?
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)