Skip to content

Commit

Permalink
fix(transformer): 当本地变量和循环变量冲突时警告,但仍然把本地变量加入 usedState 和 pendingState,
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Feb 18, 2019
1 parent 4b75433 commit a637ca5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/taro-transformer-wx/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ export class RenderParser {
this.handleLoopComponents()
renderBody.traverse(this.visitors)
this.setOutputTemplate()
this.checkDuplicateName()
this.removeJSXStatement()
this.setUsedState()
this.setPendingState()
Expand Down Expand Up @@ -1567,6 +1568,17 @@ export class RenderParser {
)))
}

checkDuplicateName () {
this.loopScopes.forEach(s => {
if (this.renderPath.scope.hasBinding(s)) {
const err = codeFrameError(this.renderPath.scope.getBinding(s)!.path.node, '此变量声明与循环变量冲突,可能会造成问题。')
// tslint:disable-next-line
console.warn('Warning: ', err.message)
this.loopScopes.delete(s)
}
})
}

setPendingState () {
const propertyKeys = Array.from(
new Set(Array.from(this.referencedIdentifiers)
Expand Down

0 comments on commit a637ca5

Please sign in to comment.