Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'async' modifier cannot be used in an ambient context.ts #36989

Closed
francesc79 opened this issue Feb 24, 2020 · 6 comments · Fixed by #37010
Closed

'async' modifier cannot be used in an ambient context.ts #36989

francesc79 opened this issue Feb 24, 2020 · 6 comments · Fixed by #37010
Assignees
Labels
checkJs Relates to checking JavaScript using TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Domain: JavaScript The issue relates to JavaScript specifically Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@francesc79
Copy link

TypeScript Version: 3.8.2

Search Terms: allowJs declaration 'async' modifier cannot be used in an ambient context.ts

Code
see code

when run tsc with allowJs and declaration flags enabled the code below

export class TestJS {
    callAsync() {
        return Promise.resolve(1);
    }

    async test() {
        await this.callAsync();
    }
}

produce the declaretion:

export class TestJS {
    callAsync(): Promise<number>;
    async test(): Promise<void>; --> error
}

but when a try to use this class I receive 'async' modifier cannot be used in an ambient context.ts(1040)

Expected behavior:
the TestJS.d.ts shouldn't contain async

Actual behavior:
TestJS.d.ts conteins async

Playground Link: code

Related Issues:

@pocesar
Copy link

pocesar commented Feb 25, 2020

was going to post about this right now, the behavior from JS / TS is definitely off

@DanielRosenwasser DanielRosenwasser added checkJs Relates to checking JavaScript using TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Domain: JavaScript The issue relates to JavaScript specifically labels Feb 25, 2020
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.9.0 milestone Feb 25, 2020
@DanielRosenwasser DanielRosenwasser added Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Feb 25, 2020
@DanielRosenwasser
Copy link
Member

Tests should probably include a test for generators too.

@francesc79
Copy link
Author

with typescript 3.7.5 work well

@DanielRosenwasser
Copy link
Member

Seems like this is fixed in the nightlies. @weswigham can you verify, track down the fix, and cherry-pick it?

@a-tarasyuk
Copy link
Contributor

a-tarasyuk commented Feb 26, 2020

Seems like this is fixed in the nightlies.

This issue related to the method makeSerializePropertySymbol. In the 3.8.*(need to find the commit where it was done) was added the way to get the modifier flags const modifierFlags = getDeclarationModifierFlagsFromSymbol(p); of a symbol and use these flags to create nodes. The 3.7.* handles only static modifier const staticFlag = isStatic ? ModifierFlags.Static : 0; - that's why 3.7.* doesn't emit async modifier.

cc @DanielRosenwasser @weswigham @francesc79

@weswigham
Copy link
Member

@a-tarasyuk it regressed in #35731 probably, since prior to that we weren't pulling on "original" modifier flags from anywhere.

Seems like this is fixed in the nightlies

Looks broken in the nightlies to me

devtools-bot pushed a commit to ChromeDevTools/devtools-frontend that referenced this issue Mar 2, 2020
This includes the fix for
microsoft/TypeScript#36989 which was blocking
the typescript-ification of `host`.

R=szuend@chromium.org
DISABLE_THIRD_PARTY_CHECK=Update typescript

Bug: 1011811
Change-Id: I637861d247ce4b696b0177e0bd8cd31243a47f98
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2083148
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
babot pushed a commit to binaryage/dirac that referenced this issue Mar 3, 2020
This includes the fix for
microsoft/TypeScript#36989 which was blocking
the typescript-ification of `host`.

R=szuend@chromium.org
DISABLE_THIRD_PARTY_CHECK=Update typescript

Bug: 1011811
Change-Id: I637861d247ce4b696b0177e0bd8cd31243a47f98
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2083148
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkJs Relates to checking JavaScript using TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Domain: JavaScript The issue relates to JavaScript specifically Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants