I'm going to install victory-native module in typescript. I'm not able to find @types/victory-native when I try npm install @types/victory-native.
What should I do for typescript?
https://github.com/FormidableLabs/victory/issues/1033 helped me out. That issue was opened after this one, but it seemed to get more attention.
To use the victory types as victory-native types, you can write
declare module "victory-native" { export * from "victory" }
in the file victory-native.d.ts under local_types.
@emarx Where is local_types? And from where does the victory-native.d.ts come from, iiuc we have to add @types/victory?
This trick works, but some types are broken, like VictoryThemeDefinition.
@pvinis you can hack it like so:
declare module "victory-native" {
export const VictoryThemeDefinition: any;
export * from "victory";
}
Hi,
Obviously, At the moment they do not support the library for ts, but you can ignore ts-list when you put
this line: //@ts-ignore before including the library.
Example:
//@ts-ignore
import { VictoryPie, VictoryLabel, VictoryGroup } from 'victory-native';
Best,
D. Hristov
Hi,
Obviously, At the moment they do not support the library for ts, but you can ignore ts-list when you put
this line: //@ts-ignore before including the library.Example:
//@ts-ignore import { VictoryPie, VictoryLabel, VictoryGroup } from 'victory-native';Best,
D. Hristov
Using @mrded suggestion I've written out a full example/comment. So far, import { VictoryArea, VictoryChart, VictoryGroup } from "victory-native"; is working as expected 馃槃
@emarx Where is
local_types? And from where does thevictory-native.d.tscome from, iiuc we have to add@types/victory?
You need to install the definitions for victory by doing yarn add --dev @types/victory, then create a new def file, under <ROOT>/typing/victory-native.d.ts then you add the line that @emarx suggested: declare module "victory-native" { export * from "victory" }
Most helpful comment
To use the victory types as victory-native types, you can write
in the file
victory-native.d.tsunderlocal_types.