Skip to content

Commit

Permalink
Enhancement: Add types for babel-plugin's static methods (#102)
Browse files Browse the repository at this point in the history
The default export is a function with additional static methods on the function, but the types didn't know this.
This change adds a manual type annotation.
  • Loading branch information
nonzzz authored Dec 8, 2023
1 parent c81b984 commit 1c90481
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/babel-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type Options = StyleXOptions;
/**
* Entry point for the StyleX babel plugin.
*/
export default function styleXTransform(): PluginObj<> {
function styleXTransform(): PluginObj<> {
// To simplify state management, we use a StateManager object to abstract
// away some of the details.
let state: StateManager;
Expand Down Expand Up @@ -302,3 +302,12 @@ function addSpecificityLevel(selector: string, index: number): string {
return `${beforeCurly}${pseudo}${afterCurly}`;
}

export type StyleXTransformObj = {
(): PluginObj<>,
withOptions: typeof styleXTransform.withOptions,
processStylexRules: typeof processStylexRules,
...
};

export default (styleXTransform: StyleXTransformObj);

0 comments on commit 1c90481

Please sign in to comment.