1.0.6 • Published 2 years ago

tsxgen v1.0.6

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

tsxgen

the most scuffed shit you've ever seen

anyways import what you want, you must import default as the jsxFactory option in your tsconfig, in my case, tsxgen

also import render if you want it to turn into actual code lol

import tsxgen, {
  render,
  Block,
  FunctionDeclaration,
  Identifier,
  ReturnStatement,
  StringLiteral,
  TypeReferenceNode,
  VariableDeclaration,
  VariableDeclarationList,
  VariableStatement
} from "./index";```

how make code?

the code below makes a function named test that defines a variable named b of string type with the value of "a" then returns b

console.log(
  render(
    <FunctionDeclaration name="test">
      <Block>
        <VariableStatement>
          <VariableDeclarationList flags={ts.NodeFlags.Const}>
            <VariableDeclaration
              name="b"
              type={<TypeReferenceNode typeName="string"></TypeReferenceNode>}
              initializer={<StringLiteral text="a"></StringLiteral>}
            ></VariableDeclaration>
          </VariableDeclarationList>
        </VariableStatement>
        <ReturnStatement>
          <Identifier text="b"></Identifier>
        </ReturnStatement>
      </Block>
    </FunctionDeclaration>
  )
);

output of above code

function test() {
  const b: string = "a";
  return b;
}

how it work?

i dont fucking know, id ont know why i wrote this, help

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago