admin管理员组文章数量:1123694
I want to import the type of Deno.connect()
argument. In VSCode, it shows the type is ConnectOptions
defined in lib.deno.d.ts. I use deno types > lib.deno.d.ts
to generate the ts file so that other files can import the types. But then deno check
/deno compile
reports duplicate identifier errors. How can I import a Deno builtin type, and still be able to run commands like deno check
?
Example code:
Case 1, no import
// main.ts
export function f(options: ConnectOptions) {
}
deno check main.ts
result:
error: TS2304 [ERROR]: Cannot find name 'ConnectOptions'.
Case 2, run deno types > lib.deno.d.ts
and add import
// main.ts
import type { ConnectOptions } from "./lib.deno.d.ts"
export function f(options: ConnectOptions) {
}
deno check main.ts
result:
error: TS2300 [ERROR]: Duplicate identifier 'Addr'. export type Addr = NetAddr | UnixAddr;
other duplicate identifier errors...
I want to import the type of Deno.connect()
argument. In VSCode, it shows the type is ConnectOptions
defined in lib.deno.net.d.ts. I use deno types > lib.deno.d.ts
to generate the ts file so that other files can import the types. But then deno check
/deno compile
reports duplicate identifier errors. How can I import a Deno builtin type, and still be able to run commands like deno check
?
Example code:
Case 1, no import
// main.ts
export function f(options: ConnectOptions) {
}
deno check main.ts
result:
error: TS2304 [ERROR]: Cannot find name 'ConnectOptions'.
Case 2, run deno types > lib.deno.d.ts
and add import
// main.ts
import type { ConnectOptions } from "./lib.deno.d.ts"
export function f(options: ConnectOptions) {
}
deno check main.ts
result:
Share Improve this question edited 8 hours ago Jackoo asked yesterday JackooJackoo 2991 gold badge3 silver badges15 bronze badges 1 |error: TS2300 [ERROR]: Duplicate identifier 'Addr'. export type Addr = NetAddr | UnixAddr;
other duplicate identifier errors...
1 Answer
Reset to default 0The builtin types can be referred from the Deno
global
export function f(options: Deno.ConnectOptions) {
}
本文标签: typescriptHow to import a Deno builtin typeand still be able to run deno checkStack Overflow
版权声明:本文标题:typescript - How to import a Deno builtin type, and still be able to run deno check? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736589250a1945052.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
deno check
already includes those types in the ambient scope (so there's no need to import them). – jsejcksn Commented 14 hours ago