Skip to content

Commit

Permalink
optional parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanaz committed Oct 26, 2021
1 parent c341cd7 commit e67d6e5
Show file tree
Hide file tree
Showing 13 changed files with 646 additions and 67 deletions.
26 changes: 13 additions & 13 deletions src/lib/es2022.array.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,101 @@ interface Array<T> {
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): T;
at(index?: number): T;
}

interface ReadonlyArray<T> {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): T;
at(index?: number): T;
}

interface Int8Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Uint8Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Uint8ClampedArray {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Int16Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Uint16Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Int32Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Uint32Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Float32Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface Float64Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface BigInt64Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}

interface BigUint64Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number;
at(index?: number): number;
}
2 changes: 1 addition & 1 deletion src/lib/es2022.string.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ interface String {
* Returns a new String consisting of the single UTF-16 code unit located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): string;
at(index?: number): string;
}
55 changes: 54 additions & 1 deletion tests/baselines/reference/indexAt(target=es2021).errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ tests/cases/compiler/indexAt.ts(10,20): error TS2550: Property 'at' does not exi
tests/cases/compiler/indexAt.ts(11,20): error TS2550: Property 'at' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(12,21): error TS2550: Property 'at' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(13,22): error TS2550: Property 'at' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(15,5): error TS2550: Property 'at' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(16,7): error TS2550: Property 'at' does not exist on type '"foo"'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(17,17): error TS2550: Property 'at' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(18,18): error TS2550: Property 'at' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(19,25): error TS2550: Property 'at' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(20,18): error TS2550: Property 'at' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(21,19): error TS2550: Property 'at' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(22,18): error TS2550: Property 'at' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(23,19): error TS2550: Property 'at' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(24,20): error TS2550: Property 'at' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(25,20): error TS2550: Property 'at' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(26,21): error TS2550: Property 'at' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
tests/cases/compiler/indexAt.ts(27,22): error TS2550: Property 'at' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.


==== tests/cases/compiler/indexAt.ts (13 errors) ====
==== tests/cases/compiler/indexAt.ts (26 errors) ====
[0].at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
Expand Down Expand Up @@ -53,4 +66,44 @@ tests/cases/compiler/indexAt.ts(13,22): error TS2550: Property 'at' does not exi
new BigUint64Array().at(0);
~~
!!! error TS2550: Property 'at' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.

[0].at();
~~
!!! error TS2550: Property 'at' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
"foo".at();
~~
!!! error TS2550: Property 'at' does not exist on type '"foo"'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Int8Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Int8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint8Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint8Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint8ClampedArray().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint8ClampedArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Int16Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Int16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint16Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint16Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Int32Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Int32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Uint32Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Uint32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Float32Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Float32Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new Float64Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'Float64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new BigInt64Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'BigInt64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
new BigUint64Array().at();
~~
!!! error TS2550: Property 'at' does not exist on type 'BigUint64Array'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.

27 changes: 27 additions & 0 deletions tests/baselines/reference/indexAt(target=es2021).js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);

[0].at();
"foo".at();
new Int8Array().at();
new Uint8Array().at();
new Uint8ClampedArray().at();
new Int16Array().at();
new Uint16Array().at();
new Int32Array().at();
new Uint32Array().at();
new Float32Array().at();
new Float64Array().at();
new BigInt64Array().at();
new BigUint64Array().at();


//// [indexAt.js]
Expand All @@ -28,3 +42,16 @@ new Float32Array().at(0);
new Float64Array().at(0);
new BigInt64Array().at(0);
new BigUint64Array().at(0);
[0].at();
"foo".at();
new Int8Array().at();
new Uint8Array().at();
new Uint8ClampedArray().at();
new Int16Array().at();
new Uint16Array().at();
new Int32Array().at();
new Uint32Array().at();
new Float32Array().at();
new Float64Array().at();
new BigInt64Array().at();
new BigUint64Array().at();
35 changes: 35 additions & 0 deletions tests/baselines/reference/indexAt(target=es2021).symbols
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,38 @@ new BigInt64Array().at(0);
new BigUint64Array().at(0);
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))

[0].at();
"foo".at();
new Int8Array().at();
>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Uint8Array().at();
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Uint8ClampedArray().at();
>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Int16Array().at();
>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Uint16Array().at();
>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Int32Array().at();
>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Uint32Array().at();
>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Float32Array().at();
>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new Float64Array().at();
>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))

new BigInt64Array().at();
>BigInt64Array : Symbol(BigInt64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))

new BigUint64Array().at();
>BigUint64Array : Symbol(BigUint64Array, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))

90 changes: 90 additions & 0 deletions tests/baselines/reference/indexAt(target=es2021).types
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,93 @@ new BigUint64Array().at(0);
>at : any
>0 : 0

[0].at();
>[0].at() : any
>[0].at : any
>[0] : number[]
>0 : 0
>at : any

"foo".at();
>"foo".at() : any
>"foo".at : any
>"foo" : "foo"
>at : any

new Int8Array().at();
>new Int8Array().at() : any
>new Int8Array().at : any
>new Int8Array() : Int8Array
>Int8Array : Int8ArrayConstructor
>at : any

new Uint8Array().at();
>new Uint8Array().at() : any
>new Uint8Array().at : any
>new Uint8Array() : Uint8Array
>Uint8Array : Uint8ArrayConstructor
>at : any

new Uint8ClampedArray().at();
>new Uint8ClampedArray().at() : any
>new Uint8ClampedArray().at : any
>new Uint8ClampedArray() : Uint8ClampedArray
>Uint8ClampedArray : Uint8ClampedArrayConstructor
>at : any

new Int16Array().at();
>new Int16Array().at() : any
>new Int16Array().at : any
>new Int16Array() : Int16Array
>Int16Array : Int16ArrayConstructor
>at : any

new Uint16Array().at();
>new Uint16Array().at() : any
>new Uint16Array().at : any
>new Uint16Array() : Uint16Array
>Uint16Array : Uint16ArrayConstructor
>at : any

new Int32Array().at();
>new Int32Array().at() : any
>new Int32Array().at : any
>new Int32Array() : Int32Array
>Int32Array : Int32ArrayConstructor
>at : any

new Uint32Array().at();
>new Uint32Array().at() : any
>new Uint32Array().at : any
>new Uint32Array() : Uint32Array
>Uint32Array : Uint32ArrayConstructor
>at : any

new Float32Array().at();
>new Float32Array().at() : any
>new Float32Array().at : any
>new Float32Array() : Float32Array
>Float32Array : Float32ArrayConstructor
>at : any

new Float64Array().at();
>new Float64Array().at() : any
>new Float64Array().at : any
>new Float64Array() : Float64Array
>Float64Array : Float64ArrayConstructor
>at : any

new BigInt64Array().at();
>new BigInt64Array().at() : any
>new BigInt64Array().at : any
>new BigInt64Array() : BigInt64Array
>BigInt64Array : BigInt64ArrayConstructor
>at : any

new BigUint64Array().at();
>new BigUint64Array().at() : any
>new BigUint64Array().at : any
>new BigUint64Array() : BigUint64Array
>BigUint64Array : BigUint64ArrayConstructor
>at : any

Loading

0 comments on commit e67d6e5

Please sign in to comment.