Skip to content
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

Auto importing doesn't work in VSCode #209

Open
NickIliev opened this issue Sep 19, 2018 · 2 comments
Open

Auto importing doesn't work in VSCode #209

NickIliev opened this issue Sep 19, 2018 · 2 comments

Comments

@NickIliev
Copy link

From @larssn on September 19, 2018 8:8

Tell us about the problem

So our company just switched to NativeScript from Cordova, and we're used to VSCode being able to auto-import classes etc. that reside in node_modules. However that doesn't seem to work for NativeScript, where it works for everything else.

Which platform(s) does your issue occur on?

Mac/Windows

Please provide the following version numbers that your issue occurs with:

  • CLI: 4.2.3
  • Cross-platform modules: 4.2.0
  • Runtime(s): 4.2.0 & 4.2.0
  • Plugin(s):
    "nativescript-angular": "^6.1.0",
    "nativescript-plugin-firebase": "^6.8.1",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-listview": "^3.6.1",
    "nativescript-ui-sidedrawer": "~4.2.0",

Please tell us how to recreate the issue in as much detail as possible.

Just create a new NS angular project. Go into app.component.ts and paste the following constructor.

constructor(
    private modalService: ModalDialogService
  ) { }

Confirm that VSCode can't figure out where ModalDialogService is located ('No suggestions' dialog).
Now confirm that you have the module already, by pasting the import import { ModalDialogService } from 'nativescript-angular/directives/dialogs';

Auto imports is a really important feature to us, being new at the framework in general. It greatly speeds up our workflow.

Copied from original issue: NativeScript/NativeScript#6279

@larssn
Copy link

larssn commented Sep 19, 2018

I should add that I'm already using the NativeScript extension in VSCode (if that is required), and no auto-imports.

And sorry for posting in the wrong issue tracker :)

@larssn
Copy link

larssn commented Sep 19, 2018

So creating a references.d.ts file with the contents: /// <reference path="node_modules/tns-core-modules/tns-core-modules.d.ts" /> fixes the problem.

Any reason creating a new plugin doesn't ship with this?

Also, have you considered using the @types functionality that TS2.0 introduced? I'm talking about something like npm install @types/tns-core-modules --save-dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants