|
| 1 | +/** |
| 2 | + * Example of const declaration |
| 3 | + */ |
| 4 | +export declare const conf: { |
| 5 | + apiUrl: 'https://api.stacksjs.org'; |
| 6 | + timeout: '5000' |
| 7 | +}; |
| 8 | +/** @defaultValue 'test' */ |
| 9 | +export declare let test: string; |
| 10 | +/** @defaultValue 'Hello World' */ |
| 11 | +export declare var helloWorld: string; |
| 12 | +/** |
| 13 | + * @defaultValue |
| 14 | + * ```ts |
| 15 | + * { |
| 16 | + * someString: 'Stacks', |
| 17 | + * someNumber: 1000, |
| 18 | + * someBoolean: true, |
| 19 | + * someFalse: false, |
| 20 | + * someFunction: () => unknown, |
| 21 | + * anotherOne: () => unknown, |
| 22 | + * someArray: [1, 2, 3], |
| 23 | + * someNestedArray: [ [1, 2, 3], [4, 5, 6, 7, 8, 9, 10], ], |
| 24 | + * someNestedArray2: [ [1, 2, 3], [4, 5, 6, 7, 8, 9, 10], 'dummy value', ], |
| 25 | + * someNestedArray3: [ [1, 2, 3], [4, 5, 6, 7, 8, 9, 10], 'dummy value', [11, 12, 13], ], |
| 26 | + * someObject: { key: 'value' }, |
| 27 | + * someNestedObject: { key: { nestedKey: 'value' }, otherKey: { nestedKey2: () => unknown } }, |
| 28 | + * someNestedObjectArray: [ { key: 'value' }, { key2: 'value2' }, ] |
| 29 | + * } |
| 30 | + * ``` |
| 31 | + */ |
| 32 | +export declare const someObject: { |
| 33 | + /** @defaultValue 'Stacks' */ |
| 34 | + someString: string; |
| 35 | + /** @defaultValue 1000 */ |
| 36 | + someNumber: number; |
| 37 | + /** @defaultValue true */ |
| 38 | + someBoolean: boolean; |
| 39 | + /** @defaultValue false */ |
| 40 | + someFalse: boolean; |
| 41 | + someFunction: () => unknown; |
| 42 | + anotherOne: () => unknown; |
| 43 | + someArray: number[]; |
| 44 | + someNestedArray: number[][]; |
| 45 | + someNestedArray2: (number[] | string)[]; |
| 46 | + someNestedArray3: (number[] | string)[]; |
| 47 | + someOtherNestedArray: ((string | number | unknown | (() => unknown))[] | number[])[]; |
| 48 | + someComplexArray: ({ |
| 49 | + /** @defaultValue 'value' */ |
| 50 | + key: string |
| 51 | +}[] | ({ |
| 52 | + /** @defaultValue 'value2' */ |
| 53 | + key2: string |
| 54 | +} | string | number)[] | (string | unknown)[])[]; |
| 55 | + someObject: { |
| 56 | + /** @defaultValue 'value' */ |
| 57 | + key: string |
| 58 | +}; |
| 59 | + someNestedObject: { key: { /** @defaultValue 'value' */ nestedKey: string }; otherKey: { nestedKey: unknown; nestedKey2: () => unknown } }; |
| 60 | + someNestedObjectArray: ({ |
| 61 | + /** @defaultValue 'value' */ |
| 62 | + key: string |
| 63 | +} | { |
| 64 | + /** @defaultValue 'value2' */ |
| 65 | + key2: string |
| 66 | +})[]; |
| 67 | + someOtherObject: unknown; |
| 68 | + someInlineCall2: unknown; |
| 69 | + someInlineCall3: unknown |
| 70 | +}; |
| 71 | +/** @defaultValue `{ 'Content-Type': 'application/json' }` */ |
| 72 | +export declare const defaultHeaders: { |
| 73 | + /** @defaultValue 'application/json' */ |
| 74 | + 'Content-Type': string |
| 75 | +}; |
| 76 | +/** |
| 77 | + * Complex Arrays and Tuples |
| 78 | + * @defaultValue |
| 79 | + * ```ts |
| 80 | + * { |
| 81 | + * matrix: [ [1, 2, [3, 4, [5, 6]]], ['a', 'b', ['c', 'd']], [true, [false, [true]]], ], |
| 82 | + * tuples: [ [1, 'string', true] as const, ['literal', 42, false] as const, ] |
| 83 | + * } |
| 84 | + * ``` |
| 85 | + */ |
| 86 | +export declare const complexArrays: { |
| 87 | + matrix: ((number | (number | number[])[])[] | (string | string[])[] | (boolean | (boolean | boolean[])[])[])[]; |
| 88 | + tuples: readonly [ |
| 89 | + readonly [1, 'string', true] | |
| 90 | + readonly ['literal', 42, false] |
| 91 | + ]; |
| 92 | + mixedArrays: (Date | Promise<string> | (() => unknown) | (() => Generator<any, any, any>))[] |
| 93 | +}; |
| 94 | +/** |
| 95 | + * Nested Object Types with Methods |
| 96 | + * @defaultValue |
| 97 | + * ```ts |
| 98 | + * { |
| 99 | + * handlers: { |
| 100 | + * onSuccess<T>: (data: T) => unknown, |
| 101 | + * onError: (error: Error & { code?: number }) => unknown, |
| 102 | + * someOtherMethod: () => unknown |
| 103 | + * }, |
| 104 | + * utils: { |
| 105 | + * formatters: { |
| 106 | + * date: (input: Date) => unknown, |
| 107 | + * currency: (amount: number, currency?) => unknown |
| 108 | + * } |
| 109 | + * } |
| 110 | + * } |
| 111 | + * ``` |
| 112 | + */ |
| 113 | +export declare const complexObject: { |
| 114 | + handlers: { onSuccess<T>: (data: T) => unknown; onError: (error: Error & { code?: number }) => unknown; someOtherMethod: () => unknown }; |
| 115 | + utils: { formatters: { date: (input: Date) => unknown; currency: (amount: number, currency?) => unknown } } |
| 116 | +}; |
| 117 | +// Method Decorators and Metadata (declares as unknown, because it should rely on explicit type) |
| 118 | +export declare const methodDecorator: ( |
| 119 | + target: any, |
| 120 | + propertyKey: string, |
| 121 | + descriptor: PropertyDescriptor |
| 122 | +) => unknown; |
| 123 | +// declares as SomeType |
| 124 | +export declare const methodDecoratorWithExplicitType: ( |
| 125 | + target: any, |
| 126 | + propertyKey: string, |
| 127 | + descriptor: PropertyDescriptor |
| 128 | +) => SomeType; |
| 129 | +// Complex Constants with Type Inference |
| 130 | +export declare const CONFIG_MAP: { |
| 131 | + development: { |
| 132 | + features: { |
| 133 | + auth: { |
| 134 | + providers: readonly ['google', 'github']; |
| 135 | + settings: { |
| 136 | + timeout: 5000; |
| 137 | + retries: 3 |
| 138 | +} |
| 139 | +} |
| 140 | +} |
| 141 | +}; |
| 142 | + production: { |
| 143 | + features: { |
| 144 | + auth: { |
| 145 | + providers: readonly ['google', 'github', 'microsoft']; |
| 146 | + settings: { |
| 147 | + timeout: 3000; |
| 148 | + retries: 5 |
| 149 | +} |
| 150 | +} |
| 151 | +} |
| 152 | +} |
| 153 | +}; |
| 154 | +export declare const command: { |
| 155 | + run: unknown; |
| 156 | + runSync: unknown |
| 157 | +}; |
0 commit comments