Multiple issues with `typescript:4.3.5` library generated Kotlin
🕗 Version
What version did you use when the problem occurred? P.S. You need to run
dukat -vto get your current local version of the tool
How can I run dukat -v? I'm using Gradle 7.2, Kotlin 1.5.31.
plugins {
kotlin("multiplatform") version "1.5.31"
}
💻 Code or Package Name
implementation(npm("typescript", "~4.3.5", generateExternals = false))
🙁 Actual behaviour
I'd like to use the typed-factorio package. But it depends on Typescript, and generating Kotlin code for that fails... which is really bizarre.
I run this command to generate the Kotlin code.
gradle jsGenerateExternals
There are too many problems to go through really. I'm very confused because I thought the point of Dukat was to generate Kotlin code from Typescript, but it doesn't even work for the actual Typescript library.
Main problems
- Enums are used as generic types.
SyntaxKindis an enum class,SyntaxKind.AsteriskTokenis a specific enum.external interface NamedTupleMember : TypeNode, JSDocContainer, Declaration { val dotDotDotToken: Token<SyntaxKind.DotDotDotToken>? // Use of enum entry names as types is not allowed, use enum type instead get() = definedExternally val name: Identifier val questionToken: Token<SyntaxKind.QuestionToken>? get() = definedExternally val type: TypeNode }typealias AsteriskToken = PunctuationToken<SyntaxKind.AsteriskToken> // Use of enum entry names as types is not allowed, use enum type instead - Multiple methods with the same signature are created
fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: Identifier, body: ModuleBlock?): ModuleDeclaration fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: Identifier, body: NamespaceDeclaration?): ModuleDeclaration fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: Identifier, body: Identifier?): ModuleDeclaration fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: Identifier, body: JSDocNamespaceDeclaration?): ModuleDeclaration fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: StringLiteral, body: ModuleBlock?): ModuleDeclaration fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: StringLiteral, body: NamespaceDeclaration?): ModuleDeclaration fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: StringLiteral, body: Identifier?): ModuleDeclaration fun updateModuleDeclaration(node: ModuleDeclaration, decorators: Array<Decorator>?, modifiers: Array<Any /* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */>?, name: StringLiteral, body: JSDocNamespaceDeclaration?): ModuleDeclaration
Because there's no documentation or examples I don't know how to resolve these problems.
18:51:26: Executing task 'assemble'...
Type-safe project accessors is an incubating feature.
> Task :wrapper
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 161ms
1 actionable task: 1 executed
Type-safe project accessors is an incubating feature.
> Task :transformCommonMainDependenciesMetadata UP-TO-DATE
> Task :compileCommonMainKotlinMetadata NO-SOURCE
> Task :generateProjectStructureMetadata UP-TO-DATE
> Task :metadataCommonMainClasses UP-TO-DATE
> Task :allMetadataJar UP-TO-DATE
> Task :compileKotlinNative UP-TO-DATE
> Task :kotlinNpmCachesSetup
> Task :jsPackageJson UP-TO-DATE
> Task :kotlinNodeJsSetup SKIPPED
> Task :rootPackageJson UP-TO-DATE
> Task :kotlinNpmInstall UP-TO-DATE
> Task :jsGenerateExternalsIntegrated SKIPPED
> Task :compileKotlinJs FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
9 actionable tasks: 2 executed, 7 up-to-date
e: <project>\externals\nonDeclarations.ts.kt: (24, 50): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (26, 56): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (28, 55): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (30, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (32, 52): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (34, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (36, 55): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (38, 64): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (40, 51): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (42, 52): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (44, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (46, 52): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (48, 50): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (54, 54): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (56, 51): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (58, 51): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (60, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (62, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (64, 52): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (66, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (68, 55): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (70, 52): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (72, 54): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (74, 54): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (76, 52): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\nonDeclarations.ts.kt: (84, 47): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (577, 52): Type argument is not within its bounds: should be subtype of 'SyntaxKind'
e: <project>\externals\typescript.ts.module_typescript.kt: (579, 48): Type argument is not within its bounds: should be subtype of 'SyntaxKind'
e: <project>\externals\typescript.ts.module_typescript.kt: (666, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.SignatureDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (672, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.SignatureDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (816, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.FunctionLikeDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (824, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.SignatureDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (832, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.FunctionLikeDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (841, 1): Class 'ConstructorDeclaration' must override public open val name: dynamic defined in ts.FunctionLikeDeclarationBase because it inherits multiple interface methods of it
e: <project>\externals\typescript.ts.module_typescript.kt: (842, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.FunctionLikeDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (855, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.FunctionLikeDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (867, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.FunctionLikeDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (879, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.SignatureDeclarationBase'
e: <project>\externals\typescript.ts.module_typescript.kt: (891, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.TypeNode'
e: <project>\externals\typescript.ts.module_typescript.kt: (955, 42): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (958, 41): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (1148, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.PrimaryExpression'
e: <project>\externals\typescript.ts.module_typescript.kt: (1155, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.Expression'
e: <project>\externals\typescript.ts.module_typescript.kt: (1423, 42): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (1588, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.DeclarationStatement'
e: <project>\externals\typescript.ts.module_typescript.kt: (1594, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.PrimaryExpression'
e: <project>\externals\typescript.ts.module_typescript.kt: (1814, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.JSDocType'
e: <project>\externals\typescript.ts.module_typescript.kt: (2060, 42): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (2153, 30): Type of 'statements' is not a subtype of the overridden property 'public abstract val statements: NodeArray<Statement> /* = Array<Statement> */ defined in ts.SourceFile'
e: <project>\externals\typescript.ts.module_typescript.kt: (2163, 24): Type of 'kind' is not a subtype of the overridden property 'public abstract val kind: SyntaxKind defined in ts.PrefixUnaryExpression'
e: <project>\externals\typescript.ts.module_typescript.kt: (2833, 26): Type of 'target' doesn't match the type of the overridden var-property 'public abstract var target: GenericType defined in ts.TypeReference'
e: <project>\externals\typescript.ts.module_typescript.kt: (3752, 39): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (3753, 39): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (3754, 39): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (3755, 39): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (3756, 39): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (3951, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (3952, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (3953, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4067, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4068, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4069, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4070, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4071, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4072, 58): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4074, 80): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4075, 80): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4118, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4119, 53): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4509, 48): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4510, 48): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (4550, 89): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5282, 78): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5284, 78): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5286, 78): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5288, 78): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5294, 79): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5296, 79): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5298, 79): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (5300, 79): Use of enum entry names as types is not allowed, use enum type instead
e: <project>\externals\typescript.ts.module_typescript.kt: (7363, 48): Unresolved reference: T
e: <project>\externals\typescript.ts.module_typescript.kt: (7363, 94): Unresolved reference: T
e: <project>\externals\typescript.ts.module_typescript.kt: (7396, 37): Unresolved reference: T
e: <project>\externals\typescript.ts.module_typescript.kt: (7396, 57): Unresolved reference: T
e: <project>\externals\typescript.ts.module_typescript.kt: (7450, 44): Unresolved reference: TKind
e: <project>\externals\typescript.ts.module_typescript.kt: (7450, 70): Unresolved reference: TKind
e: <project>\externals\typescript.ts.module_typescript.kt: (7994, 34): Unresolved reference: TKind
e: <project>\externals\typescript.ts.module_typescript.kt: (7994, 50): Unresolved reference: TKind
e: <project>\externals\typescript.ts.module_typescript.kt: (8138, 38): Unresolved reference: T
e: <project>\externals\typescript.ts.module_typescript.kt: (8138, 44): Unresolved reference: T
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlinJs'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
18:51:31: Task execution finished 'assemble'.
🙂 Expected behavior
- Documentation is updated to give clearer guidance on usage and expected output
- Additional examples
- What is the purpose of comments like this?
Are they important? Is it used by Kotlin/JS? Or is it just a comment?/* AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword */
Related
- #292
This probably is related: https://youtrack.jetbrains.com/issue/KT-42290