Export type definitions
See original GitHub issueWould it be possible to export the type definitions in index.d.ts
? That would make it possible to use the types in JavaScript projects.
Here’s an example of how PageFunction
could be used:
import { PagesFunction } from '@cloudflare/workers-types';
/** @type {PagesFunction} */
export async function onRequest(context) {
}
It’s also possible to import directly in the comment such as SvelteKit does it.
/** @type {import('@sveltejs/kit').RequestHandler} */
export async function get({ params }) {
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:16
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Documentation - Modules .d.ts - TypeScript
The types which are exported can then be re-used by consumers of the modules using either import or import type in TypeScript code...
Read more >How to export/import a only a type definition in TypeScript
js export the type myType using export type myType = {id: number}; and the file main.js imports the type using import type {myType}...
Read more >How to export a Type in TypeScript | bobbyhadz
Use a named export to export a type in TypeScript, e.g. export type Person = {} . The exported type can be imported...
Read more >How to export type definitions for third-party package? - Reddit
I'm writing a package that uses a third party package that doesn't include its own typescript definitions. I've written my own .d.ts ...
Read more >export type * from 'somewhere' #48508 - GitHub
So export type * from "foo" would export everything that export * from "foo" exports, values included, but those values would only be ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey! 👋 Thanks for reporting this, we’re actively thinking about ways of fixing this in the next major version of
workers-types
using the new type generation system. 👍For anyone coming across this issue, I’ve released a (hopefully temporary) package as a workaround:
cloudflare-workers-types-esm
Mostly just using the TS library to copy the @cloudflare/workers-types programmatically and add export clauses to them, coupled with some Github Actions black magic to semi-automatically keep the package in sync with @cloudflare/workers-types.
It’s been wildly useful in my projects so far, so I plan to keep it active until this issue is resolved.