CartoDB / carto-vl

CARTO VL: a Javascript library to create vector-based visualizations
BSD 3-Clause "New" or "Revised" License
129 stars 26 forks source link

Typescript support #1435

Closed rpolonsky closed 4 years ago

rpolonsky commented 4 years ago

Hello! How to use carto-vl in typescript project? I'm getting error:

Could not find a declaration file for module '@carto/carto-vl'.

Didn't find any types for this library

elenatorro commented 4 years ago

Hi! CARTO VL can be used with Typescript. You're right, we don't have types, you'd have to define your own types manually when needed. There's no plan to add TS types in the long term, but PRs are welcome :)

In addition, you'd need to add some configuration in your TS project, adding this to a type definition file (for example: your_file_name.d.ts):

declare module '@carto/carto-vl' {
  const content: any;
  export default content;
}

declare module '@carto/carto-vl/src' {
  const content: any;
  export default content;
}

Then, you'd be able to import it:

import carto from '@carto/carto-vl';

Hope it helps 👌

rpolonsky commented 4 years ago

Yeah, it helps, better than nothing Thank you!