diff --git a/package-lock.json b/package-lock.json index aa2ba5e2ad2..97940b9dab1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -305,12 +305,12 @@ "dev": true }, "@octokit/plugin-rest-endpoint-methods": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.1.4.tgz", - "integrity": "sha512-Y2tVpSa7HjV3DGIQrQOJcReJ2JtcN9FaGr9jDa332Flro923/h3/Iu9e7Y4GilnzfLclHEh5iCQoCkHm7tWOcg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.2.0.tgz", + "integrity": "sha512-1/qn1q1C1hGz6W/iEDm9DoyNoG/xdFDt78E3eZ5hHeUfJTLJgyAMdj9chL/cNBHjcjd+FH5aO1x0VCqR2RE0mw==", "dev": true, "requires": { - "@octokit/types": "^5.4.1", + "@octokit/types": "^5.5.0", "deprecation": "^2.3.1" } }, @@ -350,15 +350,15 @@ } }, "@octokit/rest": { - "version": "18.0.5", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.0.5.tgz", - "integrity": "sha512-SPKI24tQXrr1XsnaIjv2x0rl4M5eF1+hj8+vMe3d/exZ7NnL5sTe1BuFyCyJyrc+j1HkXankvgGN9zT0rwBwtg==", + "version": "18.0.6", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.0.6.tgz", + "integrity": "sha512-ES4lZBKPJMX/yUoQjAZiyFjei9pJ4lTTfb9k7OtYoUzKPDLl/M8jiHqt6qeSauyU4eZGLw0sgP1WiQl9FYeM5w==", "dev": true, "requires": { "@octokit/core": "^3.0.0", "@octokit/plugin-paginate-rest": "^2.2.0", "@octokit/plugin-request-log": "^1.0.0", - "@octokit/plugin-rest-endpoint-methods": "4.1.4" + "@octokit/plugin-rest-endpoint-methods": "4.2.0" } }, "@octokit/types": { @@ -550,9 +550,9 @@ "dev": true }, "@types/node": { - "version": "14.10.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.10.1.tgz", - "integrity": "sha512-aYNbO+FZ/3KGeQCEkNhHFRIzBOUgc7QvcVNKXbfnhDkSfwUv91JsQQa10rDgKSTSLkXZ1UIyPe4FJJNVgw1xWQ==", + "version": "14.10.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.10.2.tgz", + "integrity": "sha512-IzMhbDYCpv26pC2wboJ4MMOa9GKtjplXfcAqrMeNJpUUwpM/2ATt2w1JPUXwS6spu856TvKZL2AOmeU2rAxskw==", "dev": true }, "@types/node-fetch": { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a8f6e129f9c..ccba60fe42d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13922,7 +13922,7 @@ namespace ts { } const shouldIncludeUndefined = - compilerOptions.noUncheckedIndexSignatures && + compilerOptions.noUncheckedIndexedAccess && (accessFlags & (AccessFlags.Writing | AccessFlags.ExpressionPosition)) === AccessFlags.ExpressionPosition; // If the object type has a string index signature and no other members we know that the result will @@ -20735,7 +20735,7 @@ namespace ts { function includeUndefinedInIndexSignature(type: Type | undefined): Type | undefined { if (!type) return type; - return compilerOptions.noUncheckedIndexSignatures ? + return compilerOptions.noUncheckedIndexedAccess ? getUnionType([type, undefinedType]) : type; } @@ -25478,7 +25478,7 @@ namespace ts { error(node, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); } - propType = (compilerOptions.noUncheckedIndexSignatures && !isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + propType = (compilerOptions.noUncheckedIndexedAccess && !isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } else { if (prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) { @@ -29445,7 +29445,7 @@ namespace ts { // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). const possiblyOutOfBoundsType = checkIteratedTypeOrElementType(IterationUse.Destructuring | IterationUse.PossiblyOutOfBounds, sourceType, undefinedType, node) || errorType; - let inBoundsType: Type | undefined = compilerOptions.noUncheckedIndexSignatures ? undefined: possiblyOutOfBoundsType; + let inBoundsType: Type | undefined = compilerOptions.noUncheckedIndexedAccess ? undefined: possiblyOutOfBoundsType; for (let i = 0; i < elements.length; i++) { let type = possiblyOutOfBoundsType; if (node.elements[i].kind === SyntaxKind.SpreadElement) { @@ -33709,7 +33709,7 @@ namespace ts { const uplevelIteration = languageVersion >= ScriptTarget.ES2015; const downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - const possibleOutOfBounds = compilerOptions.noUncheckedIndexSignatures && !!(use & IterationUse.PossiblyOutOfBounds); + const possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & IterationUse.PossiblyOutOfBounds); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when @@ -33804,7 +33804,7 @@ namespace ts { const arrayElementType = getIndexTypeOfType(arrayType, IndexKind.Number); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & TypeFlags.StringLike && !compilerOptions.noUncheckedIndexSignatures) { + if (arrayElementType.flags & TypeFlags.StringLike && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 674029253f8..ed19a1ed2bf 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5652,6 +5652,9 @@ + + + @@ -6075,6 +6078,9 @@ + + + @@ -7293,6 +7299,9 @@ + + + @@ -7617,6 +7626,9 @@ + + + @@ -8793,6 +8805,9 @@ + + + @@ -9945,6 +9960,9 @@ + + + @@ -10242,6 +10260,9 @@ + + + @@ -10329,6 +10350,9 @@ + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index a4d08feb74e..3cc7f81d585 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5661,6 +5661,9 @@ + + + @@ -6084,6 +6087,9 @@ + + + @@ -7302,6 +7308,9 @@ + + + @@ -7626,6 +7635,9 @@ + + + @@ -8802,6 +8814,9 @@ + + + @@ -9954,6 +9969,9 @@ + + + @@ -10251,6 +10269,9 @@ + + + @@ -10338,6 +10359,9 @@ + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index c4fb501a836..eb5a25d972f 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5649,6 +5649,9 @@ + + + @@ -6072,6 +6075,9 @@ + + + @@ -7290,6 +7296,9 @@ + + + @@ -7614,6 +7623,9 @@ + + + @@ -8787,6 +8799,9 @@ + + + @@ -9939,6 +9954,9 @@ + + + @@ -10236,6 +10254,9 @@ + + + @@ -10323,6 +10344,9 @@ + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2c598b3b980..dd48aeb050b 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5664,6 +5664,9 @@ + + + @@ -6087,6 +6090,9 @@ + + + @@ -7305,6 +7311,9 @@ + + + @@ -7629,6 +7638,9 @@ + + + @@ -8805,6 +8817,9 @@ + + + @@ -9957,6 +9972,9 @@ + + + @@ -10254,6 +10272,9 @@ + + + @@ -10341,6 +10362,9 @@ + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index c3cc359e33b..2ca8f7ee2fb 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1503,8 +1503,8 @@ - - + + @@ -1794,8 +1794,8 @@ - - + + @@ -2625,8 +2625,8 @@ - - + + @@ -3465,6 +3465,9 @@ + + + @@ -4509,8 +4512,8 @@ - - + + @@ -5661,6 +5664,9 @@ + + + @@ -6084,6 +6090,9 @@ + + + @@ -7302,6 +7311,9 @@ + + + @@ -7626,6 +7638,9 @@ + + + @@ -8298,8 +8313,8 @@ - - + + @@ -8538,8 +8553,8 @@ - - + + @@ -8802,6 +8817,9 @@ + + + @@ -9954,6 +9972,9 @@ + + + @@ -10251,6 +10272,9 @@ + + + @@ -10338,6 +10362,9 @@ + + + @@ -12912,8 +12939,8 @@ - - + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8c67d11586a..177c5c45894 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5652,6 +5652,9 @@ + + + @@ -6075,6 +6078,9 @@ + + + @@ -7293,6 +7299,9 @@ + + + @@ -7617,6 +7626,9 @@ + + + @@ -8793,6 +8805,9 @@ + + + @@ -9945,6 +9960,9 @@ + + + @@ -10242,6 +10260,9 @@ + + + @@ -10329,6 +10350,9 @@ + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 20ae9e57a1c..5f7f91e078c 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5652,6 +5652,9 @@ + + + @@ -6075,6 +6078,9 @@ + + + @@ -7293,6 +7299,9 @@ + + + @@ -7617,6 +7626,9 @@ + + + @@ -8793,6 +8805,9 @@ + + + @@ -9945,6 +9960,9 @@ + + + @@ -10242,6 +10260,9 @@ + + + @@ -10329,6 +10350,9 @@ + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 37cbb2c6d22..f69faf3087d 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5642,6 +5642,9 @@ + + + @@ -6065,6 +6068,9 @@ + + + @@ -7283,6 +7289,9 @@ + + + @@ -7607,6 +7616,9 @@ + + + @@ -8780,6 +8792,9 @@ + + + @@ -9932,6 +9947,9 @@ + + + @@ -10229,6 +10247,9 @@ + + + @@ -10316,6 +10337,9 @@ + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 336851edd30..8430b58693b 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3443,6 +3443,15 @@ + + + + + + + + + @@ -3524,6 +3533,15 @@ + + + + + + + + + @@ -5624,6 +5642,15 @@ + + + + + + + + + @@ -6041,6 +6068,15 @@ + + + + + + + + + @@ -7253,6 +7289,15 @@ + + + + + + + + + @@ -7571,6 +7616,15 @@ + + + + + + + + + @@ -7643,15 +7697,6 @@ - - - - - - - - - @@ -8747,6 +8792,15 @@ + + + + + + + + + @@ -9893,6 +9947,15 @@ + + + + + + + + + @@ -10184,6 +10247,15 @@ + + + + + + + + + @@ -10265,6 +10337,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 41a5891cee7..efcc301de9f 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5651,6 +5651,9 @@ + + + @@ -6074,6 +6077,9 @@ + + + @@ -7292,6 +7298,9 @@ + + + @@ -7616,6 +7625,9 @@ + + + @@ -8792,6 +8804,9 @@ + + + @@ -9944,6 +9959,9 @@ + + + @@ -10241,6 +10259,9 @@ + + + @@ -10328,6 +10349,9 @@ + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 69813264d60..93b275ea1dc 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5645,6 +5645,9 @@ + + + @@ -6068,6 +6071,9 @@ + + + @@ -7286,6 +7292,9 @@ + + + @@ -7610,6 +7619,9 @@ + + + @@ -8786,6 +8798,9 @@ + + + @@ -9938,6 +9953,9 @@ + + + @@ -10235,6 +10253,9 @@ + + + @@ -10322,6 +10343,9 @@ + + + diff --git a/tests/baselines/reference/noUncheckedIndexedAccess.errors.txt b/tests/baselines/reference/noUncheckedIndexedAccess.errors.txt index 065eafcc65c..ececa53997e 100644 --- a/tests/baselines/reference/noUncheckedIndexedAccess.errors.txt +++ b/tests/baselines/reference/noUncheckedIndexedAccess.errors.txt @@ -2,6 +2,8 @@ tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(3,32): error TS2344 Type 'undefined' is not assignable to type 'boolean'. tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(12,7): error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. Type 'undefined' is not assignable to type 'boolean'. +tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(13,7): error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. + Type 'undefined' is not assignable to type 'boolean'. tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(14,7): error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. Type 'undefined' is not assignable to type 'boolean'. tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(15,7): error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. @@ -49,7 +51,7 @@ tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(79,7): error TS2322 tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(85,1): error TS2322: Type 'undefined' is not assignable to type 'string'. -==== tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts (27 errors) ==== +==== tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts (28 errors) ==== type CheckBooleanOnly = any; // Validate CheckBooleanOnly works - should error type T_ERR1 = CheckBooleanOnly; @@ -69,6 +71,9 @@ tests/cases/conformance/pedantic/noUncheckedIndexedAccess.ts(85,1): error TS2322 !!! error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. !!! error TS2322: Type 'undefined' is not assignable to type 'boolean'. const e2: boolean = strMap.bar; + ~~ +!!! error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. +!!! error TS2322: Type 'undefined' is not assignable to type 'boolean'. const e3: boolean = strMap[0]; ~~ !!! error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/noUncheckedIndexedAccess.types b/tests/baselines/reference/noUncheckedIndexedAccess.types index 7d1e910a95d..2194c6132d4 100644 --- a/tests/baselines/reference/noUncheckedIndexedAccess.types +++ b/tests/baselines/reference/noUncheckedIndexedAccess.types @@ -41,9 +41,9 @@ const e1: boolean = strMap["foo"]; const e2: boolean = strMap.bar; >e2 : boolean ->strMap.bar : boolean +>strMap.bar : boolean | undefined >strMap : { [s: string]: boolean; } ->bar : boolean +>bar : boolean | undefined const e3: boolean = strMap[0]; >e3 : boolean @@ -146,9 +146,9 @@ const ok1: boolean | undefined = strMap["foo"]; const ok2: boolean | undefined = strMap.bar; >ok2 : boolean | undefined ->strMap.bar : boolean +>strMap.bar : boolean | undefined >strMap : { [s: string]: boolean; } ->bar : boolean +>bar : boolean | undefined type T_OK1 = CheckBooleanOnly<(typeof strMap)[string]>; >T_OK1 : any diff --git a/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.errors.txt b/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.errors.txt index cc29a879dee..752d59d0831 100644 --- a/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.errors.txt +++ b/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.errors.txt @@ -1,12 +1,17 @@ +tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(8,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(12,9): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'string'. tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(16,9): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'string'. +tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(23,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(26,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(34,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(41,5): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(50,2): error TS2322: Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(59,8): error TS2322: Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -==== tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts (4 errors) ==== +==== tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts (9 errors) ==== declare const strArray: string[]; declare const strStrTuple: [string, string]; @@ -15,6 +20,8 @@ tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(59,8): // Destructuring from a simple array -> include undefined const [s1] = strArray; s1.toString(); // Should error, s1 possibly undefined + ~~ +!!! error TS2532: Object is possibly 'undefined'. // Destructuring a rest element -> do not include undefined const [...s2] = strArray; @@ -34,9 +41,13 @@ tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(59,8): const { t1 } = strMap; t1.toString(); // Should error, t1 possibly undefined + ~~ +!!! error TS2532: Object is possibly 'undefined'. const { ...t2 } = strMap; t2.z.toString(); // Should error + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. // Test intersections with declared properties declare const numMapPoint: { x: number, y: number} & { [s: string]: number }; @@ -45,6 +56,8 @@ tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(59,8): x.toFixed(); // Should OK y.toFixed(); // Should OK z.toFixed(); // Should error + ~ +!!! error TS2532: Object is possibly 'undefined'. } { @@ -52,6 +65,8 @@ tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts(59,8): x.toFixed(); // Should OK q.y.toFixed(); // Should OK q.z.toFixed(); // Should error + ~~~ +!!! error TS2532: Object is possibly 'undefined'. } diff --git a/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types b/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types index 9d3dca24c5d..8e923b5c82a 100644 --- a/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types +++ b/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types @@ -15,7 +15,7 @@ const [s1] = strArray; s1.toString(); // Should error, s1 possibly undefined >s1.toString() : string >s1.toString : () => string ->s1 : string +>s1 : string | undefined >toString : () => string // Destructuring a rest element -> do not include undefined @@ -57,7 +57,7 @@ const { t1 } = strMap; t1.toString(); // Should error, t1 possibly undefined >t1.toString() : string >t1.toString : () => string ->t1 : string +>t1 : string | undefined >toString : () => string const { ...t2 } = strMap; @@ -67,9 +67,9 @@ const { ...t2 } = strMap; t2.z.toString(); // Should error >t2.z.toString() : string >t2.z.toString : () => string ->t2.z : string +>t2.z : string | undefined >t2 : { [s: string]: string; } ->z : string +>z : string | undefined >toString : () => string // Test intersections with declared properties @@ -100,7 +100,7 @@ declare const numMapPoint: { x: number, y: number} & { [s: string]: number }; z.toFixed(); // Should error >z.toFixed() : string >z.toFixed : (fractionDigits?: number | undefined) => string ->z : number +>z : number | undefined >toFixed : (fractionDigits?: number | undefined) => string } @@ -127,9 +127,9 @@ declare const numMapPoint: { x: number, y: number} & { [s: string]: number }; q.z.toFixed(); // Should error >q.z.toFixed() : string >q.z.toFixed : (fractionDigits?: number | undefined) => string ->q.z : number +>q.z : number | undefined >q : { [s: string]: number; y: number; } ->z : number +>z : number | undefined >toFixed : (fractionDigits?: number | undefined) => string }