<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>Hal40n</author_name>
  <author_url>https://blog.hatena.ne.jp/Hal40n/</author_url>
  <blog_title>Halcyon Days</blog_title>
  <blog_url>https://hal40n.com/</blog_url>
  <categories>
    <anon>TypeScript</anon>
  </categories>
  <description>作成したメソッドのテストコードを書いていた時に、リテラル型のうまく渡せずハマってしまった。 無事に解消したので、その時にやったことをメモ書きしておく。 どのようなエラーが発生していたか？ 型定義に下記のようなリテラル型が定義してあった。 xPosition: 1 | 2; そのため、テストコードでもこれに合うように「1」を引き渡した。 仮の関数を func とすると下記のようになる。 func({ // 他の引数 xPosition: 1, } そして npm test コマンドでテストを実行すると Types of property 'xPosition' are incompatible.…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fhal40n.com%2Fentry%2F2024%2F10%2F19%2F170000&quot; title=&quot;リテラル型をうまく引数で渡せなくてはまったときに書いたメモ - Halcyon Days&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2024-10-19 17:00:00</published>
  <title>リテラル型をうまく引数で渡せなくてはまったときに書いたメモ</title>
  <type>rich</type>
  <url>https://hal40n.com/entry/2024/10/19/170000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
