TypeScript/tests/baselines/reference/propertiesAndIndexersForNumericNames.errors.txt
Daniel Rosenwasser 5a49bb610a Handle numeric signs in 'isNumericName'.
To be fair, I don't think humanity knew about negative numbers until like 200 B.C.E.
2014-10-09 00:39:20 -07:00

29 lines
No EOL
1.8 KiB
Text

tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(3,3): error TS2412: Property '"1"' of type 'string' is not assignable to numeric index type 'number'.
tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(4,3): error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index type 'number'.
tests/cases/compiler/propertiesAndIndexersForNumericNames.ts(5,3): error TS2412: Property '"+1"' of type 'string' is not assignable to numeric index type 'number'.
==== tests/cases/compiler/propertiesAndIndexersForNumericNames.ts (3 errors) ====
class C {
[i: number]: number;
public "1": string = "number"; // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2412: Property '"1"' of type 'string' is not assignable to numeric index type 'number'.
public "-1": string = "negative number"; // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2412: Property '"-1"' of type 'string' is not assignable to numeric index type 'number'.
public "+1": string = "positive number (for the paranoid)"; // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2412: Property '"+1"' of type 'string' is not assignable to numeric index type 'number'.
public " 1": string = "leading space"; // No error
public "1 ": string = "trailing space"; // No error
public "": string = "no nothing"; // No error
public " ": string = "just space"; // No error
public "1 0 1": string = "several numbers and spaces"; // No error
public "NaN": string = "not a number"; // No error
public "-NaN": string = "not a negative number"; // No error
public "+Infinity": string = "A gillion"; // No error
public "-Infinity": string = "Negative-a-gillion"; // No error
}