marko-js / language-server

Marko autocomplete, intellisense and editor support.
MIT License
37 stars 8 forks source link

[Language Server] Importing a `type` from an external `*.marko` file from a `*.ts` file throws an error #268

Open opes opened 2 weeks ago

opes commented 2 weeks ago

@marko/language-server@1.1.20

Details

In VS Code, when importing a type definition from a package outside of the project, the Marko language server displays an error.

Using library-ts + eBay UI Core as an example:

/my-project/src/types/index.ts

import type { Input as EbayButton } from "@ebay/ebayui-core/dist/components/ebay-button/index.d.marko";

export type { EbayButton };

File '/my-project/node_modules/@ebay/ebayui-core/dist/components/ebay-button/index.d.marko' is not under 'rootDir' '/my-project/src'. 'rootDir' is expected to contain all source files.

Expected Behavior

No error is displayed.

Actual Behavior

An error is displayed (the path to the type declaration file is underlined in red).

Possible Fix

Additional Info ### Your Environment - Environment name and version (e.g. Chrome 39, node.js 5.4): Node.js 20.12.2 - Operating System and version (desktop or mobile): M1 MacBook Pro, Sonoma 14.5 - Link to your project: https://github.com/marko-js/examples/tree/master/examples/library-ts ### Steps to Reproduce 1. Clone `library-ts` from https://github.com/marko-js/examples/tree/master/examples/library-ts 2. `npm install @ebay/ebayui-core` 3. Create `src/types/index.ts` 4. Add the code in the description above ### Stack Trace ``` The file is in the program because: Imported via "@ebay/ebayui-core/dist/components/ebay-button/index.d.marko" from file '/my-project/src/types/index.ts' Imported via "./index.marko" from file '/my-project/node_modules/@ebay/ebayui-core/dist/components/ebay-button/component-browser.d.ts' Root file specified for compilation ts(6059) ```