forked from benjamn/reify
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from meteor/tla-assignment
Fix TLA not detecting top level declarations with await
- Loading branch information
Showing
10 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const FUNCTION_TYPES = [ | ||
'FunctionDeclaration', | ||
'FunctionExpression', | ||
'ArrowFunctionExpression', | ||
'ClassMethod', | ||
'ObjectMethod', | ||
'ClassPrivateMethod', | ||
] | ||
|
||
function isTopLevelAwait(ancestors) { | ||
for (let ancestor of ancestors) { | ||
if (FUNCTION_TYPES.includes(ancestor.type)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
module.exports = { isTopLevelAwait } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,8 @@ | |
"lodash": "4.17.21", | ||
"mocha": "9.1.1", | ||
"recast": "0.20.5" | ||
}, | ||
"volta": { | ||
"node": "14.21.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// FunctionDeclaration | ||
async function functionDeclaration() { | ||
const result = await Promise.resolve("This is a function declaration"); | ||
return result; | ||
} | ||
|
||
// FunctionExpression | ||
var functionExpression = async function() { | ||
const result = await Promise.resolve("This is a function expression"); | ||
return result; | ||
}; | ||
|
||
// ArrowFunctionExpression | ||
var arrowFunctionExpression = async () => { | ||
const result = await Promise.resolve("This is an arrow function expression"); | ||
return result; | ||
}; | ||
|
||
// ClassMethod | ||
class MyClass { | ||
async classMethod() { | ||
const result = await Promise.resolve("This is a class method"); | ||
return result; | ||
} | ||
} | ||
|
||
// ObjectMethod | ||
var myObject = { | ||
objectMethod: async function() { | ||
const result = await Promise.resolve("This is an object method"); | ||
return result; | ||
} | ||
}; | ||
|
||
// ClassPrivateMethod | ||
class MyClassWithPrivateMethod { | ||
async #privateMethod() { | ||
const result = await Promise.resolve("This is a private class method"); | ||
return result; | ||
} | ||
|
||
async callPrivateMethod() { | ||
return this.#privateMethod(); | ||
} | ||
} | ||
|
||
module.exports = { | ||
functionDeclaration, | ||
functionExpression, | ||
arrowFunctionExpression, | ||
MyClass, | ||
myObject, | ||
MyClassWithPrivateMethod | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const value = Math.max(false ? 777 : await Promise.resolve(12), 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const test = await new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve('value'); | ||
}, 1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const test = await new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve('value'); | ||
}, 1) | ||
}) | ||
|
||
export const redirected = test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters