Skip to content

Commit e490802

Browse files
JSMonkSpace Team
authored andcommitted
[K/JS] Introduce a compiler argument to enable export of suspend functions
^KT-82668 Fixed
1 parent 585094b commit e490802

File tree

6 files changed

+61
-0
lines changed

6 files changed

+61
-0
lines changed

compiler/arguments/resources/kotlin-compiler-arguments.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7251,6 +7251,37 @@
72517251
"removedVersion": null
72527252
}
72537253
},
7254+
{
7255+
"name": "Xenable-suspend-function-exporting",
7256+
"shortName": null,
7257+
"deprecatedName": null,
7258+
"description": {
7259+
"current": "Enable exporting suspend functions to JavaScript/TypeScript.",
7260+
"valueInVersions": []
7261+
},
7262+
"delimiter": null,
7263+
"valueType": {
7264+
"type": "org.jetbrains.kotlin.arguments.dsl.types.BooleanType",
7265+
"isNullable": {
7266+
"current": false,
7267+
"valueInVersions": []
7268+
},
7269+
"defaultValue": {
7270+
"current": false,
7271+
"valueInVersions": []
7272+
}
7273+
},
7274+
"valueDescription": {
7275+
"current": null,
7276+
"valueInVersions": []
7277+
},
7278+
"releaseVersionsMetadata": {
7279+
"introducedVersion": "2.3.0",
7280+
"stabilizedVersion": null,
7281+
"deprecatedVersion": null,
7282+
"removedVersion": null
7283+
}
7284+
},
72547285
{
72557286
"name": "Xes-arrow-functions",
72567287
"shortName": null,

compiler/arguments/src/org/jetbrains/kotlin/arguments/description/JsCompilerArguments.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,18 @@ val actualJsArguments by compilerArgumentsLevel(CompilerArgumentsLevelNames.jsAr
472472
)
473473
}
474474

475+
compilerArgument {
476+
name = "Xenable-suspend-function-exporting"
477+
compilerName = "allowExportingSuspendFunctions"
478+
description = "Enable exporting suspend functions to JavaScript/TypeScript.".asReleaseDependent()
479+
valueType = BooleanType.defaultFalse
480+
additionalAnnotations(Enables(LanguageFeature.JsAllowExportingSuspendFunctions))
481+
482+
lifecycle(
483+
introducedVersion = KotlinReleaseVersion.v2_3_0,
484+
)
485+
}
486+
475487
compilerArgument {
476488
name = "Xfake-override-validator"
477489
description = "Enable the IR fake override validator.".asReleaseDependent()

compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/ConfigureJsLanguageFeatures.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ internal fun MutableMap<LanguageFeature, LanguageFeature.State>.configureJsLangu
1010
if (arguments.extensionFunctionsInExternals) {
1111
put(LanguageFeature.JsEnableExtensionFunctionInExternals, LanguageFeature.State.ENABLED)
1212
}
13+
14+
if (arguments.allowExportingSuspendFunctions) {
15+
put(LanguageFeature.JsAllowExportingSuspendFunctions, LanguageFeature.State.ENABLED)
16+
}
1317
}

compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ class K2JSCompilerArguments : K2WasmCompilerArguments() {
3434
field = value
3535
}
3636

37+
@Argument(
38+
value = "-Xenable-suspend-function-exporting",
39+
description = "Enable exporting suspend functions to JavaScript/TypeScript.",
40+
)
41+
@Enables(LanguageFeature.JsAllowExportingSuspendFunctions)
42+
var allowExportingSuspendFunctions: Boolean = false
43+
set(value) {
44+
checkFrozen()
45+
field = value
46+
}
47+
3748
@Argument(
3849
value = "-Xes-arrow-functions",
3950
description = "Use ES2015 arrow functions in the JavaScript code generated for Kotlin lambdas. Enabled by default in case of ES2015 target usage",

compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArgumentsCopyGenerated.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package org.jetbrains.kotlin.cli.common.arguments
1010
fun copyK2JSCompilerArguments(from: K2JSCompilerArguments, to: K2JSCompilerArguments): K2JSCompilerArguments {
1111
copyK2WasmCompilerArguments(from, to)
1212

13+
to.allowExportingSuspendFunctions = from.allowExportingSuspendFunctions
1314
to.cacheDirectory = from.cacheDirectory
1415
to.compileLongAsBigInt = from.compileLongAsBigInt
1516
to.extensionFunctionsInExternals = from.extensionFunctionsInExternals

compiler/testData/cli/js/jsExtraHelp.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ where advanced options include:
33
-Xcache-directory=<path> Path to the cache directory.
44
-Xenable-extension-functions-in-externals
55
Enable extension function members in external interfaces.
6+
-Xenable-suspend-function-exporting
7+
Enable exporting suspend functions to JavaScript/TypeScript.
68
-Xes-arrow-functions Use ES2015 arrow functions in the JavaScript code generated for Kotlin lambdas. Enabled by default in case of ES2015 target usage
79
-Xes-classes Let generated JavaScript code use ES2015 classes. Enabled by default in case of ES2015 target usage
810
-Xes-generators Enable ES2015 generator functions usage inside the compiled code. Enabled by default in case of ES2015 target usage

0 commit comments

Comments
 (0)