Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Partial<T> where T has only optional members should not yield ... has no properties in common with type 'Partial<...>'error #20999

@JasonKleban

Description

@JasonKleban

tsc v2.6.2

Here's an example from jcormont/documentdb-typescript, Collection.d.ts in attempting to support this new ttl field:

storeDocumentAsync<T extends Partial<_DocumentDB.DocumentResource>>(data: T, mode?: StoreMode, maxRetries?: number, options?: AllOptions): Promise<T & _DocumentDB.DocumentResource>;

...

export interface DocumentResource extends Resource {
    ttl?: number;
}

If I opt NOT to include a ttl, I get [ts] Type 'MyDocument' has no properties in common with type 'Partial<DocumentResource>'.

const stored = await myDocuments.storeDocumentAsync(myDocument, StoreMode.CreateOnly);

I can work around it like this, but it is ugly:

const stored = await myDocuments.storeDocumentAsync({ ... myDocument, ttl: undefined }, StoreMode.CreateOnly);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions