1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(3,5): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(4,5): error TS18048: 'matchResult.index' is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(5,5): error TS18048: 'matchResult.input' is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(6,5): error TS18048: 'matchResult.groups' is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(6,5): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(7,5): error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(10,5): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(13,5): error TS18048: 'execResult.groups' is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(13,5): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(14,5): error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
tests/cases/compiler/regexpExecAndMatchTypeUsages.ts(20,9): error TS2375: Type 'RegExpMatchArray' is not assignable to type 'RegExpExecArray' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Property 'index' is optional in type 'RegExpMatchArray' but required in type 'RegExpExecArray'.
==== tests/cases/compiler/regexpExecAndMatchTypeUsages.ts (11 errors) ====
export function foo(matchResult: RegExpMatchArray, execResult: RegExpExecArray) {
matchResult[0].length;
matchResult[999].length;
~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
matchResult.index + 0;
~~~~~~~~~~~~~~~~~
!!! error TS18048: 'matchResult.index' is possibly 'undefined'.
matchResult.input.length;
~~~~~~~~~~~~~~~~~
!!! error TS18048: 'matchResult.input' is possibly 'undefined'.
matchResult.groups["someVariable"].length;
~~~~~~~~~~~~~~~~~~
!!! error TS18048: 'matchResult.groups' is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
matchResult.groups = undefined;
~~~~~~~~~~~~~~~~~~
!!! error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
execResult[0].length;
execResult[999].length;
~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
execResult.index + 0;
execResult.input.length;
execResult.groups["someVariable"].length;
~~~~~~~~~~~~~~~~~
!!! error TS18048: 'execResult.groups' is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
execResult.groups = undefined;
~~~~~~~~~~~~~~~~~
!!! error TS2412: Type 'undefined' is not assignable to type '{ [key: string]: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.
if (Math.random()) {
matchResult = execResult;
}
else {
execResult = matchResult
~~~~~~~~~~
!!! error TS2375: Type 'RegExpMatchArray' is not assignable to type 'RegExpExecArray' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
!!! error TS2375: Property 'index' is optional in type 'RegExpMatchArray' but required in type 'RegExpExecArray'.
}
}
|