TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
async function foo () {
const a: Promise<any> = f()
a./*here*/
}
Expected behavior:
;(await a).xxx
Actual behavior:
async function foo () {
const a: Promise<any> = f()
(await a).xxx // asi broken here
}
Playground Link:
https://twitter.com/Luxcium/status/1174602967053471744
Related Issues:
await a.xxx
That wouldn't be the right thing to do because it would be parsed as await (a.xxx) and a is a promise. Which is why the await is being added in the first place. 馃槃
friendly ping @andrewbranch
Could you give some suggestions please锛烮 cannot find some existed things about ASI detection....
My issue was open there
I provided code example of my actual issue
But in fact as I am coding I am relying on the linter to add semis on save and if autocompletion add parenthesis it should also take care of not becoming continuation of previous line... await by itself or code by itself will not cause problems because of the automatic semi insertion but a set of parenthesis added on the fly change this behaviour and become continuation of previous line...
in most cases it probably requires to add a semi when autocompleting with a set of parenthesis but some edge cases might implies not doing it but I am not sure why if the parenthesis would have been the continuation of previous line I assume it would have been added by the person not as a completion in that context I think
It鈥檚 nice because now automatic completion implement not only then/catch/finally but also of the 芦 then resolved promises 禄 by adding an await inside a set of parenthesis then a dot and then the other possibility
(async _=>{
const some:any = await a;
const something:any = some.xxx('do something')
})()
now autocomplete and save you of assigning to an intermediary variable
(async _=>{
const something:any = (await a).xxx('do something');
})()
If you don鈥檛 need to say save to a variable/const then
This ...
(async _=>{
const a: Promise<any> = f()
(await a).xxx('do something') // asi broken here
})()
... is the same as this:
(async _=>{
const a: Promise<any> = f()(await a).xxx('do something') // asi broken here
})()
@Kingwl I added a lot of ASI logic in #33402; does that look helpful?
Hi all, sadly I鈥檓 not 100% sure what could i do....
Most helpful comment
That wouldn't be the right thing to do because it would be parsed as
await (a.xxx)andais a promise. Which is why theawaitis being added in the first place. 馃槃