Skip to content

Commit

Permalink
refactor(napi): move custom types to bottom of file (#6930)
Browse files Browse the repository at this point in the history
Pure refactor. Doesn't matter much but I think it's preferable for the file not to start with the most random weird types.
  • Loading branch information
overlookmotel committed Oct 26, 2024
1 parent 23157bd commit 9926990
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
66 changes: 33 additions & 33 deletions npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
// Auto-generated code, DO NOT EDIT DIRECTLY!
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs`

export interface FormalParameterRest extends Span {
type: 'RestElement';
argument: BindingPatternKind;
typeAnnotation: TSTypeAnnotation | null;
optional: boolean;
}

export type RegExpFlags = {
/** Global flag */
G: 1;
/** Ignore case flag */
I: 2;
/** Multiline flag */
M: 4;
/** DotAll flag */
S: 8;
/** Unicode flag */
U: 16;
/** Sticky flag */
Y: 32;
/** Indices flag */
D: 64;
/** Unicode sets flag */
V: 128;
};

export type JSXElementName =
| JSXIdentifier
| JSXNamespacedName
| JSXMemberExpression;

export type JSXMemberExpressionObject = JSXIdentifier | JSXMemberExpression;

export interface BooleanLiteral extends Span {
type: 'BooleanLiteral';
value: boolean;
Expand Down Expand Up @@ -2008,3 +1975,36 @@ export interface NamedReference extends Span {
type: 'NamedReference';
name: string;
}

export interface FormalParameterRest extends Span {
type: 'RestElement';
argument: BindingPatternKind;
typeAnnotation: TSTypeAnnotation | null;
optional: boolean;
}

export type RegExpFlags = {
/** Global flag */
G: 1;
/** Ignore case flag */
I: 2;
/** Multiline flag */
M: 4;
/** DotAll flag */
S: 8;
/** Unicode flag */
U: 16;
/** Sticky flag */
Y: 32;
/** Indices flag */
D: 64;
/** Unicode sets flag */
V: 128;
};

export type JSXElementName =
| JSXIdentifier
| JSXNamespacedName
| JSXMemberExpression;

export type JSXMemberExpressionObject = JSXIdentifier | JSXMemberExpression;
5 changes: 3 additions & 2 deletions tasks/ast_tools/src/generators/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ define_generator!(TypescriptGenerator);

impl Generator for TypescriptGenerator {
fn generate(&mut self, ctx: &LateCtx) -> Output {
let mut code = format!("{CUSTOM_TYPESCRIPT}\n");

let mut code = String::new();
for def in ctx.schema() {
if !def.generates_derive("ESTree") {
continue;
Expand All @@ -37,6 +36,8 @@ impl Generator for TypescriptGenerator {
code.push_str("\n\n");
}

code.push_str(CUSTOM_TYPESCRIPT);

Output::Javascript { path: format!("{}/types.d.ts", crate::TYPESCRIPT_PACKAGE), code }
}
}
Expand Down

0 comments on commit 9926990

Please sign in to comment.