並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 18 件 / 18件

新着順 人気順

literalの検索結果1 - 18 件 / 18件

タグ検索の該当結果が少ないため、タイトル検索結果を表示しています。

literalに関するエントリは18件あります。 TypeScripttypescriptprogramming などが関連タグです。 人気エントリには 『TypeScript 4.1 の Template Literal Types がやばい - Qiita』などがあります。
  • TypeScript 4.1 の Template Literal Types がやばい - Qiita

    TS 4.1 の Template Literal Types を使うと、文字列を解釈して型定義ができる。文字列は変数化でき、テンプレートリテラルで埋め込める。 type Hello = 'Hello' type World = 'World' // Template Literal を埋め込める type HelloWorld = `${Hello}, ${World}` // => type 'Hello, World' // 引数に取ることもできる type Concat<T extends string, S extends string> = `${T}, ${S}` type HelloWorld = Concat<'Hello', 'World'> // => type 'Hello, World'

      TypeScript 4.1 の Template Literal Types がやばい - Qiita
    • Template literal types and mapped type 'as' clauses by ahejlsberg · Pull Request #40336 · microsoft/TypeScript

      This PR implements two new features: Template literal types, which are a form of string literals with embedded generic placeholders that can be substituted with actual string literals through type instantiation, and Mapped type as clauses, which provide the ability to transform property names in mapped types. Template literal types Template literal types are the type space equivalent of template l

        Template literal types and mapped type 'as' clauses by ahejlsberg · Pull Request #40336 · microsoft/TypeScript
      • python3.8 から新しく導入された Literal types について - MNTSQ Techブログ

        はじめに pythonの関数に与える引数として特定の値のみを許容したいときはないでしょうか? そのようなときに、動的に引数の値をチェックして範囲外のものを除外するアサーションや、Enumを用いてとりうる値を絞ることが考えられます。 ですが、前者は動的な値検査しか行えず、後者についてはAPIの引数の型をEnumに変更する必要があり、Enumが既存のAPIをオーバーロードしたときの引数の型として使えるとは限らないです。1 このような引数の値のチェックに使える手段として、python3.8から使えるようになっているLiteral typesがあります。 Literal types は型として宣言することで、関数の引数等に対して特定の型を要求するのと同時に、特定の値を持つことも要求できます。 例 次のようなコードの例を考えてみます。 target_fruit = ['apple', 'banana

          python3.8 から新しく導入された Literal types について - MNTSQ Techブログ
        • Mastering TypeScript Template Literal Types

          Capture By AuthorTypescript has had Template Literals since its early stages. They are really useful when you want to create types from a static string. It was not until the Typescript 4.1 release that we saw Template Literal Types. In further releases, the Typescript team has been polishing its features and fixing some quirks. As a result, it is now a mature feature. What are Template Literal Typ

            Mastering TypeScript Template Literal Types
          • Template Literal Types で「単位を持つ数値」の文字列型をきれいに扱いたい

            追記: hasSuffix の実装が間違ってたので修正 ブラウザの二次元上の座標を計算するコードを書いていると、 px, rem, flex などの数値が入り乱れて、それらを文字列で管理してると扱いが難しくなります。また、ブラウザの DOM API は、コンテキスト次第で string | number みたいなノリで "250px" や 250 みたいな数値を雑に返してきます。 世の中には typescript 4.1 から使える template literal types で JSON パーサやパーサコンビネータを書く人がいるみたいですが、今回はそういう黒魔術にはできるだけ手を染めず、文字列表現に制約を掛けて、それらの計算を楽にできないかを試していました。 まずは template literal types の簡単なアイデアから。 type PixelValue = `${numb

              Template Literal Types で「単位を持つ数値」の文字列型をきれいに扱いたい
            • Christo Grozev on Twitter: ""The Russian army is the last bastion against the satanic new world order". Literal quote from the official Russian… https://t.co/Mcd7VYKLcz"

              "The Russian army is the last bastion against the satanic new world order". Literal quote from the official Russian… https://t.co/Mcd7VYKLcz

                Christo Grozev on Twitter: ""The Russian army is the last bastion against the satanic new world order". Literal quote from the official Russian… https://t.co/Mcd7VYKLcz"
              • Scala 3のmatch typeでcompile timeにString literalをparseして評価する - xuwei-k's blog

                Scala 3のmatch typeで何かのparserでも書くか?と思ったけど、コンパイル時にリテラルのStringを、型情報というか分解した場合の値情報?を、保ったままの分解が単純には出来そうにはないというか… あるいは一旦CharのHListにしたいんだけど、何か方法あるのかな— Kenji Yoshida (@xuwei_k) February 28, 2021 https://t.co/sNupBRy3rV type Substringが増えてるからいける…?— Kenji Yoshida (@xuwei_k) 2022年2月28日 できました。 parserなどに慣れてないので、とりあえず以下のクソ雑仕様?だけど、tokenにするのとparseとevalをなんとなくちゃんと分けたぞ! みんなScala 3のmatch typeで、任意の言語などのparserや評価機を書こう!!

                  Scala 3のmatch typeでcompile timeにString literalをparseして評価する - xuwei-k's blog
                • TypeScript >= 4.1 の Template Literal Types を活用した引数パーサーを作ってみた - ジンジャー研究室

                  ヘルプっぽいものを書くと文字列をパースして型をつけてくれる。 デフォルト値を指定すると T | null が T になったりする。 公開は今のところ GitHub Packages だけです(メンテしなくていい方法を考え中) github.com 型レベルのパーサーはこちらの記事を大いに参考にしたというかパクりました。 (ネタ) TypeScript 型パズルで作るmini interpreter | by Yosuke Kurami | Medium こんなに本格的じゃないけど。 難しいなと思ったのは、せっかく型レベルでパースしてもその結果を値レベルの実装に利用できない点。 なので、型は型、値は値でそれぞれパースして最終的に辻褄が合うように実装しました。 それでは皆さま良いお年を。

                    TypeScript >= 4.1 の Template Literal Types を活用した引数パーサーを作ってみた - ジンジャー研究室
                  • 【Ruby】# frozen_string_literal: trueマジックコメントは必要?【RuboCop】 - Qiita

                    【Ruby】# frozen_string_literal: trueマジックコメントは必要?【RuboCop】RubyRuboCop 最初に RuboCopの全てのCopをオンにすると、 Style::FrozenStringLiteralCommentという項目があります。 デフォルトだと基本的に全てのRubyファイルの冒頭に # frozen_string_literal: trueを書くよう注意されます。 p 1 + 1と何か書くだけでも、マジックコメントを書くよう要求されます。 厳しいと感じる項目は他にもあるのですが、 全てのファイルに要求されるのでとりわけ異質に厳しく感じています。 このマジックコメントって何をしているのでしょうか。 本当に必要なんでしょうか。 オフにしても良さそうな設定でしょうか。 自分の結論ではこのマジックコメントを使いたくなく、 そういう結論になった背景に

                      【Ruby】# frozen_string_literal: trueマジックコメントは必要?【RuboCop】 - Qiita
                    • GitHub - ghoullier/awesome-template-literal-types: Curated list of awesome Template Literal Types examples

                      You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                        GitHub - ghoullier/awesome-template-literal-types: Curated list of awesome Template Literal Types examples
                      • Feature #16986: Anonymous Struct literal - Ruby master - Ruby Issue Tracking System

                        Abstract¶ How about introducing anonymous Struct literal such as ${a: 1, b: 2}? It is almost the same as Struct.new(:a, :b).new(1, 2). Proposal¶ Background¶ In many cases, people use hash objects to represent a set of values such as person = {name: "ko1", country: 'Japan'} and access its values through person[:name] and so on. It is not easy to write (three characters [:]!), and it easily introduc

                        • Documentation - Template Literal Types

                          Template literal types build on string literal types, and have the ability to expand into many strings via unions. They have the same syntax as template literal strings in JavaScript, but are used in type positions. When used with concrete literal types, a template literal produces a new string literal type by concatenating the contents.

                          • GSoC chromium: IP address synthesis for an IPv6 only network to connect to an IPv4 address literal. - momokaのブログ

                            TLDR; When a client is in an IPv6 only environment it utilises the NAT64 and DNS64 in the network to connect to IPv4 only servers. However, when chrome tries to connect to an IPv4 literal (such as when an IPv4 address is directly written in the search bar) it doesn't use the DNS64 and fails to connect to the address. With this change Chrome will now append the IPv4 to IPv6 translation prefix (Pref

                              GSoC chromium: IP address synthesis for an IPv6 only network to connect to an IPv4 address literal. - momokaのブログ
                            • Benchmarking String Literal ("") vs Template Literal (``) - using Performance.now()

                              Benchmarking String Literal ("") vs Template Literal (``) - using Performance.now()

                                Benchmarking String Literal ("") vs Template Literal (``) - using Performance.now()
                              • GitHub - Janpot/escape-html-template-tag: Tag literal strings with this function to html escape interpolated values

                                You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                  GitHub - Janpot/escape-html-template-tag: Tag literal strings with this function to html escape interpolated values
                                • Recoilの階層的なkey管理とMapped Types、Conditional Types、Template Literal Types

                                  Recoilの階層的なkey管理とMapped Types、Conditional Types、Template Literal Types Recoil React用の状態管理ライブラリとして、RecoilというMeta(旧Facebook)が開発中の比較的新しいライブラリがあります。 記事執筆時点での最新バージョンはまだv0.6.1で"experimental"という位置づけですが、GitHubのスター数は約16,000あり、巷でも最近よく名前を聞くようになってきたと個人的には感じます。 Recoilでは状態の起点をatomとして定義します。さらにatomの値をもとに純粋な関数によって計算可能な値をselectorとして定義することもできます。同様に他のselectorの値をもとにして計算可能な値もまたselectorとして定義できます。 Recoilの基本的なAPIの使い方等は公式ド

                                    Recoilの階層的なkey管理とMapped Types、Conditional Types、Template Literal Types
                                  • Literal

                                    Discover, organise & discuss books Track what you're reading, follow friends and join clubs to collectively explore the ideas of the world's greatest authors.

                                      Literal
                                    • I need to learn about TypeScript Template Literal Types

                                      It's Sunday in New Zealand and I don't want to get out of bed yet, so instead I'm going to listen to the new Menzingers album and learn about TypeScript Template Literal Types and write down what I found out as I go! TypeScript string types: Let's start with what I already know. TypeScript has a string type. It covers all strings like const hello = "Hello World";, or const myName = `My name is ${n

                                        I need to learn about TypeScript Template Literal Types
                                      1

                                      新着記事