From 7d0a82b53a49b01d0713f2eda2f4ca73a4e722b3 Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Wed, 31 Aug 2022 17:53:45 +0300 Subject: [PATCH] fix: make sure static modifier precedes readonly modifier to avoid IDE complaining about the order --- .../io/outfoxx/typescriptpoet/Modifier.kt | 2 +- .../typescriptpoet/test/ClassSpecTests.kt | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/outfoxx/typescriptpoet/Modifier.kt b/src/main/java/io/outfoxx/typescriptpoet/Modifier.kt index c43bec62..ddb9f1a6 100644 --- a/src/main/java/io/outfoxx/typescriptpoet/Modifier.kt +++ b/src/main/java/io/outfoxx/typescriptpoet/Modifier.kt @@ -23,10 +23,10 @@ enum class Modifier { PUBLIC, PROTECTED, PRIVATE, - READONLY, GET, SET, STATIC, + READONLY, ABSTRACT, DECLARE, CONST, diff --git a/src/test/java/io/outfoxx/typescriptpoet/test/ClassSpecTests.kt b/src/test/java/io/outfoxx/typescriptpoet/test/ClassSpecTests.kt index 7bba72f9..5227452a 100644 --- a/src/test/java/io/outfoxx/typescriptpoet/test/ClassSpecTests.kt +++ b/src/test/java/io/outfoxx/typescriptpoet/test/ClassSpecTests.kt @@ -571,6 +571,31 @@ class ClassSpecTests { ) } + @Test + @DisplayName("Generates property modifiers static precedes readonly") + fun testGenPropertiesModifierStaticPrecedesReadonly() { + val testClass = ClassSpec.builder("Test") + .addProperty("value", TypeName.NUMBER, false, Modifier.PRIVATE, Modifier.STATIC, Modifier.READONLY) + .build() + + val out = StringWriter() + testClass.emit(CodeWriter(out)) + + assertThat( + out.toString(), + equalTo( + """ + class Test { + + private static readonly value: number; + + } + + """.trimIndent() + ) + ) + } + @Test @DisplayName("Generates method definitions") fun testGenMethods() {