1.0.1 • Published 5 years ago
ts-fn-source-code-range-recorder v1.0.1
ts-fn-source-code-range-recorder
Introduction
This transformer records all code range of function declarations and arrow functions into a json file named .file-fn-range.json in the project root.
Sample:
|---my-app
| |---src
| | |---inner
| | | |---b.ts
| | |---a.tssrc/a.ts:
export function add(a: number, b: number): number {
return a + b;
}src/inner/b.ts:
export const add = (a: number, b: number): number => {
return a + b;
}
export class Calc {
add(a: number, b: number): number {
return a + b;
}
}_fileFnRange.json:
{
"src/a.ts": [
{
"start": 0,
"end": 69
}
],
"src/inner/b.ts": [
{
"start": 6,
"end": 72
},
{
"start": 18,
"end": 72
},
{
"start": 93,
"end": 153
}
]
}Installation
$ npm i -D ts-fn-source-code-range-recorderUsage
Assumes that your source code directory is src and tsconfig.json is in the project root.
Creates a new file named "compile.ts" in the project root with following content:s
import { compile } from "ts-fn-source-code-range-recorder";
compile("src", "tsconfig.json");Then run
$ ts-node compile.tsto compile your code into JS.