Skip to content

Commit

Permalink
feat: api processors
Browse files Browse the repository at this point in the history
  • Loading branch information
skarab42 committed Jul 9, 2022
1 parent 8a5ba94 commit 4f8b5d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/plugin/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * as tsd from './tsd';
export * as tssert from './tssert';
8 changes: 8 additions & 0 deletions src/plugin/api/tsd/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type ts from 'byots';

export function processCallExpression(node: ts.CallExpression) {
const identifier = node.expression.getText();

// eslint-disable-next-line no-console
console.log('> tsd', { identifier });
}
8 changes: 8 additions & 0 deletions src/plugin/api/tssert/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type ts from 'byots';

export function processCallExpression(node: ts.CallExpression) {
const identifier = node.expression.getText();

// eslint-disable-next-line no-console
console.log('> tssert', { identifier });
}
10 changes: 4 additions & 6 deletions src/plugin/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { createProgram } from '../typescript/program';
import type { TypeScriptConfigOptions } from '../typescript/config';
import { type APIName, reportDiagnostics, tryToGetAPINAme } from './util';

import * as api from './api';

export interface TransformSettings {
code: string;
fileName: string;
Expand Down Expand Up @@ -50,14 +52,10 @@ function typeAssertion(fileName: string, sourceFile: ts.SourceFile, program: ts.
}

apiName = moduleAPIName;

// eslint-disable-next-line no-console
console.log({ apiName });
}

if (ts.isCallExpression(node)) {
// eslint-disable-next-line no-console
console.log('>', node.getText());
if (apiName && ts.isCallExpression(node)) {
api[apiName].processCallExpression(node);
}

node.forEachChild(visit);
Expand Down

0 comments on commit 4f8b5d1

Please sign in to comment.