Skip to content

Commit

Permalink
docs(ast): improve docs examples for PropertyDefinition (#7287)
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Nov 14, 2024
1 parent b57d00d commit f0affa2
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1928,24 +1928,25 @@ pub struct PropertyDefinition<'a> {
/// Initialized value in the declaration.
///
/// ## Example
/// ```
/// ```ts
/// class Foo {
/// x = 5 // Some(NumericLiteral)
/// y: string // None
/// x = 5; // Some(NumericLiteral)
/// y; // None
/// z: string; // None
///
/// constructor() {
/// this.y = "hello"
/// this.z = "hello";
/// }
/// }
/// ```
pub value: Option<Expression<'a>>,
/// Property was declared with a computed key
///
/// ## Example
/// ```ts
/// ```js
/// class Foo {
/// ["a"]: string // true
/// b: number // false
/// ["a"]: 1; // true
/// b: 2; // false
/// }
/// ```
pub computed: bool,
Expand All @@ -1956,12 +1957,12 @@ pub struct PropertyDefinition<'a> {
/// ## Example
/// ```ts
/// class Foo {
/// x: number // false
/// declare y: string // true
/// x: number; // false
/// declare y: string; // true
/// }
///
/// declare class Bar {
/// x: number // false
/// x: number; // false
/// }
/// ```
#[ts]
Expand Down Expand Up @@ -1989,10 +1990,10 @@ pub struct PropertyDefinition<'a> {
///
/// ```ts
/// class Foo {
/// public w: number // Some(TSAccessibility::Public)
/// private x: string // Some(TSAccessibility::Private)
/// protected y: boolean // Some(TSAccessibility::Protected)
/// readonly z // None
/// public w: number; // Some(TSAccessibility::Public)
/// private x: string; // Some(TSAccessibility::Private)
/// protected y: boolean; // Some(TSAccessibility::Protected)
/// readonly z; // None
/// }
/// ```
#[ts]
Expand Down

0 comments on commit f0affa2

Please sign in to comment.