Open vlascik opened 7 years ago
@vlascik to be honest I'd rather just have the IDE suggest the right import automatically instead of adding snippets that you would have to manually invoke
I would much rather have auto imports like in JVM languages, but not sure if that will ever happen...
I noticed IntelliJ supports javascript auto-import already in some cases. If you have this module
// foo.js
export function foo() {}
and in another file you type foo
then Ctrl-Space, it will autocomplete to
import {foo} from "./foo";
foo()
Maybe all we need is typescript definitions for the new ember modules
Maybe all we need is typescript definitions for the new ember modules
Not sure if those are auto-imported in JS files too, but for TS files that should probably work
Hm typescript definitions seem to be doable, https://www.typescriptlang.org/docs/handbook/modules.html#working-with-other-javascript-libraries . Maybe these could be generated from data at https://github.com/ember-cli/ember-rfc176-data with a script similar to ones that are there already.
You can use TS definitions in JS too, just go to Settings -> Languages & Frameworks -> Javascript -> Libraries -> Download.
The auto imports work for typescript...
I can't get it working for javascript sources. It autocompletes global declarations but won't import from an ambient module.
@denofevil any clue how we can make this work in JS files?
@Turbo87 @vlascik can you please share the typescript definitions?
@anstarovoyt this is what I'm testing with:
// ember.d.ts
declare module "@ember/component" {
export class Component {}
}
So, got bored, and created a script to generate ember.d.ts
based on RFC 176 data: https://github.com/ember-cli/ember-rfc176-data/pull/25
Generated file here: https://gist.github.com/vlascik/678b7163f2cd62241b3ede0a0fe66c87
Module name completion should work, but as said previously, in JS files, auto imports don't.
I just recently upgraded my main project to Ember-2.16 and would love my JetBrains IDE to auto-import. I'm speculating that we've still got many things to figure out.
I've hacked some Live Templates together; over in this Gist: https://gist.github.com/nadnoslen/82e29fae98d12bbc81e6614abdd211dd
I'd be happy to put a PR together that includes this new template file. Might need to settle on naming conventions; I've used i[TYPE]
; e.g. icomputed
.
Here's an example, it's manual and it kind of auto-completes for you:
Until the IDE can do this better, I've packaged up my live templates for just these Ember-2.16+ imports. The attached live-templates.zip
that contains only the one live template group: "Ember.js-2.16+ Import Templates"...and it looks like this:
How about some snippets similar to https://atom.io/packages/ember-module-snippets ? This could help with the learning curve for new modules api layout a lot.