ICode9

精准搜索请尝试: 精确搜索
  • [Typescript] Defining a namespace alias2022-09-08 15:01:04

    namespace AllGreetings { export namespace Greetings { export function returnGreeting (greeting: string) { console.log(`The message from namespace Greetings is ${greeting}.`); } } export namespace GreetingsWithLength

  • [Typescript] 17. Medium - Readonly 22022-09-08 04:33:29

    Implement a generic MyReadonly2<T, K> which takes two type argument T and K. K specify the set of properties of T that should set to Readonly. When K is not provided, it should make all properties readonly just like the normal Readonly<T>. For

  • [Typescript] 18. Medium - Deep Readonly2022-09-08 03:00:08

    Implement a generic DeepReadonly<T> which make every parameter of an object - and its sub-objects recursively - readonly. You can assume that we are only dealing with Objects in this challenge. Arrays, Functions, Classes and so on do not need to be

  • Typescript类型体操 - String to Union2022-09-07 21:01:28

    题目 中文 实现一个将接收到的 String 参数转换为一个字母 Union 的类型。 例如 type Test = '123'; type Result = StringToUnion<Test>; // expected to be "1" | "2" | "3" English Implement the String to Union type. Type take string argument. Th

  • Typescript类型体操 - Flatten2022-09-06 21:01:02

    题目 中文 在这个挑战中,你需要写一个接受数组的类型,并且返回扁平化的数组类型。 例如: type flatten = Flatten<[1, 2, [3, 4], [[[5]]]]> // [1, 2, 3, 4, 5] English In this challenge, you would need to write a type that takes an array and emitted the flatten array ty

  • Typescript类型体操 - Permutation2022-09-06 00:34:53

    题目 中文 实现联合类型的全排列,将联合类型转换成所有可能的全排列数组的联合类型。 type perm = Permutation<'A' | 'B' | 'C'>; // ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', '

  • Typescript类型体操 - ReplaceAll2022-09-05 20:31:51

    答案 中文 实现 ReplaceAll<S, From, To> 将一个字符串 S 中的所有子字符串 From 替换为 To。 例如 type replaced = ReplaceAll<'t y p e s', ' ', ''> // 期望是 'types' English Implement ReplaceAll<S, From, To> which replace the all t

  • 2022 年要改掉的 10 个 TypeScript 坏习惯2022-09-05 08:31:12

    2022 年要改掉的 10 个 TypeScript 坏习惯 TypeScript 和 JavaScript 在过去几年中不断进步,我们在过去几十年中建立的一些实践已经过时。有些可能永远没有意义。下面列出了我们都应该改掉的 10 个习惯。 1.不要使用严格模式 它看起来像什么 通过使用没有严格模式的 tsconfig.json

  • 使用 Node.js 构建基于 Typescript 的命令行界面 (CLI)2022-09-05 03:03:28

    使用 Node.js 构建基于 Typescript 的命令行界面 (CLI) 我们的目标是使用 Typescript 创建一个基于 Node.js 的命令行界面 (CLI)。此设置包括顶级等待支持和 ES 模块导入。 我们要建造什么 对于本教程,我们将创建一个名为 在太空 .执行时,CLI 将输出空间中的当前人员。 入门 我们将

  • Typescript类型体操 - Trim Left2022-09-04 23:33:13

    题目 中文 实现 TrimLeft<T> ,它接收确定的字符串类型并返回一个新的字符串,其中新返回的字符串删除了原字符串开头的空白字符串。 例如 type trimed = TrimLeft<' Hello World '> // 应推导出 'Hello World ' English Implement TrimLeft<T> which takes an exact string type

  • [Typescript] 13. Easy - Unshift2022-09-04 00:04:01

    Implement the type version of Array.unshift For example: type Result = Unshift<[1, 2], 0> // [0, 1, 2,]   /* _____________ Your Code Here _____________ */ type Unshift<T extends unknown[], U> = [ U, ...T ] /* _____________ Test Cases __

  • [Typescript] 14. Easy - Parameters2022-09-04 00:03:00

    Implement the built-in Parameters generic without using it. For example: const foo = (arg1: string, arg2: number): void => {} type FunctionParamsType = MyParameters<typeof foo> // [arg1: string, arg2: number]   /* _____________ Your Code Here __

  • 模式匹配-让你 ts 类型体操水平暴增的套路2022-09-03 13:01:00

    Typescript 支持泛型,也叫类型参数,可以对类型参数做一系列运算之后返回新的类型,这就是类型编程。 因为类型编程实现一些逻辑还是有难度的,所以被戏称为类型体操。 社区有用 Typescript 类型实现 Lisp 解释器、实现象棋等案例的(知乎可以搜到),这足够说明了 Typescript 类型可以实现各

  • Typescript类型体操 - Deep Readonly2022-09-03 00:00:39

    题目 中文 实现一个通用的DeepReadonly<T>,它将对象的每个参数及其子对象递归地设为只读。 您可以假设在此挑战中我们仅处理对象。数组,函数,类等都无需考虑。但是,您仍然可以通过覆盖尽可能多的不同案例来挑战自己。 例如 type X = { x: { a: 1 b: 'hi' } y: 'hey' }

  • Typescript类型体操 - Tuple To Object2022-09-02 23:33:44

    题目 中文 传入一个元组类型,将这个元组类型转换为对象类型,这个对象类型的键/值都是从元组中遍历出来。 例如: const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const type result = TupleToObject<typeof tuple> // expected { tesla: 'tesla', 

  • Typescript类型体操 - First of Array2022-09-02 23:30:22

    题目 中文 实现一个通用First<T>,它接受一个数组T并返回它的第一个元素的类型。 例如: type arr1 = ['a', 'b', 'c'] type arr2 = [3, 2, 1] type head1 = First<arr1> // expected to be 'a' type head2 = First<arr2> // expected to be 3 英文 Im

  • [Typescript Challenges] 10. Medium - Include2022-09-02 20:31:09

    Implement the JavaScript Array.includes function in the type system. A type takes the two arguments. The output should be a boolean true or false. For example: type isPillarMen = Includes<['Kars', 'Esidisi', 'Wamuu', 

  • [Typescript Challenges] 4. Easy - First of Array2022-09-02 02:03:11

    Implement a generic First<T> that takes an Array T and returns it's first element's type. type arr1 = ['a', 'b', 'c'] type arr2 = [3, 2, 1] type head1 = First<arr1> // expected to be 'a' type

  • [Typescript Challenges] 5. Easy - Length of Tuple2022-09-02 02:02:04

    For given a tuple, you need create a generic Length, pick the length of the tuple For example: type tesla = ['tesla', 'model 3', 'model X', 'model Y'] type spaceX = ['FALCON 9', 'FALCON HEAVY', &

  • [Typescript Challenges] 6 Easy - Exclude2022-09-02 02:01:43

    Implement the built-in Exclude<T, U> For example: type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c'   /* _____________ Your Code Here _____________ */ type MyExclude<T,

  • [Typescript Challenges] 7. Easy - Awaited2022-09-02 02:00:36

    If we have a type which is wrapped type like Promise. How we can get a type which is inside the wrapped type? For example: if we have Promise<ExampleType> how to get ExampleType? type ExampleType = Promise<string> type Result = MyAwaited<E

  • 2022 年 8 月 JavaScript 新闻和更新2022-09-02 01:01:09

    2022 年 8 月 JavaScript 新闻和更新 向所有 JavaScript 崇拜者致敬!很遗憾夏天结束了,但我们准备了一份最新的 JavaScript 新闻摘要来让你振作起来。今天,您将熟悉我们全新的 JavaScript 事件日历,专为在网页上快速实施计划功能而设计。在这里,我们还重点介绍了 TypeScript、Astro 和

  • Typescript类型体操 - Readonly 22022-09-01 21:30:54

    题目 中文 实现一个通用MyReadonly2<T, K>,它带有两种类型的参数T和K。 K指定应设置为Readonly的T的属性集。如果未提供K,则应使所有属性都变为只读,就像普通的Readonly<T>一样。 例如 interface Todo { title: string description: string completed: boolean } const todo:

  • 如何在 TypeScript 代码中使用 JavaScript React 组件2022-09-01 11:05:02

    如何在 TypeScript 代码中使用 JavaScript React 组件 TypeScript 日益流行。因此,如果您还没有开始使用它,那么现在是开始使用它的最佳时机。很有可能,我们的项目已经开发了很长时间。如果是这种情况,最好的方法可能是逐渐将 TypeScript 用于代码库。我们可能会遇到想在 TypeScript

  • 5 个加速 React 开发的工具2022-09-01 08:30:29

    5 个加速 React 开发的工具 React 工具、技巧和最佳实践将帮助您更快地构建应用程序 Original 照片by 凯利@ Pexels React 没有为样式、数据获取、路由或动画规定惯用的解决方案。您管理状态和组件之间的关系以执行您需要执行的操作,使用您需要执行的任何其他工具,并将结果呈现给

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有