React Native Sound のtypescript Error を修正する

Purpose (目的) React Nativeで音を出したい。しかし、サンプルの通りやると、typescript のErrorが出るので直したい。 Environment (動作環境) React Native (version 0.68.2)expo (version 45.0.8)Typescript (version 4.3.5) npm install インストールします。(npmでは ...
The right-hand side of an ‘in’ expression must not be a primitive.ts(2361)のエラー

動作環境 typescript nodejsreact native 発生状況 async await を使ってAsyncStorageで保管したデータをgetして、そのgetしたデータに対して、in塩山市を使って、if文の処理をしたらタイトルのエラーが出た。getしたデータはjson型である。 エラーの原因 AsyncStorageで取得したデータの方がjsonだと思っていたが、jsonになって ...
@react-native-async-storage/async-storage を使うsample

Target (目標) @react-native-async-storage/async-storage. ← use :)@react-native-community/async-storage ← can't use anymore (I get an error) Environment (動作環境) Expo (version 45.0.8)React Native (version ...
[react native] I want to center it with the ScrollView, and I want the width to be 100%

Problem (問題点) When using ScrollView, the width is not 100%, so I tried various things. (ScrollViewを使うと、幅が100%にならなくなったりしたので、いろいろ試しました。) Operating environment (動作環境) React Native (version 0.68.2)Typescr ...
[solved] navigation.navigate Argument of type ‘string’ is not assignable to parameter of type ‘never’.ts(2769) [React Native]

Content of the error (エラーの内容) No overload matches this call. Overload 1 of 2, '(...args: never): void', gave the following error. Argument of type 'string' is not assignable to paramet ...
A class member cannot have the ‘const’ keyword.ts(1248)

Error situation When I used const in class in typescript, I got the error A class member cannot have the 'const' keyword.ts(1248). (typescript で classの中でconstを利用したら、A class member cannot have the 'con ...
[Error Message] ‘XXXXXXX’ is defined but never used.eslint@typescript-eslint/no-unused-vars

What is Eslintrc.js file? (eslintrc.js ファイルとは) eslintrc.js file is a file that describes eslint settings. (eslintrc.js fileとは、eslintの設定を記載するファイルです。) Commentary (解説) @typescript-eslint/no-unused-vars I ...
react-test-rendererをnpm でinstallしようとしてエラー

react-test-rendererをインストールしようとしてエラーになりました。以下のようなエラー表示です。 $ npm i --save-dev react-test-renderer@18 npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While re ...
Property ‘answer’ does not exist on type ‘Promise‘

typescriptで、以下のような場合の解決方法です。はしょりすぎかも。 before //aaaa()の戻り値はpromise<any> const cccc = aaaa() // 以下のelementのところで、タイトルのエラーが出る if(cccc.element){ } こんな時は、aaaa()の前にawaitをつけると解決します。 after //aaaa()の戻り値はp ...
Object is possibly ‘undefined’

原因 undefined(未定義)の場合があるので、その処理はできない場合があるのでtypescriptではエラーとなる。という意味です。 具体例 例えば、文字列の結合をする処理は、文字列の変数に対してはできるが、未定義の変数に対してはできない。つまりエラーになると言っています。例えば、以下のようなコードです。 type card = { id: string, tag?: string, tit ...
Property ‘xxxxxx’ does not exist on type ‘T | undefined’. のエラーの消し方

動作環境 typescript@4.7.4VSCode react@18.2.0next@12.2.2 エラーの状況 このサイトのコードをコピペして実行しようと思ったら、タイトルのエラーが出ました。エラーの出た箇所は以下のコードの14行目の{ posts }のところです。 import Link from 'next/link'; import { useQuery } from '@apollo ...