7

if I type autorun inside the code, vscode suggests me to auto import it from mobx:

enter image description here

I want to define some custom names for that for example if I type _ somewhere in the code, I want vscode to suggest me to import lodash

or if type PropTypes I want vscode to suggest auto import PropTypes from 'prop-types'

Is this possible?

I haven't written any vscode extensions yet, but I can take a swing at it if that's what it takes to complete this functionality

Thanks in advance for any help and guidance!

Shining Love Star
  • 5,734
  • 5
  • 39
  • 49
  • did you find a way to do this? – Lucas Janon Feb 29 '20 at 15:45
  • 1
    I have same issue, so I just wrote quick-and-dirty extension, that allows to hardcode in the settings `"PropTypes": "prop-types"` and then provide suggestion for `PropTypes`, which adds import to the top of file. It needs some work to be done, like settings schema, settings reload, more careful autoimport insertion, but resolves my issue. https://marketplace.visualstudio.com/items?itemName=rulexec.custom-autoimport – Alexander Ruliov Mar 07 '20 at 11:17

2 Answers2

0

There's no support for this built into VSCode currently. Basically you're looking to define a list of names/aliases for default exports (i.e import MyCustomName from 'lodash'). Cool idea! I think you'd have to write a pretty low-level VSCode extension to accomplish this might end up being limited by the TypeScript compiler itself. Good luck!

zackkrida
  • 421
  • 2
  • 10
0

Best I could do is declaring it on a file and importing it from there:

tailwind.ts

export { default as tailwind } from "tailwind.macro";

someFile.ts

import tailwind from "~/tailwind";
Lucas Janon
  • 1,502
  • 1
  • 15
  • 18