1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

a.__spreadArray is not a function, is what ?

Posted at

😨 問題発見

行けるやろ、と TypeScript を 3.9 -> 4.2 に上げました。トランスパイルするだけだし、バグるわけねーよね。とか期待して。そして...

キャプチャ.PNG

というエラー出ちゃったわけですよ。なんすかね、.__spreadArray って。

😋 解決方法

.__spreadArray をググると、以下のようなツイートが見つかる。合法的に業務中に twitter に入って内容を見てみる。tslib 、なるほどね。package.json にないわw

というわけで、お決まりのあのコマンド実行します

$ yarn add -D tslib

tsconfig も、tslib を読み込めるように変更が必要っぽいです。

tsconfig.json
{
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig.json to read more about this file */
    // ...

    "importHelpers": true,                 /* Import emit helpers from 'tslib'. */
    "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */

    // ...
  }
}

という感じで解決しました。そして __spreadArray なのですが、これは tslib に含められている関数みたいです。(https://www.typescriptlang.org/tsconfig#importHelpers)

配列の分割代入を関数として定義している模様、なのでその関数を注入しないとだめみたいです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?