[K/JS] Don't generate TypeScript definitions from ExportModel if the -Xgenerate-dts flag was not provided ^Fixed KT-53940
This commit is contained in:
@@ -114,7 +114,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
return K2JSCompilerArguments()
|
||||
}
|
||||
|
||||
private data class TransformResult(val out: CompilationOutputs, val dts: String)
|
||||
private data class TransformResult(val out: CompilationOutputs, val dts: String?)
|
||||
|
||||
private class Ir2JsTransformer(
|
||||
val arguments: K2JSCompilerArguments,
|
||||
@@ -145,7 +145,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun makeJsCodeGeneratorAndDts(): Pair<JsCodeGenerator, String> {
|
||||
private fun makeJsCodeGeneratorAndDts(): Pair<JsCodeGenerator, String?> {
|
||||
val ir = lowerIr()
|
||||
val transformer = IrModuleToJsTransformer(ir.context, mainCallArguments, ir.moduleFragmentToUniqueName)
|
||||
|
||||
@@ -225,6 +225,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
configurationJs.put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.renderInternalDiagnosticNames)
|
||||
configurationJs.put(JSConfigurationKeys.PROPERTY_LAZY_INITIALIZATION, arguments.irPropertyLazyInitialization)
|
||||
configurationJs.put(JSConfigurationKeys.GENERATE_POLYFILLS, arguments.generatePolyfills)
|
||||
configurationJs.put(JSConfigurationKeys.GENERATE_DTS, arguments.generateDts)
|
||||
configurationJs.put(JSConfigurationKeys.GENERATE_INLINE_ANONYMOUS_FUNCTIONS, arguments.irGenerateInlineAnonymousFunctions)
|
||||
|
||||
if (!checkKotlinPackageUsage(environmentForJS.configuration, sourcesFiles)) return COMPILATION_ERROR
|
||||
@@ -382,7 +383,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
|
||||
outputs.write(outputDir, outputName)
|
||||
|
||||
if (arguments.generateDts) {
|
||||
if (tsDefinitions != null) {
|
||||
val dtsFile = outputDir.resolve("$outputName.d.ts")
|
||||
dtsFile.writeText(tsDefinitions)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user