mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[@wordpress/deprecated] add new definitions (#36684)
This commit is contained in:
parent
0f4a6a3b3a
commit
ae6aa49a5f
57
types/wordpress__deprecated/index.d.ts
vendored
Normal file
57
types/wordpress__deprecated/index.d.ts
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
// Type definitions for @wordpress/deprecated 2.4
|
||||
// Project: https://github.com/WordPress/gutenberg/tree/master/packages/deprecated/README.md
|
||||
// Definitions by: Derek Sifford <https://github.com/dsifford>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.5
|
||||
|
||||
export interface DeprecatedOptions {
|
||||
/**
|
||||
* Feature to use instead.
|
||||
*/
|
||||
alternative?: string;
|
||||
/**
|
||||
* Additional message to help transition away from the deprecated feature.
|
||||
*/
|
||||
hint?: string;
|
||||
/**
|
||||
* Link to documentation.
|
||||
*/
|
||||
link?: string;
|
||||
/**
|
||||
* Plugin name if it's a plugin feature.
|
||||
*/
|
||||
plugin?: string;
|
||||
/**
|
||||
* Version in which the feature will be removed.
|
||||
*/
|
||||
version?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object map tracking messages which have been logged, for use in ensuring a message is only logged once.
|
||||
*/
|
||||
export const logged: Record<string, boolean | undefined>;
|
||||
|
||||
/**
|
||||
* Logs a message to notify developers about a deprecated feature.
|
||||
*
|
||||
* @param feature Name of the deprecated feature.
|
||||
* @param [options] Additional options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import deprecated from '@wordpress/deprecated';
|
||||
*
|
||||
* deprecated( 'Eating meat', {
|
||||
* version: 'the future',
|
||||
* alternative: 'vegetables',
|
||||
* plugin: 'the earth',
|
||||
* hint: 'You may find it beneficial to transition gradually.',
|
||||
* } );
|
||||
*
|
||||
* // Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.'
|
||||
* ```
|
||||
*/
|
||||
declare function deprecated(feature: string, options?: DeprecatedOptions): void;
|
||||
|
||||
export default deprecated;
|
||||
19
types/wordpress__deprecated/tsconfig.json
Normal file
19
types/wordpress__deprecated/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@wordpress/deprecated": ["wordpress__deprecated"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "wordpress__deprecated-tests.ts"]
|
||||
}
|
||||
1
types/wordpress__deprecated/tslint.json
Normal file
1
types/wordpress__deprecated/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
17
types/wordpress__deprecated/wordpress__deprecated-tests.ts
Normal file
17
types/wordpress__deprecated/wordpress__deprecated-tests.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import deprecated, { logged } from '@wordpress/deprecated';
|
||||
|
||||
// $ExpectType void
|
||||
deprecated('foo');
|
||||
|
||||
deprecated('foo', { alternative: 'bar' });
|
||||
deprecated('foo', { hint: 'bar' });
|
||||
deprecated('foo', { link: 'bar' });
|
||||
deprecated('foo', { plugin: 'bar' });
|
||||
deprecated('foo', { version: 'bar' });
|
||||
deprecated('foo', { alternative: 'bar', hint: 'baz', version: 'qux' });
|
||||
|
||||
// $ExpectType Record<string, boolean | undefined>
|
||||
logged;
|
||||
|
||||
// $ExpectType boolean | undefined
|
||||
logged.foo;
|
||||
Loading…
Reference in New Issue
Block a user