1

How do I use element-ui with Vue+typescript

There are no types for element-ui so when I import it

import Vue from 'vue';
import Element from 'element-ui'

I get an error

Could not find a declaration file for module 'element-ui'. '/home/andres/Code/cdr/frontend/node_modules/element-ui/lib/element-ui.common.js' implicitly has an 'any' type.

How do I work around this?

1
  • Can you add your typescript config? Commented Sep 29, 2017 at 9:52

1 Answer 1

3

As a workaround you can simply create a custom typings file and declare the module:

// in element-ui.d.ts

declare module "element-ui";

This will result in anything you import from element-ui to be typed as any. Of course you can add type definitions in your element-ui.d.ts to have typings if you want.

You can see how to write your own types here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.