Nativescript: VSCode TS autoimport is most of the times wrong

Created on 21 Aug 2019  路  2Comments  路  Source: NativeScript/NativeScript

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.0.3
  • Cross-platform modules: 6.0.0
  • Android Runtime: 6.0.0
  • iOS Runtime: 6.0.0
  • Plugin(s):

Describe the bug
Most of the time when I use the auto-import in vscode the import is a total mess and does not represent the actual path. This on a newly started project with NS 6.0 and using long import paths.

To Reproduce

  • Observable is imported from tns-core-modules/ui/page/page.
    Correct one is tns-core-modules/data/observable
  • ObservableArray is imported from tns-core-modules/data/observable-array/observable-array.
    Correct one is tns-core-modules/data/observable-array
  • View is imported from tns-core-modules/ui/page/page
    Correct one is tns-core-modules/ui/core/view
  • GridLayout isn't even recognized for auto import

Expected behavior
Objects to be auto-imported from their correct locations instead of their aliased/exported paths.

Sample project

Additional context
May be something that can be fixed together with moving to scoped packages (#4041 )

bug vscode

Most helpful comment

One issue that causes this is that a lot of the submodules in tns-core-modules actually re-export items when they shouldn't.

For instance, Observable is re-exported in tns-core-modules/ui/page/page when it really should only be imported by that module and only exported by tns-core-modules/data/observable.

All 2 comments

This is a real pain-point for me as a developer, and makes React Native far more ergonomic to work with. In React NativeScript, I re-export many key modules from one file (just like #4041) to improve Intellisense, but it would be great if the NativeScript team could do the suggested refactor from #4041 to improve the developer experience for everyone.

One issue that causes this is that a lot of the submodules in tns-core-modules actually re-export items when they shouldn't.

For instance, Observable is re-exported in tns-core-modules/ui/page/page when it really should only be imported by that module and only exported by tns-core-modules/data/observable.

Was this page helpful?
0 / 5 - 0 ratings