-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
28 lines (27 loc) · 914 Bytes
/
index.d.ts
File metadata and controls
28 lines (27 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* Core utilities for detecting React components and generating displayName code.
* These can be used to build custom plugins for other bundlers.
*
* @example
* ```js
* const { detectReactComponents, generateDisplayNameCode } = require('react-display-name-plugin');
* const { parse } = require('acorn');
*
* const code = 'function MyComponent() { return <div>Hello</div>; }';
* const ast = parse(code, { ecmaVersion: 'latest', sourceType: 'module' });
*
* detectReactComponents(ast, (node) => {
* const componentName = node.id.name;
* const injectionCode = generateDisplayNameCode(componentName);
* console.log(injectionCode); // ;try{MyComponent.displayName="MyComponent";}catch(e){}
* });
* ```
*/
export {
detectReactComponents,
generateDisplayNameCode,
argumentCreatesElement,
argumentJsx,
shouldAddDisplayName,
ComponentFoundCallback
} from './lib/component-detector';