Skip to content

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

Closed
@francesc79

Description

@francesc79

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:

Metadata

Metadata

Assignees

Labels

Domain: Declaration EmitThe issue relates to the emission of d.ts filesDomain: JavaScriptThe issue relates to JavaScript specificallyGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do thischeckJsRelates to checking JavaScript using TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions