Skip to content

Enhance documentation for sel net selectors with usage examples and type safety guidelines - #16

Open
rushabhcodes wants to merge 3 commits into
tscircuit:mainfrom
rushabhcodes:docs/custom-net-sel-usage
Open

Enhance documentation for sel net selectors with usage examples and type safety guidelines#16
rushabhcodes wants to merge 3 commits into
tscircuit:mainfrom
rushabhcodes:docs/custom-net-sel-usage

Conversation

@rushabhcodes

@rushabhcodes rushabhcodes commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR improves the tscircuit docs around sel net selectors so AI-generated and human-written code are more likely to use the type-safe pattern for custom nets.

It adds explicit guidance that sel.net.GND-style property access is for common built-in nets, while custom nets should be defined through a shared typed selector map.

Problem

The existing docs did not clearly separate built-in net access from custom net access, which made it easier for generated code to drift toward unsupported or non-type-safe custom net patterns.

That ambiguity can lead to TypeScript errors when custom nets are accessed as if they were part of the built-in sel.net.* set.

Changes

  • Added a new sel net selectors section to SYNTAX.md
  • Documented sel.net.GND and similar property access as the pattern for common built-in nets
  • Added a typed custom-net example using a shared nets.ts selector map:
    export const nets = sel.net<"MOTOR1_POS" | "MOTOR2_POS" | ... >()
  • Added matching guidance to SKILL.md so the skill prompt and syntax primer are aligned
  • Renumbered the later SYNTAX.md sections after inserting the new selector guidance

Impact

This should reduce a common docs-driven codegen mistake around custom net selectors and make the recommended custom-net workflow clearer and more type-safe.

tscircuit/tscircuit#2815

Copilot AI review requested due to automatic review settings April 3, 2026 19:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the tscircuit syntax/skill documentation to clarify the correct, type-safe patterns for using sel net selectors—especially for arbitrary custom net names—to reduce TypeScript errors in generated code.

Changes:

  • Added a new SYNTAX.md section documenting sel.net usage for built-in nets vs custom nets (one-off and typed reusable).
  • Updated SKILL.md prompt guidance to steer generated code toward the safe sel.net() / sel.net<...>() patterns.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
SYNTAX.md Adds a dedicated section explaining sel net selector usage patterns and examples.
SKILL.md Adds a prompt/skill bullet that summarizes the safe sel net selector patterns for AI-generated code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SYNTAX.md Outdated
Comment thread SKILL.md Outdated
Comment thread SKILL.md Outdated
- PCB: `pcbX`, `pcbY`, `pcbRotation`, `layer`
- Schematic: `schX`, `schY`, `schRotation`, `schOrientation`
- Use `<trace />` for connectivity; prefer net connections (`net.GND`, `net.VCC`, etc.) for power/ground.
- When using `sel` for nets, use `sel.net.GND`-style property access only for common built-in nets. For arbitrary custom nets, prefer `sel.net().USB_DP_RAW` for one-offs or `const nets = sel.net<"USB_DP_RAW" | "USB_DM_RAW">()` for reusable typed custom nets.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- When using `sel` for nets, use `sel.net.GND`-style property access only for common built-in nets. For arbitrary custom nets, prefer `sel.net().USB_DP_RAW` for one-offs or `const nets = sel.net<"USB_DP_RAW" | "USB_DM_RAW">()` for reusable typed custom nets.
- When using `sel` for nets, use `sel.net.GND`-style property access only for common built-in nets. For custom nets, put `export const nets = sel.net<"MOTOR_NEG" | "MOTOR_POS" | ...>()` inside a `nets.ts` file

Comment thread SYNTAX.md
Comment thread SYNTAX.md Outdated
Comment thread SYNTAX.md Outdated

@seveibar seveibar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good. See comments

Comment thread SKILL.md Outdated
Comment thread SYNTAX.md Outdated
Comment thread SYNTAX.md
Comment thread SYNTAX.md Outdated
Comment thread SYNTAX.md Outdated
Comment thread SKILL.md Outdated

@seveibar seveibar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@seveibar seveibar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typos present

@seveibar

seveibar commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Idk why you would change a suggestion i carefully manually wrote lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants