Skip to content

Fix typo in enum-like code sample #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged

Fix typo in enum-like code sample #627

merged 3 commits into from
Jun 27, 2025

Conversation

eliykat
Copy link
Member

@eliykat eliykat commented Jun 25, 2025

🎟️ Tracking

N/A

📔 Objective

Fix what I think is a typo in #624. The code sample refers to _CipherType which is undefined, I think this is a remnant from the previous code example which used this convention.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@eliykat eliykat requested a review from audreyality June 25, 2025 01:38
@eliykat eliykat requested a review from a team as a code owner June 25, 2025 01:38
@github-actions github-actions bot added the adr label Jun 25, 2025
Copy link

cloudflare-workers-and-pages bot commented Jun 25, 2025

Deploying contributing-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: c59d178
Status: ✅  Deploy successful!
Preview URL: https://4dcad755.contributing-docs.pages.dev
Branch Preview URL: https://fix-enumlike-example.contributing-docs.pages.dev

View logs

Copy link

github-actions bot commented Jun 25, 2025

Logo
Checkmarx One – Scan Summary & Detailse6c26dcf-d30b-4ff6-95ff-6b2924fcf94b

Great job, no security vulnerabilities found in this Pull Request

@audreyality audreyality requested a review from a team as a code owner June 25, 2025 11:33
@audreyality audreyality removed their request for review June 25, 2025 11:33
@djsmith85 djsmith85 requested a review from audreyality June 25, 2025 11:44
withinfocus
withinfocus previously approved these changes Jun 25, 2025
Copy link
Contributor

@withinfocus withinfocus left a comment

Choose a reason for hiding this comment

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

It's all magic to me.

Comment on lines +38 to +46
export const CipherType = Object.freeze({
Login: 1,
SecureNote: 2,
Card: 3,
Identity: 4,
SshKey: 5,
} as const);

export type CipherType = _CipherType[keyof typeof CipherType];
export type CipherType = (typeof CipherType)[keyof typeof CipherType];
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering about side-by-side exported const and type declarations with the same name, so I gave it a go. It's still surprising to me that in this case import { CipherType } from "@bitwarden/common/vault/enums"; brings in both concerns, but yeah, it works... nicely!

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't consider this... 🤯 handy though!

Copy link
Member

Choose a reason for hiding this comment

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

The way that the symbols work is not unlike C namespaces. Both namespaces end up being imported. You don't need to specify them, however, because whether the symbol is in type or data position can be inferred.

Copy link
Contributor

@jprusik jprusik Jun 27, 2025

Choose a reason for hiding this comment

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

whether the symbol is in type or data position can be inferred

I wonder if there are any cases where it can't be inferred... (I couldn't think of any)? 🤔

Comment on lines +38 to +46
export const CipherType = Object.freeze({
Login: 1,
SecureNote: 2,
Card: 3,
Identity: 4,
SshKey: 5,
} as const);

export type CipherType = _CipherType[keyof typeof CipherType];
export type CipherType = (typeof CipherType)[keyof typeof CipherType];
Copy link
Contributor

@jprusik jprusik Jun 25, 2025

Choose a reason for hiding this comment

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

Probably worth mentioning, this specific example is not what main currently looks like, and should be updated in the actual code to match this updated example/guidance (once the blocking typescript version is available).

@eliykat eliykat requested review from withinfocus and a team June 26, 2025 03:10
@eliykat
Copy link
Member Author

eliykat commented Jun 26, 2025

Requesting a review from dept-architecture, which is needed to update the ADR.

@audreyality audreyality removed their request for review June 26, 2025 17:35
@eliykat eliykat merged commit 74f4bb7 into main Jun 27, 2025
10 checks passed
@eliykat eliykat deleted the fix-enumlike-example branch June 27, 2025 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants