ts-creator
Advanced tools
Comparing version 1.0.5 to 1.0.10
{ | ||
"name": "ts-creator", | ||
"version": "1.0.5", | ||
"version": "1.0.10", | ||
"description": "A code generator to generate TypeScript code generator from TypeScript code", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -7,2 +7,25 @@ # ts-creator | ||
## How to use it: | ||
``` | ||
npm install ts-creator | ||
``` | ||
### 1. generate from code | ||
```ts | ||
import creator from 'ts-creator' | ||
const generatedFactoryCode = creator(`const foo = "your code here"`) | ||
``` | ||
### 2. transform source file | ||
```ts | ||
import { transformSourceFile } from 'ts-creator' | ||
declare const file: ts.SourceFile | ||
const factoryFile = transformSourceFile(file) | ||
``` | ||
## How does it work? | ||
@@ -70,10 +93,2 @@ | ||
## How to use it: | ||
```ts | ||
import creator from 'ts-creator' | ||
const generatedFactoryCode = creator(`const foo = "your code here"`) | ||
``` | ||
## TODO: | ||
@@ -80,0 +95,0 @@ |
@@ -17,3 +17,3 @@ import * as ts from 'typescript' | ||
interface Options { | ||
export interface Options { | ||
prettierOptions?: prettier.Options | ||
@@ -1284,2 +1284,6 @@ } | ||
export function transformNode(node: ts.Node): ts.Expression { | ||
return transformVisitor(node) | ||
} | ||
export function transformSourceFile(sourceFile: ts.SourceFile): ts.SourceFile { | ||
@@ -1293,3 +1297,3 @@ return ts.updateSourceFileNode(sourceFile, [ | ||
const printer = ts.createPrinter() | ||
const file = ts.createSourceFile('unknow.ts', code, ts.ScriptTarget.Latest) | ||
const file = ts.createSourceFile('templory.ts', code, ts.ScriptTarget.Latest) | ||
const factoryFile = transformSourceFile(file) | ||
@@ -1296,0 +1300,0 @@ const factoryCode = printer.printFile(factoryFile) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138521
2465
96