0.1.31 • Published 5 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
5 years ago
0.1.30
5 years ago
0.1.29
5 years ago
0.1.28
5 years ago
0.1.27
5 years ago
0.1.24
5 years ago
0.1.25
5 years ago
0.1.26
5 years ago
0.1.23
5 years ago
0.1.22
5 years ago
0.1.21
5 years ago
0.1.20
5 years ago
0.1.18
5 years ago
0.1.19
5 years ago
0.1.17
5 years ago
0.1.15
5 years ago
0.1.14
5 years ago
0.1.13
5 years ago
0.1.12
5 years ago
0.1.11
5 years ago
0.1.10
5 years ago
0.1.9
5 years ago
0.1.8
6 years ago
0.1.7
6 years ago
0.1.6
6 years ago
0.1.5
6 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1
6 years ago