From 59bb92384a88fd313e5b5dd736282a0eabfe9b99 Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Sun, 28 May 2023 06:02:12 +0000 Subject: [PATCH] fix: don't set the port --- mod.ts | 2 +- tests/test.ts | 134 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 83 insertions(+), 53 deletions(-) diff --git a/mod.ts b/mod.ts index 324d889..82a2a05 100644 --- a/mod.ts +++ b/mod.ts @@ -81,7 +81,7 @@ router.get("/articles/:id", ({ match }) => { }); }); -serve(router.dispatch.bind(router), { port: 8080 }); +serve(router.dispatch.bind(router)); // serve(async (req: Request) => { // let { pathname, searchParams } = new URL(req.url); diff --git a/tests/test.ts b/tests/test.ts index d626c39..f697787 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -4,66 +4,96 @@ import { path } from "../deps.ts"; const { dirname, fromFileUrl, join } = path; const __dirname = dirname(fromFileUrl(import.meta.url)); -const slash = twoslasher(`\ -// @module: esnext -// @target: ES2022 -// @errors: 1003 2304 7006 2339 -// @declaration: true -// @emit -// @filename: maths.ts -/** - * Gets the length of a string - * @param value a string - */ -function fnx2(s: string) { - console.log(s.substr(3)) -} -export function absolute(num: number) { - if (num < 0) return num * -1; - return num; -} +// const slash = twoslasher(`\ +// // @module: esnext +// // @target: ES2022 +// // @errors: 1003 2304 7006 2339 +// // @declaration: true +// // @emit +// // @filename: maths.ts +// /** +// * Gets the length of a string +// * @param value a string +// */ +// function fnx2(s: string) { +// console.log(s.substr(3)) +// } +// export function absolute(num: number) { +// if (num < 0) return num * -1; +// return num; +// } -import {SpringEasing} from "spring-easing" -SpringEasing -// ^? +// import {SpringEasing} from "spring-easing" +// SpringEasing +// // ^? -/** - * Gets the length of a string - * @param value a string - */ -function fnx(s: string) { - console.log(s.substr(3)) -// ^^^^^^^^^^^ -} +// /** +// * Gets the length of a string +// * @param value a string +// */ +// function fnx(s: string) { +// console.log(s.substr(3)) +// // ^^^^^^^^^^^ +// } -export const slash = [] as string[] - fnx("42") -//^? -// ^^^^^^^ You need a description for highlight to work properly +// export const slash = [] as string[] +// fnx("42") +// //^? +// // ^^^^^^^ You need a description for highlight to work properly -function greet(person: string, date: Date) { - console.log(\`Hello \${person}, today is \${date.toDateString()}!\`) -} +// function greet(person: string, date: Date) { +// console.log(\`Hello \${person}, today is \${date.toDateString()}!\`) +// } - greet("Maddison", new Date()) -// ^^^^^ A Quick explanation -console.g -// ^| +// greet("Maddison", new Date()) +// // ^^^^^ A Quick explanation +// console.g +// // ^| -// @filename: index.ts -import {absolute} from "./maths" -const value = absolute(-1) -// ^? -// ^^^^^^ Velue -const value2 = absolute(-2) -// ^? -// ^^^^^^ Value2 +// // @filename: index.ts +// import {absolute} from "./maths" +// const value = absolute(-1) +// // ^? +// // ^^^^^^ Velue +// const value2 = absolute(-2) +// // ^? +// // ^^^^^^ Value2 -function fn(s) { - console.log(s.substr(3)) -} -`, "ts") +// function fn(s) { +// console.log(s.substr(3)) +// } +// `, "ts") +const slash = await fetch(`https://ts-check.okikio.dev/twoslash`, { + method: "POST", + body: JSON.stringify({ + "code": "const abolute = (num: number) => num < 0 ? num * -1 : num\n// ^?\n", + "extension": "ts", + "defaultOptions": { + "noErrors": false, + "errors": [ + 1016, + 2307 + ], + "showEmit": true, + "showEmittedFile": "index.js", + "noStaticSemanticInfo": false, + "emit": false, + "noErrorValidation": false + }, + "defaultCompilerOptions": { + "target": "es5", + "module": "commonjs" + }, + "fsMap": { + "index.ts": "export const x = 10" + }, + "customTags": [ + "tag1", + "tag2" + ] + }) +}).then(res => res.json()) // console.log({ // slash: await slash // }) -- 2.51.2