TypeScript example
See original GitHub issueIt would be nice for a typescript example of workers. As right now, I can’t seem to find any type definitions for the most basic example:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Fetch and log a given request object
* @param {Request} request
*/
async function handleRequest(request) {
console.log('Got request', request)
const response = await fetch(request)
console.log('Got response', response)
return response
}
https://github.com/zeit/ncc could probably be used for generating the compiled bundle, as it supports typescript
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Documentation - TypeScript for JavaScript Programmers
TypeScript knows the JavaScript language and will generate types for you in many cases. For example in creating a variable and assigning it...
Read more >Typescript example: Beginners Guide To ... - AppDividend
Typescript is a typed superset of Javascript that compiles to plain JavaScript. TypeScript is open source language maintained by Microsoft.
Read more >TypeScript Tutorial - Tutorialspoint
TypeScript is pure object oriented with classes, interfaces and statically typed like C# or Java. The popular JavaScript framework Angular 2.0 is written...
Read more >TypeScript Tutorial - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python,...
Read more >TypeScript Tutorial: What is, Interface, Enum, Array with Example
Above TypeScript example throws an error, but the same would have worked fine if it was with the var keyword. Variables using let...
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 FreeTop 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
Top GitHub Comments
would be nice to update that blog post to use babel-loader (the defacto standard for typescript + webpack now), instead of awesome-typescript-loader
I know this is old, but this is now available in the
/worker-typescript
subdirectory.You can create a project with it by visiting https://workers.new/typescript or locally via: