-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ts-interface-generator): support non-default-export classes
- create appropriate interface for classes which are not default exports; this will make cases work when the default export is an *instance* of the class (but it still requires the class itself to be exported as named export, so the module augmentation can kick in). - Add new way of writing finer-grained tests, so new cases can be covered more easily - Re-initialize base types for each generation to handle multiple invocations in different type worlds properly - happens in tests - Rename the "testdata" folder to "samples"
- Loading branch information
Showing
26 changed files
with
475 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
47 changes: 47 additions & 0 deletions
47
packages/ts-interface-generator/src/test/testcases/instance-exported/MyControl.gen.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { PropertyBindingInfo } from "sap/ui/base/ManagedObject"; | ||
import { $ControlSettings } from "sap/ui/core/Control"; | ||
|
||
declare module "./MyControl" { | ||
|
||
/** | ||
* Interface defining the settings object used in constructor calls | ||
*/ | ||
interface $MyControlSettings extends $ControlSettings { | ||
|
||
/** | ||
* The text. | ||
* | ||
* @since 1.0 | ||
*/ | ||
text?: string | PropertyBindingInfo; | ||
} | ||
|
||
interface MyControl { | ||
|
||
// property: text | ||
|
||
/** | ||
* Gets current value of property "text". | ||
* | ||
* The text. | ||
* | ||
* @since 1.0 | ||
* | ||
* @returns Value of property "text" | ||
*/ | ||
getText(): string; | ||
|
||
/** | ||
* Sets a new value for property "text". | ||
* | ||
* The text. | ||
* | ||
* @since 1.0 | ||
* When called with a value of "null" or "undefined", the default value of the property will be restored. | ||
* | ||
* @param text New value for property "text" | ||
* @returns Reference to "this" in order to allow method chaining | ||
*/ | ||
setText(text: string): this; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/ts-interface-generator/src/test/testcases/instance-exported/MyControl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Control from "sap/ui/core/Control"; | ||
import { MetadataOptions } from "sap/ui/core/Element"; | ||
import RenderManager from "sap/ui/core/RenderManager"; | ||
|
||
/** | ||
* This is my control. | ||
* | ||
* @namespace my | ||
*/ | ||
export class MyControl extends Control { | ||
static readonly metadata: MetadataOptions = { | ||
properties: { | ||
/** | ||
* The text. | ||
* @since 1.0 | ||
*/ | ||
text: "string", | ||
}, | ||
}; | ||
|
||
static renderer = { | ||
apiVersion: 2, | ||
render: function (rm: RenderManager, control: MyControl) { | ||
rm.openStart("div", control); | ||
rm.openEnd(); | ||
// @ts-ignore this only works with the generated interface | ||
rm.text(control.getText()); | ||
rm.close("div"); | ||
}, | ||
}; | ||
} | ||
|
||
export default new MyControl(); |
47 changes: 47 additions & 0 deletions
47
packages/ts-interface-generator/src/test/testcases/simple-control/MyControl.gen.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { PropertyBindingInfo } from "sap/ui/base/ManagedObject"; | ||
import { $ControlSettings } from "sap/ui/core/Control"; | ||
|
||
declare module "./MyControl" { | ||
|
||
/** | ||
* Interface defining the settings object used in constructor calls | ||
*/ | ||
interface $MyControlSettings extends $ControlSettings { | ||
|
||
/** | ||
* The text. | ||
* | ||
* @since 1.0 | ||
*/ | ||
text?: string | PropertyBindingInfo; | ||
} | ||
|
||
export default interface MyControl { | ||
|
||
// property: text | ||
|
||
/** | ||
* Gets current value of property "text". | ||
* | ||
* The text. | ||
* | ||
* @since 1.0 | ||
* | ||
* @returns Value of property "text" | ||
*/ | ||
getText(): string; | ||
|
||
/** | ||
* Sets a new value for property "text". | ||
* | ||
* The text. | ||
* | ||
* @since 1.0 | ||
* When called with a value of "null" or "undefined", the default value of the property will be restored. | ||
* | ||
* @param text New value for property "text" | ||
* @returns Reference to "this" in order to allow method chaining | ||
*/ | ||
setText(text: string): this; | ||
} | ||
} |
Oops, something went wrong.