no-unchecked-indexed-access
यह क्या करती है
यह स्किल जाँचती है कि TypeScript का सुरक्षा विकल्प noUncheckedIndexedAccess चालू है या नहीं, और ऐसे कोड को ठीक करती है जो बिना जाँचे array आइटम इंडेक्स से पढ़ता है। यह उन डेवलपर्स के लिए है जो undefined की रनटाइम गलतियाँ कम चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप एजेंट से किसी प्रोजेक्ट की TypeScript सेटिंग में छूटे सुरक्षा विकल्प जाँचने को कहें।
- ✓जब आपका ऐप ऐसी undefined वैल्यू से क्रैश हो जिसकी TypeScript ने चेतावनी नहीं दी थी।
- ✓जब आप ऐसा डेटा प्रोसेसिंग कोड जाँच रहे हों जो array से स्थिति के आधार पर आइटम पढ़ता है।
Skill का लिंक
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/no-unchecked-indexed-access/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरा ऐप कभी-कभी undefined एरर से क्रैश होता है। क्या आप वह TypeScript सेटिंग चालू कर सकते हैं जो ये पकड़ती है, और जो कोड वह बताए उसे ठीक कर सकते हैं?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट tsconfig.json फ़ाइल जाँचता है और अगर विकल्प नहीं है तो उसे चालू करता है। फिर वह array एक्सेस को अपडेट करता है जिन्हें TypeScript अब चिह्नित करता है, और जाँच या optional chaining जोड़ता है ताकि कोड गायब आइटम को संभाल सके।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Enable noUncheckedIndexedAccess to catch out-of-bounds array bugs
TypeScript's default behaviour types array[0] as T, pretending the access is always safe. In reality, the array might be empty or the index might be out of range, leading to silent undefined values that cause downstream crashes. Enabling noUncheckedIndexedAccess surfaces these potential failures as type errors at compile time, requiring developers to prove the access is safe before the code runs.
Quick Reference
- Without the flag, array[0] is typed as T even if the array is empty
- noUncheckedIndexedAccess changes array[n] to return T | undefined
- Forces an explicit check before using any array element accessed by index
- Optional chaining and nullish coalescing handle most false positives cleanly
Check
Check whether noUncheckedIndexedAccess is enabled in the project's tsconfig.json. If not, scan for array index accesses (arr[0], arr[i]) that could fail if the array is shorter than expected.
Fix
Enable noUncheckedIndexedAccess in tsconfig.json, then update any array index accesses that TypeScript now flags to include an explicit undefined check or use optional chaining before the accessed value is used.
Explain
Explain what noUncheckedIndexedAccess does, why the default TypeScript behaviour is unsound for array index access, and how optional chaining and Array.at() interact with the flag.
Code Review
Review all array index accesses in this file (arr[0], arr[i], object[key]). Flag any location where the accessed value is used without a preceding undefined check, even if noUncheckedIndexedAccess is not yet enabled in the project.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/javascript/no-unchecked-indexed-access
अक्सर पूछे जाने वाले सवाल
यहाँ डिफ़ॉल्ट TypeScript व्यवहार जोखिम भरा क्यों है?
डिफ़ॉल्ट रूप से TypeScript array के आइटम को हमेशा मौजूद मानता है, भले ही array खाली हो या इंडेक्स सीमा से बाहर हो।
क्या इससे बहुत नई गलतियाँ आएँगी?
आ सकती हैं, और स्किल कहती है कि optional chaining और nullish coalescing ज़्यादातर मामलों को साफ़ तरह संभाल लेते हैं।
Array.at() का क्या?
स्किल बताती है कि Array.at() इस जाँच के साथ कैसे काम करता है, ताकि एजेंट सही पैटर्न चुन सके।
जानकारी
लेखक का मूल विवरण
Use when auditing tsconfig.json for missing safety flags, reviewing code that uses array index access in data processing pipelines, or investigating runtime undefined errors that TypeScript did not catch.
लोकप्रियता
- GitHub स्टार
- 75k
- रैंकिंग में स्थान
- #2951
- लाइसेंस
- MIT
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
frontendchecklist
75kकमांड-लाइन टूल से फ़्रंटएंड कोड और लाइव पेजों को एक्सेसिबिलिटी, स्पीड, SEO और सिक्योरिटी के 380 से ज़्यादा नियमों से जाँचती है।
frontend-checklist-global
75kफ़्रंटएंड प्रोजेक्ट को Front-End Checklist के सभी 386 नियमों से ऑडिट करती है, और हर मिली समस्या का ठोस समाधान देती है।
404-page
75kजाँचती है कि आपका गुम पेज उपयोगी लिंक देता है और सही 404 स्टेटस लौटाता है, ताकि भटके हुए विज़िटर रास्ता ढूँढ सकें।
about-page
75kजाँचती है कि आपकी साइट पर एक साफ़ About पेज है जो बताता है कि उसे कौन चलाता है, ताकि विज़िटर और सर्च इंजन का भरोसा बढ़े।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।