Skip to content

Auto import feature #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cevek opened this issue Dec 16, 2015 · 36 comments
Closed

Auto import feature #782

cevek opened this issue Dec 16, 2015 · 36 comments
Labels

Comments

@cevek
Copy link

cevek commented Dec 16, 2015

Webstorm have cool feature like auto import entities from indexed files

for example we are typing: new Foo() and WS prompt "import Foo from 'foo.ts'?" if we says yes, then it append to header import {Foo} from './deep/folder/path/foo'
jhl ts - del - --dev-del 2015-12-16 13-20-51

@basarat
Copy link
Member

basarat commented Dec 18, 2015

Cool. Some guidance : https://github.com/TypeStrong/atom-typescript/blob/master/docs/quickfix.md

⚠️ Its hard stuff that needs close attention ... so instead of marking up for grabs marking as wishlist as I value contributor time and effort 🌹

@cevek
Copy link
Author

cevek commented Dec 21, 2015

Great!
But why import foo = require('../foo') instead of import {foo} from '../foo'?

@basarat
Copy link
Member

basarat commented Dec 21, 2015

why import foo = require('../foo') instead of import {foo} from '../foo'?

import foo = is not the same as import {foo}. it is more like import * as foo 🌹

@jschwarty
Copy link
Contributor

I have a PR (#791) submitted that adds a quick fix option for an "import from" statement.

@ambition-consulting
Copy link

I got a missing dependency "Cannot find name ", but get no quick fix suggestion. I am on version 7.16.1. Any advice?

Thanks for your work - this feature is much needed.

@basarat
Copy link
Member

basarat commented Jan 11, 2016

@amb-it-ion can you share the code snippet. Might be the canProvideFix check is not valid for your code https://github.com/TypeStrong/atom-typescript/pull/791/files#diff-8fa30ff973791698c79754125ec84700R39

@dawidk92
Copy link

+1

2 similar comments
@Regaddi
Copy link

Regaddi commented Mar 2, 2016

+1

@sharpmachine
Copy link

+1

@basarat
Copy link
Member

basarat commented Apr 25, 2016

Please note that the TypeScript team is investigating a QuickFix api similar to Refactor api. Everyone is ofcourse is free to do whatever, this was just info 🌹

@satanworker
Copy link

Sorry, guys but is it working right now?
really want to use atom with TS, but without auto import feature like in Webstrom, feels really akward :)

@gvlekke
Copy link

gvlekke commented Aug 5, 2016

+1

@jonaskello
Copy link

+1 This is the reason I stay with Webstorm. There is a package that does this for regular js. Could it be ported to work for ts?

@fernandogomesdf
Copy link

+1

@tuliogoiania
Copy link

please 👍

@jonaskello
Copy link

If I understand correctly this PR adds this feature to the TS language service. If that is true I guess it is just a matter of connecting it.

@dogancana
Copy link

dogancana commented Nov 28, 2016

+1

I"m a noob in atom but maybe https://atom.io/packages/typescript-modules-helper this one could be helpful.

@ctretyak
Copy link

i need it!

@guncha
Copy link
Contributor

guncha commented Mar 22, 2017

I need it too!! 😄

@elvnthaus
Copy link

please please +1

@harrydroid
Copy link

Please I need it too, I had switched to VisualCode Studio

@Goodwine
Copy link

Goodwine commented May 9, 2017

@dogancana, This package does help but it's not good enough.
For example in my tsconfig I have paths:{ "asd": [ "../a/s/d" ] }, files: "../a/s/d/F.ts"
Then when I try to use F, instead of adding import F from 'asd/F' I would get import F from '../../../../../a/s/d/F'

@guncha
Copy link
Contributor

guncha commented Jun 26, 2017

Codefix support that lets you do this sort of thing is now in the latest atom-typescript. To use: put the cursor on identifier where you see the "Cannot find name 'foo'", then press ctrl+enter to show available codefixes. It works with paths option in tsconfig.json, but only if you have specified a single path, not multiple.

@guncha guncha closed this as completed Jun 26, 2017
@Drabc
Copy link

Drabc commented Jun 26, 2017

Is there anything special I need to do to set this up? I just tried it and it didn't work
atom 1.18.0
os Fedora 24
atom-typescript 11.0.4

@guncha
Copy link
Contributor

guncha commented Jun 26, 2017

@Drabc There isn't any special setup required, you just need a fairly recent Typescript version. It also might not work because you're trying to auto-import something from node_modules. This only works for imports from files in your project.

@Goodwine
Copy link

Same, it does work for me but my binding is alt-enter, try pressing Ctrl-Shift-P and look for "intentions: show" maybe you have it bound to different keys.

@guncha
Copy link
Contributor

guncha commented Jun 26, 2017

Right, I wasn't clear that ctrl+enter is the default for OSX only. For Linux and Windows, it's alt+enter. This is the package we're using for the GUI part of this: https://atom.io/packages/intentions

@AndrewBogushevich
Copy link

AndrewBogushevich commented Jul 20, 2017

Using atom 1.18.0 x64 on windows7
atom-typescript 11.0.6
alt+enter => nothing happens
ctrl+shift+p => intentions: show => nothing.
what can be the reason?
@guncha

There isn't any special setup required, you just need a fairly recent Typescript version

what do you mean under install typescript, install atom-typescript package in atom, npm i -g typescript?
P.S. linter errors also doesn't show intentions on alt+enter

@klesun
Copy link

klesun commented Jul 23, 2017

Just for info, 2.1.5 < "fairly recent Typescript version" <= 2.4.2

@AndrewBogushevich
Copy link

AndrewBogushevich commented Jul 24, 2017

package.json contains angular-cli version of TS(2.2.2)

@xiaobaker
Copy link

this is awesome! btw do we support single quote instead of double quote in the autofix?

@kevinlinhaw
Copy link

@AndrewBogushevich
Did you get it to work on Windows?
I tried on atom 1.20.0 x64 on both Windows10 and Windows8, no dice.
neither shortcut key and intentions: show command works....

on mac it works perfectly though, any ideas?

@AndrewBogushevich
Copy link

@kevinlinhaw
Nope. I've just installed VSCode.

@eugensunic
Copy link

Come on guys WHY ISN'T THERE STILL A PACKAGE FOR THIS?!?!

@guncha
Copy link
Contributor

guncha commented Sep 25, 2017

@eugensunic, because you haven't built it.

@juanlet
Copy link

juanlet commented Jan 4, 2018

this would be super nice

@TypeStrong TypeStrong locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests