RobinBobin / react-native-google-drive-api-wrapper

This wrapper facilitates the use of the Google Drive API in React Native projects.
110 stars 43 forks source link

TypeScript Compile errors #91

Open tfsjohan opened 1 year ago

tfsjohan commented 1 year ago

This package causes several TSC errors.

node_modules/@robinbobin/react-native-google-drive-api-wrapper/ListQueryBuilder.ts(1,29): error TS7016: Could not find a declaration file for module 'simple-common-utils'. '/home/runner/work/cloudqr-app/cloudqr-app/node_modules/simple-common-utils/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/simple-common-utils if it exists or add a new declaration (.d.ts) file containing declare module 'simple-common-utils'; node_modules/@robinbobin/react-native-google-drive-api-wrapper/api/aux/Uris.ts(1,34): error TS7016: Could not find a declaration file for module 'simple-common-utils'. '/home/runner/work/cloudqr-app/cloudqr-app/node_modules/simple-common-utils/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/simple-common-utils if it exists or add a new declaration (.d.ts) file containing declare module 'simple-common-utils'; node_modules/@robinbobin/react-native-google-drive-api-wrapper/api/aux/uploaders/MultipartUploader.ts(4,8): error TS7016: Could not find a declaration file for module 'simple-common-utils'. '/home/runner/work/cloudqr-app/cloudqr-app/node_modules/simple-common-utils/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/simple-common-utils if it exists or add a new declaration (.d.ts) file containing declare module 'simple-common-utils'; node_modules/@robinbobin/react-native-google-drive-api-wrapper/api/aux/uploaders/MultipartUploader.ts(5,18): error TS7016: Could not find a declaration file for module 'utf8'. '/home/runner/work/cloudqr-app/cloudqr-app/node_modules/utf8/utf8.js' implicitly has an 'any' type. Try npm i --save-dev @types/utf8 if it exists or add a new declaration (.d.ts) file containing declare module 'utf8'; node_modules/@robinbobin/react-native-google-drive-api-wrapper/api/aux/utils.ts(5,8): error TS7016: Could not find a declaration file for module 'simple-common-utils'. '/home/runner/work/cloudqr-app/cloudqr-app/node_modules/simple-common-utils/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/simple-common-utils if it exists or add a new declaration (.d.ts) file containing declare module 'simple-common-utils'; node_modules/@robinbobin/react-native-google-drive-api-wrapper/api/permissions/Permissions.ts(11,40): error TS2322: Type 'object | undefined' is not assignable to type 'object'. Type 'undefined' is not assignable to type 'object'. node_modules/@robinbobin/react-native-google-drive-api-wrapper/api/permissions/Permissions.ts(17,54): error TS2322: Type 'object | undefined' is not assignable to type 'object'. Type 'undefined' is not assignable to type 'object'.

RobinBobin commented 1 year ago

Thanks for pointing out.

adamblvck commented 1 year ago

I'm not sure if this belongs to this issue, but perhaps it's worth mentioning as it's related to TS errors.

While trying to make run one of my react-native apps in web using expo, react-native-web, and webpack, I'm getting the following errors:

ERROR in ./node_modules/@robinbobin/react-native-google-drive-api-wrapper/GDrive.ts 7:10
Module parse failed: Unexpected token (7:10)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| 
| export default class GDrive {
>   private readonly __apis = new Map <string, GDriveApi> ();
|   
|   constructor() {

ERROR in ./node_modules/@robinbobin/react-native-google-drive-api-wrapper/HttpError.ts 2:10
Module parse failed: Unexpected token (2:10)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| export default class HttpError extends Error {
>   private __json?: any;
|   private __response: Response;
|   private __text?: string;

ERROR in ./node_modules/@robinbobin/react-native-google-drive-api-wrapper/ListQueryBuilder.ts 3:5
Module parse failed: Unexpected token (3:5)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| import { StaticUtils } from "simple-common-utils";
| 
> type Key = string;
| type Value = boolean | number | string;
| type KeyOrValue = Key | Value;

ERROR in ./node_modules/@robinbobin/react-native-google-drive-api-wrapper/MimeTypes.ts 1:0
Module parse failed: The keyword 'enum' is reserved (1:0)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
> enum MimeTypes {
|   BINARY     = 'application/octet-stream',
|   CSV        = 'text/csv',

ERROR in ./node_modules/@robinbobin/react-native-google-drive-api-wrapper/UnexpectedFileCountError.ts 1:5
Module parse failed: Unexpected token (1:5)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
> type ExpectedCount = number[] | number;
| 
| export default class UnexpectedFileCountError extends Error {

Now it may seem that this is related to how I'm loading the files. However when using ts-loader instead, I'm getting a bunch more TS errors on this very library, very similar to OP.

My first idea is that the ts-files aren't transpiled to js, and thus webpack isn't scooping up the library correctly with source-map-loader.

Either way, currently being prohibited from using this wonderful wrapper outside an iOS and Android context, which works otherwise very well, and which I'm very grateful for it.

RobinBobin commented 1 year ago

Hi @adamblvck , Sorry, but I designed this lib for android / ios only. I hardly imagine it will work with expo, moreover with webpack. It happened to become a rather abandoned project, with another version stuck halfway, as I can't find enough time for it :disappointed: .

adamblvck commented 1 year ago

@RobinBobin Expo (using EAS workflow) actually works quite well with your lib! Sad to hear this, but I'll see how I'll manage this going forward.

RobinBobin commented 1 year ago

Good luck 👍 !

namnh-0652 commented 9 months ago

@adamblvck did you bypass it? how to ignore these code from type-check?

namnh-0652 commented 9 months ago

@RobinBobin https://github.com/RobinBobin/react-native-google-drive-api-wrapper/pull/96/files Did this PR fix the type-check, Please release new version when you have time, thank you.

namnh-0652 commented 9 months ago

Still error type-check from 1.2.4

Serchinastico commented 5 months ago

I found myself having this error with an Expo project and to solve it I just created a new react-native-google-drive-api-wrapper.d.ts file in my project with the following contents:

declare module "simple-common-utils";
declare module "utf8";

PD: Thanks for the library @RobinBobin, it has been a lifesaver 🙌