Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Element to type BuiltIns #745

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/internal.d.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);