Skip to content

Commit 0523e1f

Browse files
fix: also add record in es5.d.ts
1 parent 146ed2f commit 0523e1f

19 files changed

+38
-36
lines changed

lib/lib.es5.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ interface ObjectConstructor {
258258
* Returns the names of the enumerable properties and methods of an object.
259259
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
260260
*/
261-
keys<K extends string>(record: Record<K, any>): K[];
261+
keys<K extends string>(o: Record<K, any>): K[];
262262
keys(o: {}): string[];
263263
}
264264

src/lib/es5.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ interface ObjectConstructor {
238238
* Returns the names of the enumerable properties and methods of an object.
239239
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
240240
*/
241+
keys<K extends string>(o: Record<K, any>): K[];
241242
keys(o: {}): string[];
242243
}
243244

@@ -577,7 +578,7 @@ interface TemplateStringsArray extends ReadonlyArray<string> {
577578

578579
/**
579580
* The type of `import.meta`.
580-
*
581+
*
581582
* If you need to declare that a given property exists on `import.meta`,
582583
* this type may be augmented via interface merging.
583584
*/

tests/baselines/reference/conditionalTypeDoesntSpinForever.symbols

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ export enum PubSubRecordIsStoredInRedisAsA {
403403
fields: () => new Set(Object.keys(soFar) as (keyof SO_FAR)[]),
404404
>fields : Symbol(fields, Decl(conditionalTypeDoesntSpinForever.ts, 94, 18))
405405
>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
406-
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
406+
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
407407
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
408-
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
408+
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
409409
>soFar : Symbol(soFar, Decl(conditionalTypeDoesntSpinForever.ts, 92, 29))
410410
>SO_FAR : Symbol(SO_FAR, Decl(conditionalTypeDoesntSpinForever.ts, 92, 21))
411411

tests/baselines/reference/conditionalTypeDoesntSpinForever.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,10 @@ export enum PubSubRecordIsStoredInRedisAsA {
409409
>new Set(Object.keys(soFar) as (keyof SO_FAR)[]) : Set<keyof SO_FAR>
410410
>Set : SetConstructor
411411
>Object.keys(soFar) as (keyof SO_FAR)[] : (keyof SO_FAR)[]
412-
>Object.keys(soFar) : string[]
413-
>Object.keys : (o: {}) => string[]
412+
>Object.keys(soFar) : never[]
413+
>Object.keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
414414
>Object : ObjectConstructor
415-
>keys : (o: {}) => string[]
415+
>keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
416416
>soFar : SO_FAR
417417

418418
hasField: (fieldName: string | number | symbol) => fieldName in soFar

tests/baselines/reference/contextualExpressionTypecheckingDoesntBlowStack.symbols

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export default class Operation {
2121

2222
for(const parameterLocation of Object.keys(parameterValues)) {
2323
>parameterLocation : Symbol(parameterLocation, Decl(contextualExpressionTypecheckingDoesntBlowStack.ts, 8, 17))
24-
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
24+
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
2525
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
26-
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
26+
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
2727
>parameterValues : Symbol(parameterValues, Decl(contextualExpressionTypecheckingDoesntBlowStack.ts, 6, 23))
2828

2929
const parameter: any = (this as any).getParameter();;

tests/baselines/reference/contextualExpressionTypecheckingDoesntBlowStack.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export default class Operation {
2121
for(const parameterLocation of Object.keys(parameterValues)) {
2222
>parameterLocation : string
2323
>Object.keys(parameterValues) : string[]
24-
>Object.keys : (o: {}) => string[]
24+
>Object.keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
2525
>Object : ObjectConstructor
26-
>keys : (o: {}) => string[]
26+
>keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
2727
>parameterValues : any
2828

2929
const parameter: any = (this as any).getParameter();;

tests/baselines/reference/externModule.errors.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat
6969
var d=new XDate();
7070
~~~~~
7171
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
72-
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.
72+
!!! related TS2728 /.ts/lib.es5.d.ts:898:15: 'Date' is declared here.
7373
d.getDay();
7474
d=new XDate(1978,2);
7575
~~~~~
7676
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
77-
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.
77+
!!! related TS2728 /.ts/lib.es5.d.ts:898:15: 'Date' is declared here.
7878
d.getXDate();
7979
var n=XDate.parse("3/2/2004");
8080
~~~~~
8181
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
82-
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.
82+
!!! related TS2728 /.ts/lib.es5.d.ts:898:15: 'Date' is declared here.
8383
n=XDate.UTC(1964,2,1);
8484
~~~~~
8585
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
86-
!!! related TS2728 /.ts/lib.es5.d.ts:897:15: 'Date' is declared here.
86+
!!! related TS2728 /.ts/lib.es5.d.ts:898:15: 'Date' is declared here.
8787

8888

tests/baselines/reference/genericIndexedAccessMethodIntersectionCanBeAccessed.symbols

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export const createService = <T>(
4545
) => {
4646
Object.keys(ServiceCtr).forEach(key => {
4747
>Object.keys(ServiceCtr).forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
48-
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
48+
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
4949
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
50-
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
50+
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
5151
>ServiceCtr : Symbol(ServiceCtr, Decl(genericIndexedAccessMethodIntersectionCanBeAccessed.ts, 11, 33))
5252
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
5353
>key : Symbol(key, Decl(genericIndexedAccessMethodIntersectionCanBeAccessed.ts, 14, 36))

tests/baselines/reference/genericIndexedAccessMethodIntersectionCanBeAccessed.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export const createService = <T>(
3232
>Object.keys(ServiceCtr).forEach(key => { const method = (ServiceCtr)[key as keyof T]; const {__$daemonMode, __$action, id} = method; }) : void
3333
>Object.keys(ServiceCtr).forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
3434
>Object.keys(ServiceCtr) : string[]
35-
>Object.keys : (o: {}) => string[]
35+
>Object.keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
3636
>Object : ObjectConstructor
37-
>keys : (o: {}) => string[]
37+
>keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
3838
>ServiceCtr : ExtendedService<T> & Service<T>
3939
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
4040
>key => { const method = (ServiceCtr)[key as keyof T]; const {__$daemonMode, __$action, id} = method; } : (key: string) => void

tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.errors.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.t
4141
Math.sign(1);
4242
~~~~
4343
!!! error TS2551: Property 'sign' does not exist on type 'Math'. Did you mean 'sin'?
44-
!!! related TS2728 /.ts/lib.es5.d.ts:703:5: 'sin' is declared here.
44+
!!! related TS2728 /.ts/lib.es5.d.ts:704:5: 'sin' is declared here.
4545

4646
// Using ES6 object
4747
var o = {

tests/baselines/reference/objectKeysWithRecord.symbols

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const record: Record<K, boolean> = { foo: true, bar: false };
1111

1212
Object.keys(record).forEach((key: K) => {
1313
>Object.keys(record).forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
14-
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
14+
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
1515
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
16-
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
16+
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
1717
>record : Symbol(record, Decl(objectKeysWithRecord.ts, 1, 5))
1818
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
1919
>key : Symbol(key, Decl(objectKeysWithRecord.ts, 3, 29))

tests/baselines/reference/objectKeysWithRecord.types

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ const record: Record<K, boolean> = { foo: true, bar: false };
1212

1313
Object.keys(record).forEach((key: K) => {
1414
>Object.keys(record).forEach((key: K) => {}) : void
15-
>Object.keys(record).forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
16-
>Object.keys(record) : string[]
17-
>Object.keys : (o: {}) => string[]
15+
>Object.keys(record).forEach : (callbackfn: (value: K, index: number, array: K[]) => void, thisArg?: any) => void
16+
>Object.keys(record) : K[]
17+
>Object.keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
1818
>Object : ObjectConstructor
19-
>keys : (o: {}) => string[]
19+
>keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
2020
>record : Record<K, boolean>
21-
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
21+
>forEach : (callbackfn: (value: K, index: number, array: K[]) => void, thisArg?: any) => void
2222
>(key: K) => {} : (key: K) => void
2323
>key : K
2424

tests/baselines/reference/promisePermutations.errors.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
295295
~~~~~~~~~
296296
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
297297
!!! error TS2345: Property 'catch' is missing in type 'IPromise<string>' but required in type 'Promise<number>'.
298-
!!! related TS2728 /.ts/lib.es5.d.ts:1403:5: 'catch' is declared here.
298+
!!! related TS2728 /.ts/lib.es5.d.ts:1404:5: 'catch' is declared here.
299299
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
300300

301301
var r11: IPromise<number>;

tests/baselines/reference/promisePermutations2.errors.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
294294
~~~~~~~~~
295295
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
296296
!!! error TS2345: Property 'catch' is missing in type 'IPromise<string>' but required in type 'Promise<number>'.
297-
!!! related TS2728 /.ts/lib.es5.d.ts:1403:5: 'catch' is declared here.
297+
!!! related TS2728 /.ts/lib.es5.d.ts:1404:5: 'catch' is declared here.
298298
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
299299

300300
var r11: IPromise<number>;

tests/baselines/reference/promisePermutations3.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
303303
~~~~~~~~~
304304
!!! error TS2345: Argument of type '(x: any) => IPromise<string>' is not assignable to parameter of type '(error: any) => Promise<number>'.
305305
!!! error TS2345: Property 'catch' is missing in type 'IPromise<string>' but required in type 'Promise<number>'.
306-
!!! related TS2728 /.ts/lib.es5.d.ts:1403:5: 'catch' is declared here.
306+
!!! related TS2728 /.ts/lib.es5.d.ts:1404:5: 'catch' is declared here.
307307
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
308308

309309
var r11: IPromise<number>;
@@ -340,5 +340,5 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
340340
~~~~~~~~~~~~~~~
341341
!!! error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<{}>'.
342342
!!! error TS2345: Property 'catch' is missing in type 'IPromise<any>' but required in type 'Promise<{}>'.
343-
!!! related TS2728 /.ts/lib.es5.d.ts:1403:5: 'catch' is declared here.
343+
!!! related TS2728 /.ts/lib.es5.d.ts:1404:5: 'catch' is declared here.
344344
var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok

tests/baselines/reference/promiseTypeInference.errors.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ tests/cases/compiler/promiseTypeInference.ts(10,39): error TS2322: Type 'IPromis
2626
!!! error TS2322: Types of parameters 'success' and 'onfulfilled' are incompatible.
2727
!!! error TS2322: Type 'TResult1 | PromiseLike<TResult1>' is not assignable to type 'IPromise<TResult1 | TResult2>'.
2828
!!! error TS2322: Type 'TResult1' is not assignable to type 'IPromise<TResult1 | TResult2>'.
29-
!!! related TS6502 /.ts/lib.es5.d.ts:1396:57: The expected type comes from the return type of this signature.
29+
!!! related TS6502 /.ts/lib.es5.d.ts:1397:57: The expected type comes from the return type of this signature.
3030

tests/baselines/reference/recursiveTypeRelations.symbols

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ export function css<S extends { [K in keyof S]: string }>(styles: S, ...classNam
9090

9191
return Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => {
9292
>Object.keys(arg).reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
93-
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
93+
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
9494
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
95-
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
95+
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
9696
>arg : Symbol(arg, Decl(recursiveTypeRelations.ts, 18, 30))
9797
>reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
9898
>obj : Symbol(obj, Decl(recursiveTypeRelations.ts, 26, 55))

tests/baselines/reference/recursiveTypeRelations.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export function css<S extends { [K in keyof S]: string }>(styles: S, ...classNam
7272
>Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; }, {}) : any
7373
>Object.keys(arg).reduce : { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; <U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }
7474
>Object.keys(arg) : string[]
75-
>Object.keys : (o: {}) => string[]
75+
>Object.keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
7676
>Object : ObjectConstructor
77-
>keys : (o: {}) => string[]
77+
>keys : { <K extends string>(o: Record<K, any>): K[]; (o: {}): string[]; }
7878
>arg : ClassNameObjectMap<S>
7979
>reduce : { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; <U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }
8080
>(obj: ClassNameObject, key: keyof S) => { const exportedClassName = styles[key]; obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; return obj; } : (obj: any, key: keyof S) => any

tests/cases/compiler/objectKeysWithRecord.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @strictFunctionTypes: true
12
type K = 'foo' | 'bar'
23
const record: Record<K, boolean> = { foo: true, bar: false };
34

0 commit comments

Comments
 (0)