-
Notifications
You must be signed in to change notification settings - Fork 239
TypeScript view #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
One option would be a toggle in the sidebar to change between TS and JS But I think the main issue with this is that it requires to write all content in both typescript and javascript, which could be a lot of duplication/extra work. What about a section
|
Not necessarily. We have the same problem for
<script lang="ts">
import { enhance } from '$lib/form';
import { scale } from 'svelte/transition';
import { flip } from 'svelte/animate';
/**
* @typedef {{
* uid: string;
* created_at: Date;
* text: string;
* done: boolean;
* pending_delete: boolean;
* }} Todo
*/
type Todo = {
uid: string;
created_at: Date;
text: string;
done: boolean;
pending_delete: boolean;
};
/** @type {Todo[]} */
export let todos: Todo[];
</script> import { api } from './_api';
import type { RequestHandler } from './__types';
/** @type {import('./__types').RequestHandler} */
export const get: RequestHandler = async ({ locals }) => {
// ...
} In other words we write TypeScript and annotate it with redundant JS, then we have the option of keeping the TS and removing the JSDoc, keeping the JSDoc and removing the TS, or removing both. It's a bit more work than just writing type-less code, but it's not twice as much work, and there's little danger of things falling out of sync. We could do the same here. Design-wise I feel like it needs to be a top-level option (maybe in the menu) since it should apply to code snippets in the sidebar as well. |
I have a feeling comparing contents for the solve button would end up being kinda painful, maybe it won't be with fetching the transformed files from vite for comparison. |
would be neat if we could opt into TypeScript, both as
.ts
andlang="ts"
, and opt into JSDoc otherwiseThe text was updated successfully, but these errors were encountered: