Enhance documentation for sel net selectors with usage examples and type safety guidelines - #16
Open
rushabhcodes wants to merge 3 commits into
Open
Conversation
… type safety guidelines
There was a problem hiding this comment.
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.mdsection documentingsel.netusage for built-in nets vs custom nets (one-off and typed reusable). - Updated
SKILL.mdprompt guidance to steer generated code toward the safesel.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.
seveibar
reviewed
Apr 3, 2026
| - 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. |
Contributor
There was a problem hiding this comment.
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 |
seveibar
reviewed
Apr 3, 2026
seveibar
reviewed
Apr 3, 2026
seveibar
reviewed
Apr 3, 2026
…maps for custom nets
seveibar
reviewed
Apr 4, 2026
seveibar
reviewed
Apr 4, 2026
seveibar
reviewed
Apr 4, 2026
seveibar
reviewed
Apr 4, 2026
seveibar
reviewed
Apr 4, 2026
seveibar
reviewed
Apr 4, 2026
… maps for custom nets
Contributor
|
Idk why you would change a suggestion i carefully manually wrote lol |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
export const nets = sel.net<"MOTOR1_POS" | "MOTOR2_POS" | ... >()
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