pmneo / ts-importer

MIT License
73 stars 8 forks source link

Append import to multiline import #28

Closed ahanriat closed 6 years ago

ahanriat commented 7 years ago

Hi guys!

Congrats for this amazing plugin 🎉

Just spotted an issue when having multiline imports:

Disclaimer: this issue is not linked to React Native, I'm just using it for the purpose of this issue ;)

Initial situation

// Some multiline import 
import {
  View,
  StyleSheet,
} from 'react-native';

// ... some other imports

Then the plugin add the import for the Image component from 'react-native'

Current behaviour

import {
  View,
  StyleSheet,
} from 'react-native';

// ... some other imports
import { Image } from 'react-native'; // <= unfortunatly it adds another import from `'react-native'`

Expected behaviour

import {
  View,
  StyleSheet,
  Image, // <= It would be super nice to have it here :D
} from 'react-native';

// ... some other imports

Cheers 🚀

brunsten commented 7 years ago

For me it looks like this:

import {
     Component, Input, Output, EventEmitter, ViewEncapsulation, HostBinding, OnInit, OnChanges
} from '@angular/core';

Adding SimpleChanges:

import { Component, Input, Output, EventEmitter, ViewEncapsulation, HostBinding, OnInit, OnChanges, SimpleChanges } from '@angular/core';
      Component, Input, Output, EventEmitter, ViewEncapsulation, HostBinding, OnInit, OnChanges
 } from '@angular/core';

This doesn't compile really well

pmneo commented 7 years ago

I will take a look into it.