@@ -89,21 +89,39 @@ interface ObjectConstructor {
89
89
* on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions.
90
90
* @param o Object that contains the own properties.
91
91
*/
92
- getOwnPropertyNames ( o : any ) : string [ ] ;
92
+ getOwnPropertyNames < O > ( o : O ) : O extends undefined | null ? never : string [ ] ;
93
93
94
94
/**
95
95
* Creates an object that has the specified prototype or that has null prototype.
96
96
* @param o Object to use as a prototype. May be null.
97
97
*/
98
- create ( o : object | null ) : { } ;
98
+ create < O extends object = { } > ( o : O | null ) : O ;
99
+
100
+ /**
101
+ * Creates an object that has the specified prototype, and that optionally contains specified properties.
102
+ * @param o Object to use as a prototype. May be null
103
+ * @param properties JavaScript object that contains one or more property descriptors.
104
+ */
105
+ create < O extends object , P extends Record < PropertyKey , PropertyDescriptor > > (
106
+ o : O ,
107
+ properties : P & ThisType < any >
108
+ ) : {
109
+ [ K in keyof ( O & P ) ] : P [ K ] extends { value : infer V }
110
+ ? V
111
+ : P [ K ] extends { get : ( ) => infer V }
112
+ ? V
113
+ : K extends keyof O
114
+ ? O [ K ]
115
+ : unknown ;
116
+ } ;
99
117
100
118
/**
101
119
* Creates an object that has the specified prototype, and that optionally contains specified properties.
102
120
* @param o Object to use as a prototype. May be null
103
121
* @param properties JavaScript object that contains one or more property descriptors.
104
122
*/
105
123
create < P extends Record < string , PropertyDescriptor > > (
106
- o : object | null ,
124
+ o : null ,
107
125
properties : P & ThisType < any >
108
126
) : {
109
127
[ K in keyof P ] : P [ K ] extends { value : infer V }
@@ -119,28 +137,31 @@ interface ObjectConstructor {
119
137
* @param p The property name.
120
138
* @param attributes Descriptor for the property. It can be for a data property or an accessor property.
121
139
*/
122
- defineProperty < O , K extends PropertyKey , D extends PropertyDescriptor > (
140
+ defineProperty <
141
+ O extends object ,
142
+ P extends PropertyKey ,
143
+ D extends PropertyDescriptor
144
+ > (
123
145
o : O ,
124
- p : K ,
146
+ p : P ,
125
147
attributes : D & ThisType < any >
126
- ) : O &
127
- ( K extends PropertyKey
128
- ? Record <
129
- K ,
130
- D extends { value : infer V }
131
- ? V
132
- : D extends { get : ( ) => infer V }
133
- ? V
134
- : unknown
135
- >
136
- : unknown ) ;
148
+ ) : O & {
149
+ [ K in P ] : D extends { value : infer V }
150
+ ? V
151
+ : D extends { get : ( ) => infer V }
152
+ ? V
153
+ : unknown ;
154
+ } ;
137
155
138
156
/**
139
157
* Adds one or more properties to an object, and/or modifies attributes of existing properties.
140
158
* @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.
141
159
* @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.
142
160
*/
143
- defineProperties < O , P extends Record < PropertyKey , PropertyDescriptor > > (
161
+ defineProperties <
162
+ O extends object ,
163
+ P extends Record < PropertyKey , PropertyDescriptor >
164
+ > (
144
165
o : O ,
145
166
properties : P & ThisType < any >
146
167
) : {
0 commit comments