优化
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* This is bar
|
||||
*/
|
||||
export function bar() {
|
||||
console.log('Anything else');
|
||||
}
|
||||
|
||||
interface E {
|
||||
f: symbol;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
a: number;
|
||||
b: string;
|
||||
c: {
|
||||
d: string;
|
||||
e: E;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This is bar with complex input
|
||||
*/
|
||||
export function complexBar(input: Options) {
|
||||
console.log('Anything else', input);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as mkdirp from 'mkdirp';
|
||||
|
||||
/**
|
||||
* This is foo
|
||||
*/
|
||||
export function foo(input: string) {
|
||||
console.log('Anything', input);
|
||||
mkdirp('./foo/foo/foo/foo/foo/foo/foo');
|
||||
|
||||
return input + 1;
|
||||
}
|
||||
|
||||
export const fooVar = 'fooVar' as string;
|
||||
@@ -0,0 +1,9 @@
|
||||
export { foo, fooVar } from '@/foo';
|
||||
export { bar, complexBar } from '@/bar';
|
||||
|
||||
/**
|
||||
* Root export
|
||||
*/
|
||||
export function main() {
|
||||
console.log('main');
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@/*": ["./*"],
|
||||
}
|
||||
}
|
||||
}
|
||||
4
client/packages/plugin-declaration-generator/test/index.d.ts
vendored
Normal file
4
client/packages/plugin-declaration-generator/test/index.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare module '@capital/foo' {
|
||||
export const a: any;
|
||||
export const b: string;
|
||||
}
|
||||
20
client/packages/plugin-declaration-generator/test/index.ts
Normal file
20
client/packages/plugin-declaration-generator/test/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { parseExports, parseModuleDeclaration } from '../src/tsgenerator';
|
||||
import path from 'path';
|
||||
|
||||
const { exportModules } = parseExports(
|
||||
path.resolve(__dirname, './demo/index.ts'),
|
||||
{
|
||||
paths: { '@/*': ['./*'] },
|
||||
}
|
||||
);
|
||||
|
||||
console.log('exportModules', exportModules);
|
||||
|
||||
const { modules } = parseModuleDeclaration(
|
||||
path.resolve(__dirname, './index.d.ts'),
|
||||
{
|
||||
paths: { '@/*': ['./*'] },
|
||||
}
|
||||
);
|
||||
|
||||
console.log('modules', modules);
|
||||
14
client/packages/plugin-declaration-generator/test/parser.ts
Normal file
14
client/packages/plugin-declaration-generator/test/parser.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { parseDeclarationEntry } from '../src/parser';
|
||||
import path from 'path';
|
||||
|
||||
const project = parseDeclarationEntry({
|
||||
entryPath: path.resolve(__dirname, './demo/index.ts'),
|
||||
project: {
|
||||
tsConfigFilePath: path.resolve(__dirname, './demo/tsconfig.json'),
|
||||
},
|
||||
});
|
||||
|
||||
console.log(
|
||||
'sourceFile',
|
||||
project.getSourceFiles().map((item) => item.getFilePath())
|
||||
);
|
||||
Reference in New Issue
Block a user