babel-plugin-transform-taroapi 3.7.0-alpha.22 → 3.7.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +5 -5
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -60,7 +60,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
60
60
|
this.apis = apis
|
|
61
61
|
},
|
|
62
62
|
visitor: {
|
|
63
|
-
ImportDeclaration (ast) {
|
|
63
|
+
ImportDeclaration (ast: BabelCore.NodePath<any>) {
|
|
64
64
|
if (ast.node.source.value !== this.packageName) return
|
|
65
65
|
|
|
66
66
|
ast.node.specifiers.forEach(node => {
|
|
@@ -91,7 +91,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
91
91
|
}
|
|
92
92
|
})
|
|
93
93
|
},
|
|
94
|
-
MemberExpression (ast) {
|
|
94
|
+
MemberExpression (ast: BabelCore.NodePath<any>) {
|
|
95
95
|
/* 处理Taro.xxx */
|
|
96
96
|
const isTaro = t.isIdentifier(ast.node.object, { name: taroName })
|
|
97
97
|
const property = ast.node.property
|
|
@@ -110,7 +110,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
110
110
|
|
|
111
111
|
// 同一api使用多次, 读取变量名
|
|
112
112
|
if (this.apis.has(propertyName)) {
|
|
113
|
-
const parentNode = ast.parent
|
|
113
|
+
const parentNode = ast.parent as BabelCore.types.AssignmentExpression
|
|
114
114
|
const isAssignment = t.isAssignmentExpression(parentNode) && parentNode.left === ast.node
|
|
115
115
|
|
|
116
116
|
if (!isAssignment) {
|
|
@@ -129,7 +129,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
129
129
|
needDefault = true
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
|
-
CallExpression (ast) {
|
|
132
|
+
CallExpression (ast: BabelCore.NodePath<any>) {
|
|
133
133
|
if (!ast.scope.hasReference(this.canIUse)) return
|
|
134
134
|
const callee = ast.node.callee
|
|
135
135
|
if (t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: taroName })) {
|
|
@@ -188,7 +188,7 @@ const plugin = function (babel: typeof BabelCore): BabelCore.PluginObj<IState> {
|
|
|
188
188
|
ast.node.specifiers = namedImports
|
|
189
189
|
}
|
|
190
190
|
},
|
|
191
|
-
CallExpression (ast) {
|
|
191
|
+
CallExpression (ast: BabelCore.NodePath<any>) {
|
|
192
192
|
if (!invokedApis.has(that.canIUse)) return
|
|
193
193
|
const callee = ast.node.callee
|
|
194
194
|
const { name } = t.identifier(invokedApis.get(that.canIUse)!)
|