Skip to content

Commit

Permalink
Add Element to type BuiltIns (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emiyaaaaa committed Nov 11, 2023
1 parent 570e27f commit d42ea80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/internal.d.ts
Expand Up @@ -67,9 +67,9 @@ export type Subtract<A extends number, B extends number> = BuildTuple<A> extends
: never;

/**
Matches any primitive, `Date`, or `RegExp` value.
Matches any primitive, `Date`, `RegExp`, `Element` value.
*/
export type BuiltIns = Primitive | Date | RegExp;
export type BuiltIns = Primitive | Date | RegExp | Element;

export type UpperCaseCharacters = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';

Expand Down
13 changes: 13 additions & 0 deletions test-d/partial-deep.ts
Expand Up @@ -10,6 +10,7 @@ const foo = {
bar: {
function: (_: string): void => undefined,
classConstructor: ClassA,
element: document.createElement('div'),
object: {key: 'value'},
string: 'waldo',
number: 1,
Expand Down Expand Up @@ -41,6 +42,7 @@ const instance = new partialDeepFoo.bar!.classConstructor!();
instance.foo = 2;
const b = partialDeepFoo.bar!.constructor;
expectType<((_: string) => void) | undefined>(partialDeepFoo.bar!.function);
expectType<HTMLDivElement | undefined>(partialDeepFoo.bar!.element);
expectAssignable<object | undefined>(partialDeepFoo.bar!.object);
expectType<string | undefined>(partialDeepFoo.bar!.string);
expectType<number | undefined>(partialDeepFoo.bar!.number);
Expand Down Expand Up @@ -100,3 +102,14 @@ expectAssignable<ReadonlyMap<string | undefined, string | undefined> | undefined
expectAssignable<ReadonlySet<string | undefined> | undefined>(partialDeepNoRecurseIntoArraysBar.readonlySet);
expectType<readonly string[] | undefined>(partialDeepNoRecurseIntoArraysBar.readonlyArray);
expectType<readonly ['foo'] | undefined>(partialDeepNoRecurseIntoArraysBar.readonlyTuple);

// Test for interface
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface InterfaceType {
string: string;
object: {
number: number;
};
}
declare const interfaceType: PartialDeep<InterfaceType>;
expectType<{string?: string; object?: {number?: number}}>(interfaceType);

0 comments on commit d42ea80

Please sign in to comment.