exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework

Home Page:https://ultrajs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VSCode Deno Plugin + ultra: "Go to definition" command doesn't work for React lib

d9k opened this issue · comments

Created Ultra project with deno run -A -r https://deno.land/x/ultra/create.ts using these answers.

Then opened VS Code IDE + Deno plugin at
https://github.com/d9k/d9k-examples/blob/main/ts/ultra-demo-react-autocomplete/src/app.tsx:

Go to definition VSCode command doesn't work for React imports (useEffect, useState).

Versions

> deno --version
deno 1.38.4
> code --version
1.85.0

VSCode Deno extension plugin: v 3.29.0
Ultra: v 2.3.8

I had similar, but more critical issue (not only Go to definition didn't work, but there were TypeScript compilation error) with react-fela

https://github.com/d9k/citations-supabase-demo/blob/847a97b76a9de202d7431b8458da95b49542a079/src/deps/react-fela/index.ts

and I solved it like this:

// @deno-types="./index.d.ts"
export * from 'react-fela';

If while having in importMap.json:

    "react": "https://esm.sh/react@18.2.0?dev",
    "@types/react": "https://esm.sh/v128/@types/react@18.2.38/index.d.ts",

I try similar stuff with react: src/deps/react.ts:

// @deno-types="@types/react"
export * from "react";

I get error

Module '"https://esm.sh/v128/@types/react@18.2.38/index"' uses 'export =' and cannot be used with 'export *'.deno-ts(2498)

And in src/app.ts:

`import { useEffect, useState } from "./deps/react.ts"`:

Error Module '"./deps/react.ts"' has no exported member 'useEffect'.deno-ts(2305).

Ugly solution:

// @deno-types="@types/react"
export {
   useState,
   useEffect,
} from "https://esm.sh/react@18.2.0?dev"

This does work (and Go to definition VSCode command too) but now I must reexport every react module member manually by name.

After experimenting in another branch (see deps/react.ts) seems @types/react somehow propely cached and issue with Go to definition doesn't appears anymore (in other local ultra projects too).

Very strange...

Before opening this issue I tried rm -r ~/.cache/deno and restarting VS Code. It didn't help.

Will close issue for now because it have not clearly steps to reproduce.