From f8fdb0dc7efa3590da01eeb076734758c5732e85 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Thu, 21 May 2020 18:34:02 +0300 Subject: [PATCH] [JS] Add `;` after functions in .d.ts Fixes nit from KT-37752 --- .../js/export/ExportModelToTsDeclarations.kt | 4 +- .../constructors/constructors.d.ts | 20 ++++----- .../declarations/declarations.d.ts | 32 +++++++------- .../inheritance/inheritance.d.ts | 14 +++---- .../namespaces/namespaces.d.ts | 42 +++++++++---------- .../primitives/primitives.d.ts | 2 +- .../selectiveExport/selectiveExport.d.ts | 8 ++-- .../visibility/visibility.d.ts | 10 ++--- 8 files changed, 66 insertions(+), 66 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelToTsDeclarations.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelToTsDeclarations.kt index 13464287e52..f87e0f35e8c 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelToTsDeclarations.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelToTsDeclarations.kt @@ -42,10 +42,10 @@ fun ExportedDeclaration.toTypeScript(indent: String): String = indent + when (th val renderedReturnType = returnType.toTypeScript() - "$keyword$name$renderedTypeParameters($renderedParameters): $renderedReturnType" + "$keyword$name$renderedTypeParameters($renderedParameters): $renderedReturnType;" } is ExportedConstructor -> - "constructor(${parameters.joinToString(", ") { it.toTypeScript() }})" + "constructor(${parameters.joinToString(", ") { it.toTypeScript() }});" is ExportedProperty -> { val keyword = when { diff --git a/js/js.translator/testData/typescript-export/constructors/constructors.d.ts b/js/js.translator/testData/typescript-export/constructors/constructors.d.ts index 66590dc03e7..a36e85f1c95 100644 --- a/js/js.translator/testData/typescript-export/constructors/constructors.d.ts +++ b/js/js.translator/testData/typescript-export/constructors/constructors.d.ts @@ -1,33 +1,33 @@ declare namespace JS_TESTS { type Nullable = T | null | undefined class ClassWithDefaultCtor { - constructor() + constructor(); readonly x: string; } class ClassWithPrimaryCtor { - constructor(x: string) + constructor(x: string); readonly x: string; } class ClassWithSecondaryCtor { private constructor(); readonly x: string; - static create(y: string): ClassWithSecondaryCtor + static create(y: string): ClassWithSecondaryCtor; } class ClassWithMultipleSecondaryCtors { private constructor(); readonly x: string; - static createFromString(y: string): ClassWithMultipleSecondaryCtors - static createFromInts(y: number, z: number): ClassWithMultipleSecondaryCtors + static createFromString(y: string): ClassWithMultipleSecondaryCtors; + static createFromInts(y: number, z: number): ClassWithMultipleSecondaryCtors; } class OpenClassWithMixedConstructors { - constructor(x: string) + constructor(x: string); readonly x: string; - static createFromStrings(y: string, z: string): OpenClassWithMixedConstructors - static createFromInts(y: number, z: number): OpenClassWithMixedConstructors + static createFromStrings(y: string, z: string): OpenClassWithMixedConstructors; + static createFromInts(y: number, z: number): OpenClassWithMixedConstructors; } class DerivedClassWithSecondaryCtor extends OpenClassWithMixedConstructors { private constructor(); - static delegateToPrimary(y: string): DerivedClassWithSecondaryCtor - static delegateToCreateFromInts(y: number, z: number): DerivedClassWithSecondaryCtor + static delegateToPrimary(y: string): DerivedClassWithSecondaryCtor; + static delegateToCreateFromInts(y: number, z: number): DerivedClassWithSecondaryCtor; } } diff --git a/js/js.translator/testData/typescript-export/declarations/declarations.d.ts b/js/js.translator/testData/typescript-export/declarations/declarations.d.ts index 5e6db47f597..6e5ebb03f53 100644 --- a/js/js.translator/testData/typescript-export/declarations/declarations.d.ts +++ b/js/js.translator/testData/typescript-export/declarations/declarations.d.ts @@ -1,17 +1,17 @@ declare namespace JS_TESTS { type Nullable = T | null | undefined namespace foo { - function sum(x: number, y: number): number - function varargInt(x: Int32Array): number - function varargNullableInt(x: Array>): number - function varargWithOtherParameters(x: string, y: Array, z: string): number - function varargWithComplexType(x: Array<(p0: Array) => Array>): number - function sumNullable(x: Nullable, y: Nullable): number - function defaultParameters(x: number, y: string): string - function generic1(x: T): T - function generic2(x: Nullable): boolean - function generic3(a: A, b: B, c: C, d: D): Nullable - function inlineFun(x: number, callback: (p0: number) => void): void + function sum(x: number, y: number): number; + function varargInt(x: Int32Array): number; + function varargNullableInt(x: Array>): number; + function varargWithOtherParameters(x: string, y: Array, z: string): number; + function varargWithComplexType(x: Array<(p0: Array) => Array>): number; + function sumNullable(x: Nullable, y: Nullable): number; + function defaultParameters(x: number, y: string): string; + function generic1(x: T): T; + function generic2(x: Nullable): boolean; + function generic3(a: A, b: B, c: C, d: D): Nullable; + function inlineFun(x: number, callback: (p0: number) => void): void; const _const_val: number; const _val: number; let _var: number; @@ -20,23 +20,23 @@ declare namespace JS_TESTS { let _varCustom: number; let _varCustomWithField: number; class A { - constructor() + constructor(); } class A1 { - constructor(x: number) + constructor(x: number); readonly x: number; } class A2 { - constructor(x: string, y: boolean) + constructor(x: string, y: boolean); readonly x: string; y: boolean; } class A3 { - constructor() + constructor(); readonly x: number; } class A4 { - constructor() + constructor(); readonly _valCustom: number; readonly _valCustomWithField: number; _varCustom: number; diff --git a/js/js.translator/testData/typescript-export/inheritance/inheritance.d.ts b/js/js.translator/testData/typescript-export/inheritance/inheritance.d.ts index 6a04989b078..3e9d1935cb2 100644 --- a/js/js.translator/testData/typescript-export/inheritance/inheritance.d.ts +++ b/js/js.translator/testData/typescript-export/inheritance/inheritance.d.ts @@ -4,31 +4,31 @@ declare namespace JS_TESTS { interface I { x: T; readonly y: S; - z(u: U): void + z(u: U): void; } interface I2 { x: string; readonly y: boolean; - z(z: number): void + z(z: number): void; } } namespace foo { abstract class AC implements foo.I2 { - constructor() + constructor(); x: string; abstract readonly y: boolean; - abstract z(z: number): void + abstract z(z: number): void; readonly acProp: string; abstract readonly acAbstractProp: string; } class OC extends foo.AC implements foo.I { - constructor(y: boolean, acAbstractProp: string) + constructor(y: boolean, acAbstractProp: string); readonly y: boolean; readonly acAbstractProp: string; - z(z: number): void + z(z: number): void; } class FC extends foo.OC { - constructor() + constructor(); } } } diff --git a/js/js.translator/testData/typescript-export/namespaces/namespaces.d.ts b/js/js.translator/testData/typescript-export/namespaces/namespaces.d.ts index 3c285bfac6f..5981f3195b2 100644 --- a/js/js.translator/testData/typescript-export/namespaces/namespaces.d.ts +++ b/js/js.translator/testData/typescript-export/namespaces/namespaces.d.ts @@ -2,36 +2,36 @@ declare namespace JS_TESTS { type Nullable = T | null | undefined namespace foo.bar.baz { class C1 { - constructor(value: string) + constructor(value: string); readonly value: string; - component1(): string - copy(value: string): foo.bar.baz.C1 - toString(): string - hashCode(): number - equals(other: Nullable): boolean + component1(): string; + copy(value: string): foo.bar.baz.C1; + toString(): string; + hashCode(): number; + equals(other: Nullable): boolean; } - function f(x1: foo.bar.baz.C1, x2: a.b.C2, x3: C3): string + function f(x1: foo.bar.baz.C1, x2: a.b.C2, x3: C3): string; } namespace a.b { class C2 { - constructor(value: string) + constructor(value: string); readonly value: string; - component1(): string - copy(value: string): a.b.C2 - toString(): string - hashCode(): number - equals(other: Nullable): boolean + component1(): string; + copy(value: string): a.b.C2; + toString(): string; + hashCode(): number; + equals(other: Nullable): boolean; } - function f(x1: foo.bar.baz.C1, x2: a.b.C2, x3: C3): string + function f(x1: foo.bar.baz.C1, x2: a.b.C2, x3: C3): string; } class C3 { - constructor(value: string) + constructor(value: string); readonly value: string; - component1(): string - copy(value: string): C3 - toString(): string - hashCode(): number - equals(other: Nullable): boolean + component1(): string; + copy(value: string): C3; + toString(): string; + hashCode(): number; + equals(other: Nullable): boolean; } - function f(x1: foo.bar.baz.C1, x2: a.b.C2, x3: C3): string + function f(x1: foo.bar.baz.C1, x2: a.b.C2, x3: C3): string; } diff --git a/js/js.translator/testData/typescript-export/primitives/primitives.d.ts b/js/js.translator/testData/typescript-export/primitives/primitives.d.ts index 24023e38507..dbc2e61a3f7 100644 --- a/js/js.translator/testData/typescript-export/primitives/primitives.d.ts +++ b/js/js.translator/testData/typescript-export/primitives/primitives.d.ts @@ -2,7 +2,7 @@ declare namespace JS_TESTS { type Nullable = T | null | undefined namespace foo { const _any: any; - function _nothing(): never + function _nothing(): never; const _throwable: Error; const _string: string; const _boolean: boolean; diff --git a/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.d.ts b/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.d.ts index 646eaeb6235..e3fc42c0853 100644 --- a/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.d.ts +++ b/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.d.ts @@ -10,17 +10,17 @@ declare namespace JS_TESTS { } namespace foo { const exportedVal: number; - function exportedFun(): number + function exportedFun(): number; class ExportedClass { - constructor() + constructor(); readonly value: number; } } namespace foo { const fileLevelExportedVal: number; - function fileLevelExportedFun(): number + function fileLevelExportedFun(): number; class FileLevelExportedClass { - constructor() + constructor(); readonly value: number; } } diff --git a/js/js.translator/testData/typescript-export/visibility/visibility.d.ts b/js/js.translator/testData/typescript-export/visibility/visibility.d.ts index 57b6edc6071..fc58155515a 100644 --- a/js/js.translator/testData/typescript-export/visibility/visibility.d.ts +++ b/js/js.translator/testData/typescript-export/visibility/visibility.d.ts @@ -3,18 +3,18 @@ declare namespace JS_TESTS { interface publicInterface { } const publicVal: number; - function publicFun(): number + function publicFun(): number; class publicClass { - constructor() + constructor(); } class Class { - constructor() + constructor(); readonly publicVal: number; - publicFun(): number + publicFun(): number; } namespace Class { class publicClass { - constructor() + constructor(); } } }