Victory-native: Typescript support

Created on 6 Mar 2018  路  8Comments  路  Source: FormidableLabs/victory-native

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?

Most helpful comment

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.

All 8 comments

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 the victory-native.d.ts come 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" }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlo1 picture jlo1  路  3Comments

safaiyeh picture safaiyeh  路  6Comments

ericschaal picture ericschaal  路  4Comments

xinhash picture xinhash  路  4Comments

hwaterke picture hwaterke  路  6Comments