docs(ast): improve docs examples for PropertyDefinition (#7287)

This commit is contained in:
overlookmotel 2024-11-14 22:28:14 +00:00
parent b57d00d6fb
commit f0affa20c6

View file

@ -1928,13 +1928,14 @@ pub struct PropertyDefinition<'a> {
/// Initialized value in the declaration. /// Initialized value in the declaration.
/// ///
/// ## Example /// ## Example
/// ``` /// ```ts
/// class Foo { /// class Foo {
/// x = 5 // Some(NumericLiteral) /// x = 5; // Some(NumericLiteral)
/// y: string // None /// y; // None
/// z: string; // None
/// ///
/// constructor() { /// constructor() {
/// this.y = "hello" /// this.z = "hello";
/// } /// }
/// } /// }
/// ``` /// ```
@ -1942,10 +1943,10 @@ pub struct PropertyDefinition<'a> {
/// Property was declared with a computed key /// Property was declared with a computed key
/// ///
/// ## Example /// ## Example
/// ```ts /// ```js
/// class Foo { /// class Foo {
/// ["a"]: string // true /// ["a"]: 1; // true
/// b: number // false /// b: 2; // false
/// } /// }
/// ``` /// ```
pub computed: bool, pub computed: bool,
@ -1956,12 +1957,12 @@ pub struct PropertyDefinition<'a> {
/// ## Example /// ## Example
/// ```ts /// ```ts
/// class Foo { /// class Foo {
/// x: number // false /// x: number; // false
/// declare y: string // true /// declare y: string; // true
/// } /// }
/// ///
/// declare class Bar { /// declare class Bar {
/// x: number // false /// x: number; // false
/// } /// }
/// ``` /// ```
#[ts] #[ts]
@ -1989,10 +1990,10 @@ pub struct PropertyDefinition<'a> {
/// ///
/// ```ts /// ```ts
/// class Foo { /// class Foo {
/// public w: number // Some(TSAccessibility::Public) /// public w: number; // Some(TSAccessibility::Public)
/// private x: string // Some(TSAccessibility::Private) /// private x: string; // Some(TSAccessibility::Private)
/// protected y: boolean // Some(TSAccessibility::Protected) /// protected y: boolean; // Some(TSAccessibility::Protected)
/// readonly z // None /// readonly z; // None
/// } /// }
/// ``` /// ```
#[ts] #[ts]