|
1 | 1 | import { expectType } from "tsd";
|
2 |
| -import { Base, Plugin } from "./index.js"; |
| 2 | +import { Base, ExtendBaseWith, Plugin } from "./index.js"; |
3 | 3 |
|
4 | 4 | import { fooPlugin } from "./plugins/foo/index.js";
|
5 | 5 | import { barPlugin } from "./plugins/bar/index.js";
|
@@ -238,3 +238,48 @@ const baseWithManyChainedDefaultsAndPlugins =
|
238 | 238 | expectType<string>(baseWithManyChainedDefaultsAndPlugins.foo);
|
239 | 239 | expectType<string>(baseWithManyChainedDefaultsAndPlugins.bar);
|
240 | 240 | expectType<string>(baseWithManyChainedDefaultsAndPlugins.getFooOption());
|
| 241 | + |
| 242 | +declare const RestApiClient: ExtendBaseWith< |
| 243 | + Base, |
| 244 | + { |
| 245 | + defaults: { |
| 246 | + defaultValue: string; |
| 247 | + }; |
| 248 | + plugins: [ |
| 249 | + () => { pluginValueOne: number }, |
| 250 | + () => { pluginValueTwo: boolean } |
| 251 | + ]; |
| 252 | + } |
| 253 | +>; |
| 254 | + |
| 255 | +expectType<string>(RestApiClient.defaults.defaultValue); |
| 256 | + |
| 257 | +// @ts-expect-error |
| 258 | +RestApiClient.defaults.unexpected; |
| 259 | + |
| 260 | +expectType<number>(RestApiClient.pluginValueOne); |
| 261 | +expectType<boolean>(RestApiClient.pluginValueTwo); |
| 262 | + |
| 263 | +// @ts-expect-error |
| 264 | +RestApiClient.unexpected; |
| 265 | + |
| 266 | +declare const MoreDefaultRestApiClient: ExtendBaseWith< |
| 267 | + typeof RestApiClient, |
| 268 | + { |
| 269 | + defaults: { |
| 270 | + anotherDefaultValue: number; |
| 271 | + }; |
| 272 | + } |
| 273 | +>; |
| 274 | + |
| 275 | +expectType<string>(MoreDefaultRestApiClient.defaults.defaultValue); |
| 276 | +expectType<number>(MoreDefaultRestApiClient.defaults.anotherDefaultValue); |
| 277 | + |
| 278 | +declare const MorePluginRestApiClient: ExtendBaseWith< |
| 279 | + typeof MoreDefaultRestApiClient, |
| 280 | + { |
| 281 | + plugins: [() => { morePluginValue: string[] }]; |
| 282 | + } |
| 283 | +>; |
| 284 | + |
| 285 | +expectType<string[]>(MorePluginRestApiClient.morePluginValue); |
0 commit comments