Skip to content
Open
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 src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,13 @@ interface String {
substring(start: number, end?: number): string;

/** Converts all the alphabetic characters in a string to lowercase. */
toLowerCase(): string;
toLowerCase<T extends string>(this: T): string extends T ? string : Lowercase<T>;

/** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
toLocaleLowerCase(locales?: string | string[]): string;

/** Converts all the alphabetic characters in a string to uppercase. */
toUpperCase(): string;
toUpperCase<T extends string>(this: T): string extends T ? string : Uppercase<T>;

/** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */
toLocaleUpperCase(locales?: string | string[]): string;
Expand Down
16 changes: 8 additions & 8 deletions tests/baselines/reference/abstractPropertyInConstructor.types
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ abstract class AbstractClass {
> : ^^^^^^
>this.prop.toLowerCase() : string
> : ^^^^^^
>this.prop.toLowerCase : () => string
> : ^^^^^^
>this.prop.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>this.prop : string
> : ^^^^^^
>this : this
> : ^^^^
>prop : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^

if (!str) {
>!str : boolean
Expand Down Expand Up @@ -215,16 +215,16 @@ abstract class DerivedAbstractClass extends AbstractClass {
> : ^ ^^ ^^^^^^^^^
>this.prop.toLowerCase() : string
> : ^^^^^^
>this.prop.toLowerCase : () => string
> : ^^^^^^
>this.prop.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>this.prop : string
> : ^^^^^^
>this : this
> : ^^^^
>prop : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^

this.method(1);
>this.method(1) : void
Expand Down
12 changes: 11 additions & 1 deletion tests/baselines/reference/arrayconcat.errors.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
arrayconcat.ts(12,9): error TS2564: Property 'options' has no initializer and is not definitely assigned in the constructor.
arrayconcat.ts(16,25): error TS2684: The 'this' context of type 'string | undefined' is not assignable to method's 'this' of type 'string'.
Type 'undefined' is not assignable to type 'string'.
arrayconcat.ts(16,25): error TS18048: 'a.name' is possibly 'undefined'.
arrayconcat.ts(17,25): error TS2684: The 'this' context of type 'string | undefined' is not assignable to method's 'this' of type 'string'.
Type 'undefined' is not assignable to type 'string'.
arrayconcat.ts(17,25): error TS18048: 'b.name' is possibly 'undefined'.


==== arrayconcat.ts (3 errors) ====
==== arrayconcat.ts (5 errors) ====
interface IOptions {
name?: string;
flag?: boolean;
Expand All @@ -23,9 +27,15 @@ arrayconcat.ts(17,25): error TS18048: 'b.name' is possibly 'undefined'.
this.options = this.options.sort(function(a, b) {
var aName = a.name.toLowerCase();
~~~~~~
!!! error TS2684: The 'this' context of type 'string | undefined' is not assignable to method's 'this' of type 'string'.
!!! error TS2684: Type 'undefined' is not assignable to type 'string'.
~~~~~~
!!! error TS18048: 'a.name' is possibly 'undefined'.
var bName = b.name.toLowerCase();
~~~~~~
!!! error TS2684: The 'this' context of type 'string | undefined' is not assignable to method's 'this' of type 'string'.
!!! error TS2684: Type 'undefined' is not assignable to type 'string'.
~~~~~~
!!! error TS18048: 'b.name' is possibly 'undefined'.

if (aName > bName) {
Expand Down
16 changes: 8 additions & 8 deletions tests/baselines/reference/arrayconcat.types
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,32 @@ class parser {
> : ^^^^^^
>a.name.toLowerCase() : string
> : ^^^^^^
>a.name.toLowerCase : () => string
> : ^^^^^^
>a.name.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>a.name : string | undefined
> : ^^^^^^^^^^^^^^^^^^
>a : IOptions
> : ^^^^^^^^
>name : string | undefined
> : ^^^^^^^^^^^^^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^

var bName = b.name.toLowerCase();
>bName : string
> : ^^^^^^
>b.name.toLowerCase() : string
> : ^^^^^^
>b.name.toLowerCase : () => string
> : ^^^^^^
>b.name.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>b.name : string | undefined
> : ^^^^^^^^^^^^^^^^^^
>b : IOptions
> : ^^^^^^^^
>name : string | undefined
> : ^^^^^^^^^^^^^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^

if (aName > bName) {
>aName > bName : boolean
Expand Down
24 changes: 12 additions & 12 deletions tests/baselines/reference/bestChoiceType.types
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
> : ^^^^^^
>s.toLowerCase() : string
> : ^^^^^^
>s.toLowerCase : () => string
> : ^^^^^^
>s.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>s : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^

// Similar cases

Expand Down Expand Up @@ -86,12 +86,12 @@ function f1() {
> : ^^^^^^
>s.toLowerCase() : string
> : ^^^^^^
>s.toLowerCase : () => string
> : ^^^^^^
>s.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>s : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
}

function f2() {
Expand Down Expand Up @@ -141,11 +141,11 @@ function f2() {
> : ^^^^^^
>s.toLowerCase() : string
> : ^^^^^^
>s.toLowerCase : () => string
> : ^^^^^^
>s.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>s : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
}

8 changes: 4 additions & 4 deletions tests/baselines/reference/checkJsdocSatisfiesTag13.types
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const t1 = { f: s => s.toLowerCase() }; // should work
> : ^^^^^^
>s.toLowerCase() : string
> : ^^^^^^
>s.toLowerCase : () => string
> : ^^^^^^
>s.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>s : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^

/** @satisfies {{ f: (x: string) => string }} */
const t2 = { g: "oops" }; // should error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ STRING.toLowerCase(), new CLASS()
> : ^^^^^
>STRING.toLowerCase() : string
> : ^^^^^^
>STRING.toLowerCase : () => string
> : ^^^^^^
>STRING.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>STRING : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>new CLASS() : CLASS
> : ^^^^^
>CLASS : typeof CLASS
Expand Down Expand Up @@ -274,12 +274,12 @@ var resultIsObject11 = (STRING.toLowerCase(), new CLASS());
> : ^^^^^
>STRING.toLowerCase() : string
> : ^^^^^^
>STRING.toLowerCase : () => string
> : ^^^^^^
>STRING.toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>STRING : string
> : ^^^^^^
>toLowerCase : () => string
> : ^^^^^^
>toLowerCase : <T extends string>(this: T) => string extends T ? string : Lowercase<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>new CLASS() : CLASS
> : ^^^^^
>CLASS : typeof CLASS
Expand Down
Loading
Loading