Giter Club home page Giter Club logo

ts-importer's People

Contributors

joostlubach avatar pmneo avatar rndmerle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ts-importer's Issues

Bug: import code completion doesn't work with 'reflect-metadata'

It's a strange issue, I thought that this extension doesn't provide import code completion feature but it was just a bug ๐Ÿ˜„

If you have (even commented) line import "reflect-metadata"; (it's a shim to make TypeScript decorators work) in your file, the import code completion doesn't work at all - there's no suggestion about symbols to import on typing or on CTRL+SPACE.

Where to put config options and knownSymbols?

Documentation's configuration section contains the description of the plugin's options but no reference where and how to set the.

Should I create a file in project root?
Same about the knownSymbols object which can be generated. Where I should add it to make use of ti?

Import from directory when importing from index.ts

Currently when importing from a file named middleoutCompression/index.ts ts-importer specifies the './middleoutCompression/index' as the path.

I would be nicer if it instead simplified the path down to './middleoutCompression'.

Adding custom import statement

Would it be possible to add custom import / export statements?

I work with a custom JS engine that has this import schema

part.js

var a = 42;

main.js

// #import "part.js"
console.log(a) // Logs 42 to the console

In the above script the complete content of the script part.js is copied into the script main.js. Would this extension be extendable to serve this functionality?

Importing "this" instead of the export name.

I can't exactly figure out why this might be happening, but I have a specific export at the end of a file that sets up a logger that looks like this:

const defaultLogger = getLogger("default") as Logger;
export { defaultLogger as logger }

Typescript Importer indexes this export as "this" instead of logger. So, usually on accident I get an import statement at the top of my file that looks like this:
import { this } from "relative/path/to/logger/file";

This is what the symbol index file looks like for this export:

"this": [
		{
			"name": "this",
			"path": "path\\to\\logger.ts",
			"isDefault": false
		}
]

It's super annoying, since 'this' is used all the time. Any idea why this would be happening?

Thanks,
Tyler Robinson

Option to prefer "barrel" (index.ts) files if available

Thanks so much for this awesome plugin! Couldn't live without it.

Would it be possible to add an option to prefer an export from an index.ts file if it's available? This way it ts-importer could help me keep imports a lot cleaner. This is a common use case when dealing with angular2 modules for example.

Insert dependency ordered by dependency name

Currently ts-importer adds new dependencies to an existing import statement as the last item in the statement.

Instead, it would be great if it inserted new dependencies alphabetically amongst the existing dependencies with an import statement.

e.g. When adding dependency a instead of this:

import { x, y, z, a  } from './blah';

It would do this:

import { a, x, y, z  } from './blah';

This way one wouldn't have to use the fixer in ts-lint to reorder after each added import.

Don't suggest auto-imports inside comments

Current behavior:
When the cursor is inside a comment, typing a symbol that can be exported automatically imports it when pressing space, tab or enter.

Expected behavior
When typing inside comments, no import suggestions should be done.

image

My configuration:

  • VS Code 1.6.1
  • ts-importer 1.2.7
  • settings.json:
"tsimporter.lowImportance": true,
"tsimporter.spaceBetweenBraces": false

Nice work, by the way!

Feature request: Option to import by relative path even when paths is set

Hi,

Great job on this project, it is awesome! This is a suggestion to make it even more awesome:

I usually have tsconfig.json set up like this:

{
	"compilerOptions": {
		"baseUrl": ".",
		"paths": {
			"*": [
				"bower_components/*",
				"*"
			]
		}
	}
}

TS importer then produces absolute paths like:

import { LibComponent } from 'lib/LibComponent' // From bower
import { Baz } from 'src/main/typescript/foo/bar/Baz' // From this project

By using a relative path, the latter could be a lot shorter, like:

import { LibComponent } from 'lib/LibComponent' // From bower
import { Baz } from './Baz' // From this project

Would it be possible to get this result somehow? Maybe by calculating both the absolute and the relative path and using the shorter one? (That would let the LibComponent keep the absolute path, because the relative path for it would be something like ../../../../../bower_components/lib/LibComponent which is longer.

This could help greatly when writing library code, to be used in another project โ€“ not having to insert the ./ manually.

Importing inside Comments and Strings

The plugin still imports inside comments and strings. And what's really annoying is that it adds the imports when I press space when I finish a word resulting in many imports after I write a comment or string.

Organizing imports

Organizing imports would be a perfect feature. Please take a look how it's done in Typescript Hero https://github.com/buehler/typescript-hero

In short.
The sequence of the groups located in settings to workspace, it uses regular expressions to identify the group.

[
    "Plains",
    "/@angular/",
    {
        "identifier": "/Foo[1-9]Bar/",
        "order": "desc"
    },
    "Workspace",
    {
        "identifier": "Remaining",
        "order": "desc"
    }
]

Also if you will do some kind of imports organization, please provide a hot key to force organizing and an option for settings to do it automatically on save.

The reason why I'm using your extension not a TsHero is your extension uses paths from tsconfig, which is more important for me, and imho the killing feature!:)

Thank you.

Wrong import statement inserted

When I paste part of my code to new file, I have to create necessary imports. This extensions provide support for it:

2016-11-13 18_51_32-pogoda

The tooltip statement is appropriate but it insert wrong, default import syntax:

2016-11-13 18_51_45-pogoda

Even when I manually correct the import, the next imports from this module appears as new line with default import syntax.

The trace might be that I had in other file the syntax import uiRouter, { StateProvider } from "angular-ui-router"; so the cached version might be incorrect. When I removed the mixed statement and reloaded VS Code, the import works ok.

Support JavaScript?

This project is awesome. I like it and recommend to many friends.
And will you support javascript?

Thank you.

Feature request: Remove unused imports

Out of the TS extensions I've tried, yours is the definitely best of the lot for managing imports. Would love to request the following:

  • Remove unused imports (an annoying chore I encounter frequently)
  • Have the context menu deprioritise options I never choose, and vice versa
  • Format/sort imports inside braces:
    • Inside braces: import { D, A, C, B } --> import { A, B, C, D }
    • Case sensitivity: import { fn1, Type1, fn2, Type2, someVar } --> import { Type1, Type2, fn1, fn2, someVar }
    • Multiline with line breaking when there are too many imports on one line:
import { someReallyLongFunctionOrVariableName, fn1, someVar2, Type1, fn2, Type2, SomeReallyLongTypeName, someVar1}

// becomes:

import {
  SomeReallyLongTypeName, Type1, Type2,
  fn1, fn2, someReallyLongFunctionOrVariableName, someVar2, someVar1
} from 'somewhere';

// or (as per settings):

import { SomeReallyLongTypeName, Type1, Type2,
         fn1, fn2, someReallyLongFunctionOrVariableName, someVar2, someVar1 } from 'somewhere';

High CPU loading after VSCode update to v.1.31.1

After updating VSCode to the last version the ts-importer extension became absolutely unusable.
As soon as I enter several symbols in my *.ts file the CPU gets 100% loaded.
(after extension disabling things get normal again)

Migration: please emit ES6 output

We have identified this extension as emitting ES5-JavaScript code and extending API-types, like vscode.Disposable or vscode.CompletionItem. VS Code itself has changed to emit ES6 JavaScript code and too enable functions extending from classes we have added a utility in our code. Given the small number of es5-emitting extensions that also extend API-types we ask for your help, which is emitting ES6 instead of ES5.

For this extension the following should be enough

  • in tsconfig.json change the target to es6
  • recompile via tsc -p tsconfig.json
  • run vsce publish patch

Thanks and #HappyCoding!

Can you provide somewhere to customize some index?

For example, I always use this:

import * as path from 'path';

However, it can't auto import path when I typed path.
I'm not sure if this is a common demand, but think it will be really useful if somewhere I can add some customize index. (Just like the dump index file)

And another problem is that , once use ts-importer, I found that some hint of basic type disappeared.
e.g. I type this:

let a: string;

Code hint of string can not work. While I disable ts-importer it could.

Append import to multiline import

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 ๐Ÿš€

import statements are broken if the final import item contains a line break

if the final import item contains a line break, the new import will corrupt it by being added inside the brackets.

import { 
    Component
} from '@angular/core';

@Component()
class Test {
}

And then you add another one, for example, Subject

import {
import { Subject } from 'rxjs';
  Component
} from '@angular/core';

@Component()
class Test {
  property: Subject
}

Importing the wrong modules

This plugin was working great for me until yesterday. Now it is consistently importing stuff I don't want. I'm not sure what's changed.

every time I type console._ [logger] it adds:

imports console as * from 'console'

because some library I have in my node_modules folder exports a console module.

If I type window._ (global window object) it adds this import.

imports import { window } from 'rxjs/operator/window';

Annoying - it was working so well but I had to disable it. If I can do anything to help diagnose the issue please let me know.

tsimporter.filesToExclude not working

The filesToExclude option is not working for me. I have tried all possibile combinations like "tsimporter.filesToExclude": [ "./old/**" ], "tsimporter.filesToExclude": [ "old/**" ] or "tsimporter.filesToExclude": [ "./old/**/*" ]. It still resolve also the old project folder:

2016-10-26 18_24_50-startowa

Maybe it has cached exports from before I turned the filesToExclude setting?

Importing Angular components adds extra line

When I am at the top of a .ts file where all the imports are and I want to import a new component manually, for example AppComponent, I type "import App" and when the suggestion for AppComponent pops up, I hit enter on my keyboard. The result is two lines:
import { AppComponent } from './app.component';
import AppComponent

it should be only the first line:
import { AppComponent } from './app.component';

Clean unused (+sort)?

Hi, much โค๏ธ for the extension!
Any plans on adding sort + removing unused imports?

Interface intellisense problem

Hi, when I use this extension it makes using interfaces quite bad. It is probably a bug:

image

Expected behavior and when I disable the extension:
image

In both screenshots I press ctrl + space within these brakets.

Relative path above current directory

If you try to use a module from an upper directory structure, the plugin will put the path like "./../my-module", but it should be only "../my-module".

Should not show dependencies in member lists

Normally when hitting Control + Space (on a Mac) to reveal members for an object VS Code will only show members of the object.

However, when ts-importer is installed it shows all your potential dependencies in your app. In this scenario this is just noise and unfortunately makes the member dropdown almost completely unusable.

I love this extension and recommend it to fellow developers but this specific issue is a show stopper for them. Its a shame as I must admit, I feel like ts-importer makes me much more productive with auto importing dependencies, but less productive by getting in the way of member lists. If this issue was fixed I feel like it would make a huge difference in productivity. ๐Ÿ™

TSX?

Hey, love the plugin!

Just wondering, is there a specific reason why .tsx files arent supported?

Insert import statement ordered by filename

Currently ts-importer adds new import statements to the end of the import list.

It would be great if it instead inserted new import statements alphabetically amongst all the import statements.

e.g. Instead of

import { yada } from './a';
import { etc } from './c';
import { nested } from './c/a';
import { andSoOn } from './d';
import { blah } from './b'; // <-- Just added

It would do this:

import { yada } from './a';
import { blah } from './b'; // <-- Just added
import { etc } from './c';
import { nested } from './c/a';
import { andSoOn } from './d';

This way one wouldn't have to use the fixer in ts-lint to reorder after each added import.

Support export default with interfaces

Hey

If you want to have an interface as the default export from a file, the syntax is:

interface Foo { ... }
export default Foo;

At the moment this doesn't work if you try to auto-import it by typing
let foo: Foo
(the interface wont appear in auto complete list).

Any chance you might implement this feature?

Btw thanks for the nice extension :)

Namespaces

Please add support for import of namespace. Currently it imports a class but it is not visible without importing namespace.

Don't import before a copyright header (comment at top of file)

Great plugin!

Given a file with no imports something like:

// Copyright 2017 Some company

const x = "foo";

If I let the plugin automatically import a type, it will put it above the copyright header, like

import * as React from "react";
// Copyright 2017 Some company

const x = "foo";

When in reality I want

// Copyright 2017 Some company

import * as React from "react";

const x = "foo";

Is it a feasible FR to have the plugin import the first import after an comment at the beginning of the file?

Add re-export support

Often modules extend other modules, and partially expose some of their features

export {x as y} from 'z';

Amazing extension!, just one question

Hi, your extension is amazing, the best importer there is currently available. Only question i had was: How can i exclude the tmp folder?.

Because in an app generated with the angular-cli i have a tmp folder full of brocolli .ts files and when the auto import looks for the components them there.

Or maybe not exclude the tmp folder explicitly for allow to select an array of expressions to be matched against when looking for folders to watch.

Thanks for this great extension, if you need some help i am more than willing!. Cheers

Not merging default and named imports

Hi.

When I import, from the same module, a named export and then the default export (or the other way around), it produces two different import entries instead of a single one.

Expected result:

import something, { named } from "./something";

Actual result:

import something from "./something";
import { named } from "./something";

Thanks for your time.

"Importance" of suggestions

I'm sure if VScode's API allows for that, but would it be possible for the extension's suggestions to be displayed below the "default" suggestions proposed by VScode?

I have removed a single property from the object on the screenshot below to illustrate the point. This one was done without the extension:

image

And this one with the extension:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.