Skip to content

Commit f9212ac

Browse files
committed
Address reviews, consolidate code
1 parent fbc2707 commit f9212ac

35 files changed

+1479
-70
lines changed
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1-
export class Constructor {
2-
constructor(public readonly property: number) {}
1+
// export class Constructor {
2+
// constructor(public readonly property: number) {}
3+
// }
4+
5+
namespace Yay {
6+
export class SuperConstructor {
7+
constructor(public readonly property: number) {
8+
}
9+
}
10+
11+
export namespace Woo {
12+
export class MyClass {
13+
constructor() {}
14+
}
15+
}
16+
}
17+
18+
export class SuperConstructor2 {
19+
constructor(public readonly property: number) {
20+
}
21+
}
22+
23+
export function useConstructor(): Yay.SuperConstructor {
24+
return new Yay.SuperConstructor(10)
25+
}
26+
27+
export function useConstructor2(): SuperConstructor2 {
28+
return new SuperConstructor2(10)
329
}
430

5-
export function useConstructor(): Constructor {
6-
return new Constructor(Constructor.name.length)
31+
export function useConstructor3(): Yay.Woo.MyClass {
32+
return new Yay.Woo.MyClass()
733
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export function a(): string {
2+
// definition @example/a HEAD src/`a.ts`/
3+
//documentation ```ts\nmodule "a.ts"\n```
4+
// ^ definition @example/a HEAD src/`a.ts`/a().
5+
// documentation ```ts\nfunction a(): string\n```
6+
return ''
7+
}
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export function a(): string {
2+
// definition @example/a 1.0.0 src/`index.ts`/
3+
//documentation ```ts\nmodule "index.ts"\n```
4+
// ^ definition @example/a 1.0.0 src/`index.ts`/a().
5+
// documentation ```ts\nfunction a(): string\n```
6+
return ''
7+
}
8+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { a } from '@example/a/src'
2+
// definition @example/b 1.0.0 src/`b.ts`/
3+
//documentation ```ts\nmodule "b.ts"\n```
4+
// ^ reference @example/a 1.0.0 src/`index.ts`/a().
5+
// ^^^^^^^^^^^^^^^^ reference @example/a 1.0.0 src/`index.ts`/
6+
7+
export function b() {
8+
// ^ definition @example/b 1.0.0 src/`b.ts`/b().
9+
// documentation ```ts\nfunction b(): string\n```
10+
return a()
11+
// ^ reference @example/a 1.0.0 src/`index.ts`/a().
12+
}
13+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export function a(): string {
2+
// definition @example/a 1.0.0 src/`a.ts`/
3+
//documentation ```ts\nmodule "a.ts"\n```
4+
// ^ definition @example/a 1.0.0 src/`a.ts`/a().
5+
// documentation ```ts\nfunction a(): string\n```
6+
return ''
7+
}
8+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { a } from '@example/a'
2+
// definition @example/b 1.0.0 src/`b.ts`/
3+
//documentation ```ts\nmodule "b.ts"\n```
4+
// ^ reference local 0
5+
6+
export function b() {
7+
// ^ definition @example/b 1.0.0 src/`b.ts`/b().
8+
// documentation ```ts\nfunction b(): any\n```
9+
return a()
10+
// ^ reference local 0
11+
}
12+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React from 'react'
2+
// definition react-example 1.0.0 src/`LoaderInput.tsx`/
3+
//documentation ```ts\nmodule "LoaderInput.tsx"\n```
4+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
5+
// ^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/
6+
7+
/** Takes loading prop, input component as child */
8+
interface Props {
9+
// ^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#
10+
// documentation ```ts\ninterface Props\n```
11+
// documentation Takes loading prop, input component as child
12+
loading: boolean
13+
// ^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
14+
// documentation ```ts\n(property) loading: boolean\n```
15+
children: React.ReactNode
16+
// ^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
17+
// documentation ```ts\n(property) children: ReactNode\n```
18+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
19+
// ^^^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/ReactNode#
20+
}
21+
22+
export const LoaderInput: React.FunctionComponent<Props> = ({
23+
// ^^^^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput.
24+
// documentation ```ts\nvar LoaderInput: FunctionComponent<Props>\n```
25+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
26+
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/FunctionComponent#
27+
// ^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#
28+
loading,
29+
// ^^^^^^^ definition local 3
30+
// documentation ```ts\n(parameter) loading: boolean\n```
31+
// ^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
32+
children,
33+
// ^^^^^^^^ definition local 4
34+
// documentation ```ts\n(parameter) children: ReactNode\n```
35+
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
36+
// ^^^^^^^^ reference local 7
37+
}) => (
38+
<div className="hello">
39+
// ^^^ reference @types/react 17.0.52 `index.d.ts`/global/JSX/IntrinsicElements#div.
40+
// ^^^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/HTMLAttributes#className.
41+
{children}
42+
// ^^^^^^^^ reference local 4
43+
{loading && <p>spinner</p>}
44+
// ^^^^^^^ reference local 3
45+
// ^ reference @types/react 17.0.52 `index.d.ts`/global/JSX/IntrinsicElements#p.
46+
// ^ reference @types/react 17.0.52 `index.d.ts`/global/JSX/IntrinsicElements#p.
47+
</div>
48+
// ^^^ reference @types/react 17.0.52 `index.d.ts`/global/JSX/IntrinsicElements#div.
49+
)
50+
51+
export const LoaderInput2: React.FunctionComponent<Props> = props => {
52+
// ^^^^^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput2.
53+
// documentation ```ts\nvar LoaderInput2: FunctionComponent<Props>\n```
54+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
55+
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/FunctionComponent#
56+
// ^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#
57+
// ^^^^^ definition local 9
58+
// documentation ```ts\n(parameter) props: PropsWithChildren<Props>\n```
59+
return <LoaderInput loading={true} key="key" children={props.children} />
60+
// ^^^^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput.
61+
// ^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
62+
// ^^^ reference local 13
63+
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
64+
// ^^^^^ reference local 9
65+
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
66+
// ^^^^^^^^ reference local 7
67+
}
68+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
// definition react-example 1.0.0 src/`MyTSXElement.tsx`/
3+
//documentation ```ts\nmodule "MyTSXElement.tsx"\n```
4+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
5+
// ^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/
6+
7+
export interface MyProps {}
8+
// ^^^^^^^ definition react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
9+
// documentation ```ts\ninterface MyProps\n```
10+
11+
export const MyTSXElement: React.FunctionComponent<MyProps> = ({}) => (<p></p>)
12+
// ^^^^^^^^^^^^ definition react-example 1.0.0 src/`MyTSXElement.tsx`/MyTSXElement.
13+
// documentation ```ts\nvar MyTSXElement: FunctionComponent<MyProps>\n```
14+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
15+
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/FunctionComponent#
16+
// ^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
17+
// ^ reference @types/react 17.0.52 `index.d.ts`/global/JSX/IntrinsicElements#p.
18+
// ^ reference @types/react 17.0.52 `index.d.ts`/global/JSX/IntrinsicElements#p.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from "react";
2+
// definition react-example 1.0.0 src/`UseMyTSXElement.tsx`/
3+
//documentation ```ts\nmodule "UseMyTSXElement.tsx"\n```
4+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
5+
// ^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/
6+
7+
import { MyProps, MyTSXElement } from "./MyTSXElement";
8+
// ^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
9+
// ^^^^^^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyTSXElement.
10+
// ^^^^^^^^^^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/
11+
12+
export const _: React.FunctionComponent<MyProps> =
13+
// ^ definition react-example 1.0.0 src/`UseMyTSXElement.tsx`/_.
14+
// documentation ```ts\nvar _: FunctionComponent<MyProps>\n```
15+
// ^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/
16+
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.52 `index.d.ts`/React/FunctionComponent#
17+
// ^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
18+
({}) => (<MyTSXElement></MyTSXElement>)
19+
// ^^^^^^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyTSXElement.
20+
// ^^^^^^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyTSXElement.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
export class ClassWithPrivate {
2+
// definition syntax 1.0.0 src/`ClassWithPrivate.ts`/
3+
//documentation ```ts\nmodule "ClassWithPrivate.ts"\n```
4+
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
5+
// documentation ```ts\nclass ClassWithPrivate\n```
6+
#privateField
7+
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
8+
// documentation ```ts\n(property) #privateField: any\n```
9+
#privateFieldWithInitializer = 42
10+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateFieldWithInitializer`.
11+
// documentation ```ts\n(property) #privateFieldWithInitializer: number\n```
12+
13+
#privateMethod() {
14+
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateMethod`().
15+
// documentation ```ts\n(method) #privateMethod(): any\n```
16+
this.#privateField = 'private field'
17+
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
18+
return this.#privateField
19+
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
20+
}
21+
22+
static #privateStaticField
23+
// ^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticField`.
24+
// documentation ```ts\n(property) #privateStaticField: any\n```
25+
static #privateStaticFieldWithInitializer = 42
26+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticFieldWithInitializer`.
27+
// documentation ```ts\n(property) #privateStaticFieldWithInitializer: number\n```
28+
29+
static #privateStaticMethod() {}
30+
// ^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticMethod`().
31+
// documentation ```ts\n(method) #privateStaticMethod(): void\n```
32+
public publicMethod(): any[] {
33+
// ^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#publicMethod().
34+
// documentation ```ts\n(method) publicMethod(): any[]\n```
35+
return [
36+
this.#privateField,
37+
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
38+
this.#privateFieldWithInitializer,
39+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateFieldWithInitializer`.
40+
this.#privateMethod(),
41+
// ^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateMethod`().
42+
ClassWithPrivate.#privateStaticMethod(),
43+
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
44+
// ^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticMethod`().
45+
ClassWithPrivate.#privateStaticField,
46+
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
47+
// ^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticField`.
48+
ClassWithPrivate.#privateStaticFieldWithInitializer,
49+
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
50+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticFieldWithInitializer`.
51+
]
52+
}
53+
}
54+

0 commit comments

Comments
 (0)