How to use IExport generated by ts2fable?
See original GitHub issuesorry for dumb question. But how to use Static type in above case. Means that is also abstract class. So, should I try createEmpty or jsoption for it. I tried jsoptions that did’t work. need to check create empty though.
Below is simple reference code
type [<AllowNullLiteral>] IExports =
abstract HelloResponse: HelloResponseStatic
abstract Hello: HelloStatic
type [<AllowNullLiteral>] IReturn<'T> =
abstract createResponse: unit -> 'T
type [<AllowNullLiteral>] IReturnVoid =
abstract createResponse: unit -> unit
type [<AllowNullLiteral>] HelloResponse =
abstract result: string with get, set
type [<AllowNullLiteral>] HelloResponseStatic =
[<Emit "new $0($1...)">] abstract Create: unit -> HelloResponse
type [<AllowNullLiteral>] Hello =
inherit IReturn<HelloResponse>
abstract name: string with get, set
abstract createResponse: unit -> unit
abstract getTypeName: unit -> unit
type [<AllowNullLiteral>] HelloStatic =
[<Emit "new $0($1...)">] abstract Create: unit -> Hello
So, how to create Hello out of HelloStatic?
PS: On side note. In Hello type createResponse type is coming wrong. It should be HelloResponse. For reference below is TypeScript code.
export interface IReturn<T>
{
createResponse() : T;
}
export interface IReturnVoid
{
createResponse() : void;
}
export class HelloResponse
{
result: string;
}
// @Route("/hello")
// @Route("/hello/{Name}")
export class Hello implements IReturn<HelloResponse>
{
name: string;
createResponse() { return new HelloResponse(); }
getTypeName() { return "Hello"; }
}
I am using latest 0.4 version of ts2fable. If you want I can file another issue for same.
cc/ @MangelMaxime
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
fable-compiler/ts2fable-exports
All branches are auto-generated by ts2fable. Contribute to fable-compiler/ts2fable-exports development by creating an account on GitHub.
Read more >ts2fable-json-export - npm Package Health Analysis
Is ts2fable-json-export safe to use? The npm package ts2fable-json-export was scanned for known vulnerabilities and missing license, and no issues were found.
Read more >ts2fable/README.md
The CDN for ts2fable. ... 22, You can also use `--export`(or `-e`) option to collect from multiple `tsfiles` ... 94, removed from the...
Read more >Let's write Fable bindings for a JS library
Learn about writing Fable Bindings for a Javascript or Typescript library. See the article for a list of common scenarios and examples.
Read more >Export all interfaces/types from one file in TypeScript project
The only way I think that might work, is to import the foo.d.ts/bar.d.ts types into index.d.ts and then in turn export them from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, was my mistake. I was missing the module wrapper around the declarations.
@jgrund it depends actually. If there is no global export then there will be no let binding . You have to create it by your self in that case. Else it will be generated.