Skip to content

Commit

Permalink
[chore] typecheck example (#2019)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Jul 27, 2021
1 parent 20dad18 commit f732275
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
11 changes: 9 additions & 2 deletions examples/hn.svelte.dev/src/routes/[list]/rss.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @param {string} list
* @param {Record<string, any>[]} items
*/
const render = (list, items) => `<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
Expand Down Expand Up @@ -27,9 +31,12 @@ const render = (list, items) => `<?xml version="1.0" encoding="UTF-8" ?>
</channel>
</rss>`;

export function get(req, res) {
/**
* @type {import('@sveltejs/kit').RequestHandler}
*/
export function get({ params }) {
const list =
req.params.list === 'top' ? 'news' : req.params.list === 'new' ? 'newest' : req.params.list;
params.list === 'top' ? 'news' : params.list === 'new' ? 'newest' : params.list;

fetch(`https://api.hnpwa.com/v0/${list}/1.json`)
.then((r) => r.json())
Expand Down
12 changes: 9 additions & 3 deletions examples/hn.svelte.dev/src/routes/rss.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export function get(req, res) {
res.redirect('/top/rss');
}
/**
* @type {import('@sveltejs/kit').RequestHandler}
*/
export function get() {
return {
headers: { Location: '/top/rss' },
status: 301
};
}
10 changes: 8 additions & 2 deletions examples/hn.svelte.dev/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"baseUrl": ".",
"paths": {
"$lib/*": ["./src/lib/*"]
"$lib": ["src/lib"],
"$lib/*": ["src/lib/*"]
}
}
},
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
}

0 comments on commit f732275

Please sign in to comment.