0.1.31 • Published 3 years ago
@yuyi919/ts-transformer-awesome v0.1.31
@yuyi919/ts-transformer-awesome
What is CustomTransformer ?
interface CustomTransformers {
/** Custom transformers to evaluate before built-in .js transformations. */
before?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[];
/** Custom transformers to evaluate after built-in .js transformations. */
after?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[];
/** Custom transformers to evaluate after built-in .d.ts transformations. */
afterDeclarations?: (TransformerFactory<Bundle | SourceFile> | CustomTransformerFactory)[];
}
Api
const { getCustomTransformers } = require('@yuyi919/ts-transformer-awesome')
// ts.createProgram(...)
getCustomTransformers({
program, // ts.Program
importLibs: [
'lodash',
['@material-ui/core', {
libraryDirectory: '',
camel2DashComponentName: false
}]
] // use ts-import-plugin
// ...
}) // { before: [...], after: [...] }
global env
import '@yuyi919/ts-transformer-awesome/env'
Basic
ts-nameof
点击此处查看更多
ts-transformer-keys
就像使用ts-transformer-keys
一样
interface A {
a: number;
b: number;
}
tsKeys<A>() // => ["a", "b"]
点击此处查看更多
tsx-control-statements
就像使用tsx-control-statements
一样
// 转换前
const TsxControlStatments = () => {
return (
<For of={[1, 2, 3]} each="item" index="itemIndex">
<a style={{ background: 'red' }}>{itemIndex}{item}</a>
</For>
);
}
// 转换后
var TsxControlStatments = () => {
return Array.from([1, 2, 3], function (item, itemIndex) {
return React.createElement("a", {
style: __$hoisted_o0
/**
* 此处是`@avensia-oss/ts-transform-hoist-objects-in-props`在发挥作用
*/
}, itemIndex);
});
}
// 自动静态化转译
var __$hoisted_o0 = {
background: 'red'
};
点击此处查看更多
0.1.31
3 years ago
0.1.30
4 years ago
0.1.29
4 years ago
0.1.28
4 years ago
0.1.27
4 years ago
0.1.24
4 years ago
0.1.25
4 years ago
0.1.26
4 years ago
0.1.23
4 years ago
0.1.22
4 years ago
0.1.21
4 years ago
0.1.20
4 years ago
0.1.18
4 years ago
0.1.19
4 years ago
0.1.17
4 years ago
0.1.15
4 years ago
0.1.14
4 years ago
0.1.13
4 years ago
0.1.12
4 years ago
0.1.11
4 years ago
0.1.10
4 years ago
0.1.9
4 years ago
0.1.8
4 years ago
0.1.7
4 years ago
0.1.6
4 years ago
0.1.5
4 years ago
0.1.4
4 years ago
0.1.3
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago