随笔分类 -  TypeScript

1 2 3 4 5 ··· 30 下一页
摘要:When you try to import image in typescript project, it will report issue import logo from "./assets/react.svg" What you can do is, create a types.d.ts 阅读全文
posted @ 2025-02-21 16:10 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:整合 TypeScript 准备工作 首先我们需要有一个基于 ts 的项目。 第一步通过 npm init -y 初始化项目 接下来通过: npm install typescript 局部安装 typescript。 之后还需要生成 typescript 的配置文件,通过命令: npx tsc - 阅读全文
posted @ 2025-01-25 18:45 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要:The Input is Different than the Output We've reached the point with Zod where our input is different than our output. In other words, you can generate 阅读全文
posted @ 2024-12-21 19:19 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Define a component with props and defualt props value <script setup lang="ts"> import { ref, onMounted } from 'vue' import fetchCount from '../service 阅读全文
posted @ 2024-11-27 22:33 Zhentiw 阅读(13) 评论(0) 推荐(0) 编辑
摘要:<template> <router-link class="event-link" :to="{ name: 'EventDetails', params: { id: event.id } }" > <div class="event-card"> <span>@{{ event.time }} 阅读全文
posted @ 2024-11-27 03:08 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:/** * Utility for extracting the parameters from a function overload (for typed emits) * https://github.com/microsoft/TypeScript/issues/32164#issuecom 阅读全文
posted @ 2024-11-25 21:30 Zhentiw 阅读(17) 评论(0) 推荐(0) 编辑
摘要:We have a module: const key = Symbol('key') export class A { [key] = 1 value () { console.log(this[key]) } } It seems that keyis not expose to outside 阅读全文
posted @ 2024-11-25 21:10 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:const BookingSchema = z.object({ roomType: z.string(), dueDate: z .string({ message: "invalid due date", }) .date('date format is wrong'), numberOfGue 阅读全文
posted @ 2024-11-19 15:50 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要:export enum EffectFlags { /** * ReactiveEffect only */ ACTIVE = 1 << 0, RUNNING = 1 << 1, TRACKING = 1 << 2, NOTIFIED = 1 << 3, DIRTY = 1 << 4, ALLOW_ 阅读全文
posted @ 2024-11-19 02:51 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:type BanType<T, E> = T extends E ? never : T; type BanDate<T> = BanType<T, Date>; function log<T>(x: BanDate<T>) { console.log() } log(new Date()) // 阅读全文
posted @ 2024-09-09 14:55 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:const requestFullscreenProps = [ "requestFullScreen", "webkitRequestFullScreen", "mozRequestFullScreen", "msRequestFullScreen", ] as const; const exit 阅读全文
posted @ 2024-09-09 14:39 Zhentiw 阅读(11) 评论(0) 推荐(0) 编辑
摘要:Consider this Result type: type Result<TResult, TError> = | { success: true; data: TResult; } | { success: false; error: TError; }; The Result type ha 阅读全文
posted @ 2024-09-06 15:03 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:Consider this package.json file: { "name": "exercise", "version": "1.0.0", "main": "index.js", "scripts": { "dev": "run-p dev:*", "dev:client": "tsc - 阅读全文
posted @ 2024-09-04 14:41 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:A long-awaited feature is smart incremental builds for TypeScript projects. In 3.0 you can use the --build flag with tsc. This is effectively a new en 阅读全文
posted @ 2024-09-03 21:28 Zhentiw 阅读(26) 评论(0) 推荐(0) 编辑
摘要:export const randomColor = () => { return "#" + Math.random().toString(16).substring(2, 8).padEnd(6, '0') } export const randomString = (len: number) 阅读全文
posted @ 2024-09-03 20:35 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:The solution is to modify the tsconfig.json file to enable declarationMap under the compilerOptions. // inside tsconfig.json { "compilerOptions": { "d 阅读全文
posted @ 2024-09-02 20:41 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:One of the interesting things about verbatimModuleSyntax in TypeScript is that it requires a specific type of import when you're working with types. L 阅读全文
posted @ 2024-08-13 01:29 Zhentiw 阅读(64) 评论(0) 推荐(0) 编辑
摘要:To fix the CommonJS export issue, we need to make a change to our tsconfig.json file. Add the verbatimModuleSyntax setting and set it to true: { "comp 阅读全文
posted @ 2024-08-13 01:24 Zhentiw 阅读(63) 评论(0) 推荐(0) 编辑
摘要:The module and moduleResolution options in the tsconfig.json file can be confusing. Here we'll discuss the differences between the module and moduleRe 阅读全文
posted @ 2024-08-13 01:17 Zhentiw 阅读(24) 评论(0) 推荐(0) 编辑
摘要:Here we're attempting to import several PNG files into our TypeScript program: import pngUrl1 from "./example1.png"; // red squiggly line under "./exa 阅读全文
posted @ 2024-08-08 19:20 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 30 下一页
点击右上角即可分享
微信分享提示