Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

How to import global types/interfaces? #129

Answered by ije
autsada asked this question in Q&A
Discussion options

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".

You must be logged in to vote

/// <reference lib="dom" /> can work

Replies: 4 comments 12 replies

Comment options

Please don't use issues for questions, use discussions or the discord instead.

You must be logged in to vote
1 reply
Comment options

Noted, thank you.

Comment options

please try import type {HTMLButtonElement} from "react"

You must be logged in to vote
7 replies
Comment options

Hi @shadowtime2000

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"

Comment options

@autsada Oh yeah forgot about that, I don't think esm.sh allows importing @types/ packages.

Comment options

I think its possible its available in the global scope because of the TS JSX stuff but not sure...

Comment options

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.

Comment options

By the way, is it possible to use tsconfig.json in aleph?

Comment options

since we switchy to swc that doesn't support type check yet instead of tsc, tsconfig doesn't work in alephjs.

You must be logged in to vote
0 replies
Comment options

/// <reference lib="dom" /> can work

You must be logged in to vote
4 replies
Comment options

Thank you, I will give it a try.

Comment options

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

Comment options

@autsada I think you will have to put it in all the files that are using it...

Comment options

@shadowtime2000 thank you.

Answer selected by autsada
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #128 on February 06, 2021 04:26.

AltStyle によって変換されたページ (->オリジナル) /