type-fest icon indicating copy to clipboard operation
type-fest copied to clipboard

PartialDeep should skip HTMLCanvasElement

Open tjx666 opened this issue 1 year ago • 5 comments

import type { PartialDeep } from 'type-fest';

export interface TextElement {
    canvas: HTMLCanvasElement;
}

const a: PartialDeep<TextElement> = {} as TextElement;

image

versions:

ts: 5.1.6
type-fest: 4.0

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

tjx666 avatar Jul 24 '23 02:07 tjx666

help ~ how solve the question?

icyfe avatar Jul 24 '23 03:07 icyfe

@sindresorhus Anther way, maybe we should not skip HTMLCanvasElement? PartialDeep<{a: HTMLCanvasElement}>['a'] is equal to Partial<HTMLCanvasElement>, look like is a normal behavior.

If need, we can add option to specify the non-recursive or impartible type to be skiped in deep-type.

Emiyaaaaa avatar Nov 09 '23 07:11 Emiyaaaaa

No one would actually do Partial<HTMLCanvasElement> though. I would rather PartialDeep work like people expect and not recurse into built-in types.

sindresorhus avatar Nov 10 '23 07:11 sindresorhus

No one would actually do Partial<HTMLCanvasElement> though. I would rather PartialDeep work like people expect and not recurse into built-in types.

Is it ok?

export type BuiltIns = Primitive | Date | RegExp

changed to

export type BuiltInClass /** or other name */ = Date | RegExp | Element ... and more
export type BuiltIns = Primitive | BuiltInClass

or just BuiltIns = Primitive | Date | RegExp | Element

Emiyaaaaa avatar Nov 10 '23 09:11 Emiyaaaaa

Reopening as it was reverted in https://github.com/sindresorhus/type-fest/releases/tag/v4.8.1

sindresorhus avatar Nov 17 '23 12:11 sindresorhus