convert to TS

This commit is contained in:
Tom Soukup
2022-12-13 18:06:35 +01:00
parent 4b03784956
commit 524360bb40
4 changed files with 18 additions and 12 deletions

View File

@@ -195,6 +195,7 @@ Create a basic [Solid](https://www.solidjs.com/) app.
| [vite:bundler](https://atmospherejs.com/vite/bundler) | | | | | | | | | | | X | X | | [vite:bundler](https://atmospherejs.com/vite/bundler) | | | | | | | | | | | X | X |
| [webapp](https://atmospherejs.com/meteor/webapp) | | | | X | | | | | | | | | | [webapp](https://atmospherejs.com/meteor/webapp) | | | | X | | | | | | | | |
| [zodern:melte](https://atmospherejs.com/zodern/melte) | | | | | | | | X | | | | | | [zodern:melte](https://atmospherejs.com/zodern/melte) | | | | | | | | X | | | | |
| [zodern:types](https://atmospherejs.com/zodern/types) | | | | | | | | X | | | | |
<h2 id="meteorgenerate"> meteor generate </h2> <h2 id="meteorgenerate"> meteor generate </h2>

View File

@@ -1,3 +0,0 @@
import { Mongo } from 'meteor/mongo';
export const LinksCollection = new Mongo.Collection('links');

View File

@@ -0,0 +1,9 @@
import { Mongo } from 'meteor/mongo';
export interface Link {
_id: string;
url: string;
title: string;
}
export const LinksCollection = new Mongo.Collection<Link>('links');

View File

@@ -1,18 +1,20 @@
<script> <script lang="ts">
import { LinksCollection } from '/imports/api/links'; import { Meteor } from "meteor/meteor";
import { LinksCollection, type Link } from '../api/links';
let counter = 0; let counter: number = 0;
const addToCounter = () => { const addToCounter = (): void => {
counter += 1; counter += 1;
} }
let subIsReady = false; let subIsReady: boolean = false;
$m: { $m: {
const handle = Meteor.subscribe('links.all'); const handle: Meteor.SubscriptionHandle = Meteor.subscribe("links.all");
subIsReady = handle.ready(); subIsReady = handle.ready();
} }
// more information about $m at https://atmospherejs.com/zodern/melte#tracker-statements // more information about $m at https://atmospherejs.com/zodern/melte#tracker-statements
let links: Link[];
$m: links = LinksCollection.find().fetch(); $m: links = LinksCollection.find().fetch();
</script> </script>
@@ -33,7 +35,4 @@
{:else} {:else}
<div>Loading ...</div> <div>Loading ...</div>
{/if} {/if}
<h2>Typescript ready</h2>
<p>Just add lang="ts" to .svelte components.</p>
</div> </div>