मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग7.8k · #13085

typescript-import-audit

यह क्या करती है

यह स्किल TypeScript कोड की चार चरणों वाली समीक्षा बताती है, जिसमें गड़बड़ इंपोर्ट, दोहराए इंपोर्ट, गायब क्लास पैरेंट और गायब एक्सपोर्ट देखे जाते हैं। यह TypeScript प्रोजेक्ट को सुथरा करने वाले डेवलपर्स के लिए है।

कब इस्तेमाल करें

  • ✓जब आप TypeScript प्रोजेक्ट में इंपोर्ट साफ़ करना चाहते हैं।
  • ✓जब कोई क्लास किसी बेस क्लास को विस्तारित करनी चाहिए पर नहीं कर रही।
  • ✓जब किसी barrel फ़ाइल में वे एक्सपोर्ट नहीं हैं जिनकी दूसरी फ़ाइलों को ज़रूरत है।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-import-audit/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-import-audit/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“क्या आप मेरे TypeScript इंपोर्ट जाँच सकते हैं और दोहराए या गायब एक्सपोर्ट ठीक कर सकते हैं?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट संबंधित फ़ाइलें पढ़ता है, चार तरह की समस्याएं खोजता है, और हर एक के लिए एक छोटा, लक्षित सुधार लागू करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

TypeScript Import & Structure Audit

A step-by-step workflow for auditing TypeScript projects for common structural and import hygiene problems, then applying targeted fixes.


Overview

This skill covers four audit checks and their corresponding fixes:

# Issue Fix
1 Value imports used only as type annotations Split with import type
2 Duplicate imports from the same module Consolidate into one import statement
3 Classes missing expected base class extension Add extends BaseClass
4 Missing re-exports in barrel (index.ts) files Add the missing export lines

Step 1 — Read All Relevant Files in Parallel

Before making any changes, read all files that need to be audited in a single parallel batch. This avoids slow sequential reads.

Read in parallel:
  - src/index.ts           (barrel file)
  - src/**/*.ts            (all source files)
  - Any explicitly named files from the task spec

Look for:

  • All import statements at the top of each file
  • Class declarations (class Foo)
  • Export lists in barrel files

Step 2 — Audit Check 1: Value Imports Used Only as Types

Detection

For every import { A, B } from 'module' statement, check whether each imported name is used only in type positions (: TypeName, as TypeName, <TypeName> generics, implements TypeName). If a name never appears in a value position (instantiation, function call, assignment), it should be a type-only import.

// ❌ Bad — Foo is only used as a type annotation
import { Foo, bar } from './module';
const x: Foo = bar();

// ✅ Good — split into value import + type import
import { bar } from './module';
import type { Foo } from './module';

Fix Pattern

  1. Identify all names in the import that are type-only.
  2. Remove them from the value import (delete the value import entirely if all names are type-only).
  3. Add (or merge into an existing) import type { ... } from 'module' statement.

Step 3 — Audit Check 2: Duplicate Imports from the Same Module

Detection

Scan for two or more import statements that reference the same module path:

// ❌ Bad — two imports from the same source
import { ComponentA } from './components';
import { ComponentB } from './components';

Fix Pattern

Merge all named imports from the same module into a single statement:

// ✅ Good
import { ComponentA, ComponentB } from './components';

If there is a mix of value and type imports from the same module, keep them as two separate lines (import { ... } and import type { ... }), but ensure there is at most one of each kind per module path.


Step 4 — Audit Check 3: Classes That Should Extend a Base Class

Detection

Look for class declarations that:

  • Implement an interface that implies a base class, OR
  • Are described in comments / documentation as extending something, OR
  • Contain methods/properties that are defined on a known base class
// ❌ Missing base class
class MyPanel implements PanelInterface {
  render() { ... }
}

// ✅ Correct
class MyPanel extends BasePanel implements PanelInterface {
  render() { ... }
}

Fix Pattern

Add extends BaseClass between the class name and any implements clause:

class ClassName extends BaseClass implements InterfaceName { ... }

Ensure the base class is imported if it is not already.


Step 5 — Audit Check 4: Missing Re-exports in Barrel Files

Detection

A barrel file (index.ts) should re-export everything that is part of the public API. Common gaps:

  • A new file was added but never added to index.ts
  • A named export inside a file is not forwarded by the barrel
// src/components/MyWidget.ts
export class MyWidget { ... }
export type MyWidgetProps = { ... }

// src/components/index.ts — ❌ missing MyWidget
export { SomeOtherThing } from './SomeOtherThing';

Fix Pattern

Add the missing re-export line:

// src/components/index.ts — ✅ fixed
export { SomeOtherThing } from './SomeOtherThing';
export { MyWidget } from './MyWidget';
export type { MyWidgetProps } from './MyWidget';

Use export type { ... } for type-only exports to maintain strict type/value separation.


Step 6 — Apply Fixes and Verify

Order of operations

  1. Fix duplicate imports first (consolidation may surface type-only candidates).
  2. Fix **value vs. type im
अक्सर पूछे जाने वाले सवाल

barrel फ़ाइल क्या है?

यह एक इंडेक्स फ़ाइल है जो कई फ़ाइलों के एक्सपोर्ट एक जगह से इकट्ठा करती है, ताकि उन्हें एक ही स्थान से इंपोर्ट किया जा सके।

type-only इंपोर्ट का क्या मतलब है?

यह ऐसा इंपोर्ट है जो केवल टाइप लेबल के लिए इस्तेमाल होता है, जिसे चिह्नित किया जा सकता है ताकि वह रन टाइम पर लोड न हो।

क्या यह ऑडिट फ़ाइलें अपने-आप बदलता है?

स्किल पहले फ़ाइलें पढ़ती है और फिर सुधार लागू करती है, ताकि आप देख सकें कि क्या बदला।

जानकारी

लेखक का मूल विवरण

Systematic workflow for auditing TypeScript codebases for import hygiene issues (value vs. type imports, duplicates), missing base class extensions, and incomplete barrel file re-exports, with actionable fix patterns.

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#13085
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills