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

Intellisense seems to be broken (see magic function for DHIS2) #2641

Open
christad92 opened this issue Nov 7, 2024 · 8 comments · Fixed by #2662
Open

Intellisense seems to be broken (see magic function for DHIS2) #2641

christad92 opened this issue Nov 7, 2024 · 8 comments · Fixed by #2662
Assignees
Labels
bug Newly identified bug

Comments

@christad92
Copy link

When using the DHIS2 adaptor with the credentials well configured and metadata loaded, the IntelliSense did not load. Even when you try to manually trigger it by entering ctrl/cmd + space, it doesn't load.

@christad92 christad92 added the bug Newly identified bug label Nov 7, 2024
@christad92 christad92 moved this to Backlog in v2 Nov 7, 2024
@christad92 christad92 added this to v2 Nov 7, 2024
@josephjclark
Copy link
Contributor

When you say "it doesn't load", do you mean you don't see the suggestions list at all, like you don't see a UI component; or do you mean there's an empty list? With No Suggestions or just with irrelevant stuff?

I've just done a quick check on app and I get "dumb" code assist, with no metadata. I think that's a problem with my credential though because I have no metadata at all...

@taylordowns2000
Copy link
Member

The metadata loads into the metadata panel, but code completion using metadata (press control+. for a list of available tracked entity attributes, for example) no longer shows the list in the typeahead box.

@josephjclark
Copy link
Contributor

I'll take a close look on Monday

@josephjclark josephjclark self-assigned this Nov 9, 2024
@josephjclark
Copy link
Contributor

Confirmed - intellisense was working in 2.8.0 but seems to be broken in main and I think 2.9.0

@josephjclark
Copy link
Contributor

Here is the PR that introduced the issue #2433

@josephjclark
Copy link
Contributor

"It kinda works."

He said, heroically.

@josephjclark
Copy link
Contributor

So, what's going on here is this.

In the old world, we loaded all the type definitions associated with an adaptor and squashed them into a s single global type definition. This sort of worked, although it flattened namespaces like http., and it also meant that everything declared in every file (including common) was made available to code assist.

So we put out a fix which loaded each file within the adaptor into a module. This worked better - we had namespaces now. But it's still too keen to expose common functions. And it turns out that if an adaptor declares some global types in a types.d.ts, those types don't get loaded.

Basically the when the typescript engine loads adaptor.d.ts, it doesn't see the types that it cross-references. In DHIS2, we declare a global type called Dhis2Data in types.d.ts and refer to it in adaptor.d.ts. But the inner workings of Monaco - which doesn't properly module a filesystem or project - mean that those type references aren't ever found.

I think I have a fix and a PR will come up shortly.

Basically we a) load each file as its own module ie @openfn/langauge-dhis/Adaptor2, b) convert all relative paths like import thing from './Util' into absolute imports like import thing from './Util' and c) force the global types.d.ts into every module we declare.

This seems to work. At what cost, I am not entirely sure...

@github-project-automation github-project-automation bot moved this from In progress to Done in v2 Nov 13, 2024
@josephjclark josephjclark reopened this Nov 13, 2024
@josephjclark
Copy link
Contributor

Metadata is still broken :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Newly identified bug
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants