Debian Codegraph @

types/README.md

raw symbols SCIP
1 # @withfig/autocomplete-types package
2
3 This is the package providing types for our autocomplete app.
4
5 ## Typings for fig autocomplete specs and other tools
6
7 Configure the global Fig namespace in your `tsconfig.json`:
8
9 ```jsonc
10 {
11 "compilerOptions": {
12 // you may get some typecheck errors if you are using some node packages like "fs"
13 // just include "node" in the below array. Same for "jest", "chai"...and so on.
14 "types": ["@withfig/autocomplete-types"]
15 },
16 }
17 ```
18
19 ### FAQs
20
21 - I have done everything described above but I can't get my IDE (e.g. VSCode) to detect the autocomplete types, what can I do?
22 You should try some of the following steps:
23 1) Restart the IDE
24 2) Delete your `node_modules/` folder and reinstall again the packages
25 3) Restart the system
26
27 If you are still unable to use `@withfig/autocomplete-types`, please open an issue [here](https://github.com/withfig/autocomplete-tools/issues).
28
29 ## Documenting the API
30 We use [TSDocs](https://tsdoc.org) to comment the exported symbols of the Fig namespace.
31 In our docs generator, which is executed on our backend each time the types are updated, we perform some custom Typescript AST traversals and we retrieve all the exported nodes with their TSDoc comments.
32 > For Fig members: see the website repo to find out more about the custom generator we are using for docs
33
34 ### How are the docs organized once they are parsed from the Typescript AST?
35
36 First of all we generate an entire page on the website for each of the main interfaces available in the Fig namespace, all the typealiases go to the "Others" page.
37
38 ### Supported TSDoc tags and custom JSDoc tags
39
40 #### `Interface`
41 - @filename: to change the target filename of an interface (internal)
42 - @excluded: do not generate docs for the Interface
43
44 #### `Typealias`
45
46 - @param: The params of an exported function, the format MUST be `@param <name of the param> <some description>`. It can be provided multiple times for different params.
47 ```ts
48 /**
49 * @param value some description for the value param
50 */
51 type Callback = (value) => void
52 ```
53 - @returns: An explanation of what is returned by a function.
54 ```ts
55 /**
56 * @param value some description for the value param
57 * @returns nothing
58 */
59 type Callback = (value) => void
60 ```
61 - @remarks: Further details about the implementation of the method, use cases...etc. This data will appear in the `Discussion` section.
62 - @example: Provide examples about the usage of the API object. It is repeatable.
63 - @excluded: do not generate docs for the Typealias
64
65 #### `Interface` member
66 - @param: The params of an exported function, the format MUST be `@param <name of the param> <some description>`. It can be provided multiple times for different params.
67 ```ts
68 /**
69 * @param value some description for the value param
70 */
71 memberName: (value) => void
72 ```
73 - @returns: An explanation of what is returned by a function.
74 ```ts
75 /**
76 * @param value some description for the value param
77 * @returns nothing
78 */
79 memberName: (value) => void
80 ```
81 - @remarks: Further details about the implementation of the method, use cases...etc. This data will appear in the `Discussion` section.
82 - @example: Provide examples about the usage of the API object. It is repeatable.
83 - @defaultValue: define the default value of a member.
84 - @deprecated: Mark an API as deprecated providing an optional message about the deprecation.
85 ```ts
86 /**
87 * @deprecated This message is optional
88 */
89 export const didChange = {
90 subscribe: (notification) => { },
91 }
92 ```
93 - @excluded: do not generate docs for the member
94 - @category: assign a category to an interface member
95
96 #### Custom resolution
97
98 We perform some analysis over the types before generating the docs.
99 In particular all the types from the Fig namespace are replaced recursively with Typescript primitive types like functions, string...
100
101 For `Interface members` and `Typealiases` are available some additional tags that prevent complete or partial replacements of the Types.
102
103 - @irreplaced: do not replace any Symbol contained in the one tagged
104 ```ts
105 // e.g. with the irreplaced tag
106 type Data = string
107 /**
108 * @irreplaced
109 */
110 type Res = Data
111 // will output
112 type Data = string
113 type Res = Data
114 ```
115 ```ts
116 // e.g. without the irreplaced tag
117 type Data = string
118 type Res = Data
119 // will output
120 type Data = string
121 type Res = string
122 ```
123 - @irreplaceable: this Typealias cannot be replaced in any Symbol that references the tagged one
124 ```ts
125 // e.g. with the irreplaceable tag
126 /**
127 * @irreplaceable
128 */
129 type Data = string
130 type Res = Data
131 // will output
132 type Data = string
133 type Res = Data
134 ```
135 ```ts
136 // e.g. without the irreplaceable tag
137 type Data = string
138 type Res = Data
139 // will output
140 type Data = string
141 type Res = string
142 ```
143 - @replaceFirstLevel: only replaces the direct Symbols contained in the tagged one, then act as @irreplaceable for those Symbols
144
145
146 > IMPORTANT: when using types that reference themselves add an `@irreplaceable` tag to them (see SubcommandDiff)