Skip to content

Commit af8004b

Browse files
committed
Add test for prototype methods without generics
1 parent 1098e06 commit af8004b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/type-definitions/templates.import.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import '@core-js/pure/full/array-buffer/detached';
33
// @ts-expect-error it has no exports
44
import detached from '@core-js/pure/full/array-buffer/detached';
55

6-
// $prototype
6+
// $prototype with generics
77
import at from '@core-js/pure/full/array/prototype/at';
8-
const atResult1: number = at.call([1, 2, 3], -2);
8+
at.call([1, 2, 3], -2); // we can't save strict result type for prototype methods with generics. It is any here
99
at.apply([1, 2, 3], [-2]);
1010
// @ts-expect-error
1111
at.call([1, 2, 3], null);
@@ -16,6 +16,19 @@ at('string');
1616
// @ts-expect-error
1717
at(null);
1818

19+
// $prototype without generics
20+
import stringAt from '@core-js/pure/full/string/prototype/at';
21+
const stringAtResult: string | undefined = stringAt.call('asd', -2);
22+
stringAt.apply('asd', [-2]);
23+
// @ts-expect-error
24+
stringAt.call('asd', null);
25+
// @ts-expect-error
26+
stringAt.call('asd');
27+
// @ts-expect-error
28+
stringAt([1]);
29+
// @ts-expect-error
30+
stringAt(null);
31+
1932
// $prototypeIterator
2033
import arrayVirtualIterator from '@core-js/pure/full/array/prototype/iterator';
2134
const aviValue1: number = arrayVirtualIterator.call([1]).next().value;

0 commit comments

Comments
 (0)