deep-foundation / deepcase-app

https://deep-foundation.github.io/deepcase-app/
The Unlicense
11 stars 7 forks source link

feature: add autocompletion when importing libraries #182

Open FreePhoenix888 opened 1 year ago

FreePhoenix888 commented 1 year ago

Code

async ({require}) => {
  const { Link } = require('@deep-foundation/deeplinks/imports/minilinks'); 
  const link: Link<number> = {
    // When I write here I want to see autocompletion
}

Additional Information

If we create interface inside our root function and use the interface - typescript works fine. The problem is related only to the require parameter that is of type any and Typescript does not know what that require can return. It is not the same as using builtin require

FreePhoenix888 commented 1 year ago

I have found this solution on stackoverflow: https://stackoverflow.com/a/52294684/13545849 But what If there are two entities with the same exported from two different packages?

Look at this demo

FreePhoenix888 commented 1 year ago

I like this answer: https://stackoverflow.com/a/65555804/13545849

FreePhoenix888 commented 1 year ago

https://github.com/lukasbach/monaco-editor-auto-typings/issues/7#issuecomment-1017480688 Unable to resolve package names with '@' :(

FreePhoenix888 commented 1 year ago

@Konard , I need to know how bundler will be working because this information can help me how I should add types to monacoeditor: https://chat.openai.com/share/85140d0d-25db-45a6-8d37-0151faf9507d

Konard commented 1 year ago

@FreePhoenix888 it is planned to work using require function.

FreePhoenix888 commented 1 year ago

@FreePhoenix888 it is planned to work using require function.

This is not what I want to hear. I want to know is there is some info about bundler that I can use for this issue? Should I use typeRoots option? If no - how should Monaco editor understand types of which dependencies needs to be added? Depending on the code? If yes - what if the package is not installed in isolation provider? Will this problem be solved with bundler or what? Please give me as descriptive answer as you can. I need to solve my puzzle

Konard commented 1 year ago

@FreePhoenix888 with bundler no packages will be installed into isolation provider, most of them will be removed. Bundler creates a bundle when package is installed in Deep. The bundle is stored in database. I need to know which data is required for Monaco editor to do typing support. May be bundler itself is not enough, because it creates bundle using webpack, and the output result is single javascript file. At the moment I'm not sure how it will work with .d.ts files and so on.