mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
76 lines
3.5 KiB
Plaintext
76 lines
3.5 KiB
Plaintext
assignFromStringInterface2.ts(42,1): error TS2740: Type 'NotString' is missing the following properties from type 'String': codePointAt, includes, endsWith, normalize, and 16 more.
|
|
assignFromStringInterface2.ts(44,1): error TS2322: Type 'String' is not assignable to type 'NotString'.
|
|
The types returned by 'match(...)' are incompatible between these types.
|
|
Type 'RegExpMatchArray | null' is not assignable to type 'RegExpMatchArray'.
|
|
Type 'null' is not assignable to type 'RegExpMatchArray'.
|
|
assignFromStringInterface2.ts(45,1): error TS2322: Type 'string' is not assignable to type 'NotString'.
|
|
assignFromStringInterface2.ts(47,1): error TS2322: Type 'String' is not assignable to type 'string'.
|
|
'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
|
|
assignFromStringInterface2.ts(48,1): error TS2322: Type 'NotString' is not assignable to type 'string'.
|
|
|
|
|
|
==== assignFromStringInterface2.ts (5 errors) ====
|
|
interface String {
|
|
doStuff(): string;
|
|
}
|
|
|
|
interface NotString {
|
|
doStuff(): string;
|
|
toString(): string;
|
|
charAt(pos: number): string;
|
|
charCodeAt(index: number): number;
|
|
concat(...strings: string[]): string;
|
|
indexOf(searchString: string, position?: number): number;
|
|
lastIndexOf(searchString: string, position?: number): number;
|
|
localeCompare(that: string): number;
|
|
match(regexp: string): RegExpMatchArray;
|
|
match(regexp: RegExp): RegExpMatchArray;
|
|
replace(searchValue: string, replaceValue: string): string;
|
|
replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string;
|
|
replace(searchValue: RegExp, replaceValue: string): string;
|
|
replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string;
|
|
search(regexp: string): number;
|
|
search(regexp: RegExp): number;
|
|
slice(start?: number, end?: number): string;
|
|
split(separator: string, limit?: number): string[];
|
|
split(separator: RegExp, limit?: number): string[];
|
|
substring(start: number, end?: number): string;
|
|
toLowerCase(): string;
|
|
toLocaleLowerCase(): string;
|
|
toUpperCase(): string;
|
|
toLocaleUpperCase(): string;
|
|
trim(): string;
|
|
length: number;
|
|
substr(from: number, length?: number): string;
|
|
valueOf(): string;
|
|
[index: number]: string;
|
|
}
|
|
|
|
var x = '';
|
|
declare var a: String;
|
|
declare var b: NotString;
|
|
|
|
a = x;
|
|
a = b;
|
|
~
|
|
!!! error TS2740: Type 'NotString' is missing the following properties from type 'String': codePointAt, includes, endsWith, normalize, and 16 more.
|
|
|
|
b = a;
|
|
~
|
|
!!! error TS2322: Type 'String' is not assignable to type 'NotString'.
|
|
!!! error TS2322: The types returned by 'match(...)' are incompatible between these types.
|
|
!!! error TS2322: Type 'RegExpMatchArray | null' is not assignable to type 'RegExpMatchArray'.
|
|
!!! error TS2322: Type 'null' is not assignable to type 'RegExpMatchArray'.
|
|
b = x;
|
|
~
|
|
!!! error TS2322: Type 'string' is not assignable to type 'NotString'.
|
|
|
|
x = a; // expected error
|
|
~
|
|
!!! error TS2322: Type 'String' is not assignable to type 'string'.
|
|
!!! error TS2322: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
|
|
x = b; // expected error
|
|
~
|
|
!!! error TS2322: Type 'NotString' is not assignable to type 'string'.
|
|
|
|
|