- 
  Notifications
 
You must be signed in to change notification settings  - Fork 166
 
-
Hi,
I am playing around with aleph quite a bit to learn it, and have one question.
My question is how to import global types/interfaces that globally available in react (@types/react (global.d.ts)), for example, "HTMLButtonElement".
Beta Was this translation helpful? Give feedback.
All reactions
/// <reference lib="dom" /> can work
Replies: 4 comments 12 replies
-
Please don't use issues for questions, use discussions or the discord instead.
Beta Was this translation helpful? Give feedback.
All reactions
-
Noted, thank you.
Beta Was this translation helpful? Give feedback.
All reactions
-
please try import type {HTMLButtonElement} from "react"
Beta Was this translation helpful? Give feedback.
All reactions
-
I also tried to import "@types/react" but go this error ```
"error: Import 'https://esm.sh/@types/react@17.0.1' failed: 500 Internal Server Error
exit with code: 1"
Beta Was this translation helpful? Give feedback.
All reactions
-
@autsada Oh yeah forgot about that, I don't think esm.sh allows importing @types/ packages.
Beta Was this translation helpful? Give feedback.
All reactions
- 
 
👍 1 
-
I think its possible its available in the global scope because of the TS JSX stuff but not sure...
Beta Was this translation helpful? Give feedback.
All reactions
-
I saw in dext the preact framework in deno that is also inspired by next, they have tsconfig.json that set lib to "dom" so it might enable us to use that global types but not sure about this.
{
 "compilerOptions": {
 "lib": ["esnext", "dom", "deno.ns"],
 "jsx": "react",
 "jsxFactory": "h",
 "jsxFragmentFactory": "Fragment"
 }
}
And also this issue in deno that might relate to the issue I am facing.
Beta Was this translation helpful? Give feedback.
All reactions
-
By the way, is it possible to use tsconfig.json in aleph?
Beta Was this translation helpful? Give feedback.
All reactions
-
since we switchy to swc that doesn't support type check yet instead of tsc, tsconfig doesn't work in alephjs.
Beta Was this translation helpful? Give feedback.
All reactions
-
/// <reference lib="dom" /> can work
Beta Was this translation helpful? Give feedback.
All reactions
- 
 
👍 1 
-
Thank you, I will give it a try.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @ije
Yes, it works.
Just one more question please, where is the right file to put this directive? Now I have it in the root file app.tsx
Beta Was this translation helpful? Give feedback.
All reactions
-
@autsada I think you will have to put it in all the files that are using it...
Beta Was this translation helpful? Give feedback.
All reactions
- 
 
👍 1 
-
@shadowtime2000 thank you.
Beta Was this translation helpful? Give feedback.