fable-compiler / ts2fable

Parser of Typescript declaration files
http://fable.io/ts2fable/
Apache License 2.0
223 stars 34 forks source link

Issues with flatpickr #295

Open 0x53A opened 5 years ago

0x53A commented 5 years ago

I'll (probably, don't depend on it ...) try to fix it myself when I have some time, in a month or two.

0) Note: the documentation for -e could be improved, I didn't realize at first that I could add the package name of the first package.

yarn add flatpickr
ts2fable node_modules/flatpickr/dist/typings.d.ts src/Bindings/FlatPickr/FlatPickr.fs -e flatpickr

1) missing generic params

grafik

2) missing type Record<'X, 'Y>

grafik

3) invalid generics

grafik

4) duplicated entries in enum

grafik

0x53A commented 5 years ago

Record is apparently a TS native Dictionary type:

https://www.rickcarlino.com/2017/02/27/real-world-use-case-for-typescript-record-types.html


The plugin stuff may be solvable with anonymous records:

// types/options.d.ts
export declare type Plugin<E = {}> = (fp: Instance & E) => Options;
// plugins/weekSelect/weekSelect.d.ts
import { Plugin } from "../../types/options";
export declare type PlusWeeks = {
    weekStartDay: Date;
    weekEndDay: Date;
};
declare function weekSelectPlugin(): Plugin<PlusWeeks>;

would need to generate a new anonymous record combining the fields of Instance & E: (fp: Instance & E)


arrayify just needs the braces dropped:

grafik

0x53A commented 5 years ago

The generated Options type is useless and would need support for Partial (which at first glance doesn't seem too hard)

grafik

grafik