Refact constants into separate type

Open
#889 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
tooling

Research direction

Start by locating the definition that currently types defaultValue and inspect how default values are represented. Introduce the proposed Constant shape there, update defaultValue to accept Constant or string, and run the repository's existing checks to confirm the definition remains valid.

Written by the indexing model from the issue text.

Description

CodeGen

I think this could be folded into defaultValue as a new Constant type (might be useful elsewhere).

/** Constant defines a Rust const declaration */
export interface Constant {
  kind: 'constant';

  /** the name of the const */
  name: string;

  /** the value of the const */
  value: Literal;

  /** indicates the visibility of the const */
  visibility: Visibility;
}

Then we can update the definition accordingly.

  defaultValue?: Constant | string;

Originally posted by @jhendrixMSFT in https://github.com/Azure/typespec-rust/pull/887#discussion_r2884751124

Dominant language
Rust
Stars
7
Forks
11
Avg merge
14h 15m
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/typespec-rust

All issues in Azure/typespec-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.