You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/06/23 16:24:22 UTC

[GitHub] [cordova-plugin-file] kputh opened a new issue #400: Add documentation on how to use this plugin with TypeScript

kputh opened a new issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400


   # Feature Request
   
   ## Motivation Behind Feature
   <!-- Why should this feature be implemented? What problem does it solve? -->
   I'm migrating an exiting project to Cordova, and this plugin has been challenging. The project uses TypeScript and figuring out how to use the types in the package properly has been a hassle.
   
   (I don't use 'global' libraries very often. My current solution is simply `import 'cordova-plugin-file';` It does fail at constants like `cordova.file.dataDirectory`.)
   
   
   
   ## Feature Description
   <!-- 
   Describe your feature request in detail
   Please provide any code examples or screenshots of what this feature would look like
   Are there any drawbacks? Will this break anything for existing users? 
   -->
   A paragraph in the documentation about using this plugin with TypeScript and a complete TypeScript module (file) using it as an example would be nice.
   
   
   
   ## Alternatives or Workarounds
   <!-- 
   Describe alternatives or workarounds you are currently using 
   Are there ways to do this with existing functionality?
   -->
   none
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] timbru31 edited a comment on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
timbru31 edited a comment on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648819057


   This one works fine for us:
   
   ```json
   {
   	"extends": "./tsconfig.json",
   	"compilerOptions": {
   		"outDir": "./out-tsc/app",
   		"preserveConstEnums": true,
   		"types": ["node", "cordova", "cordova-plugin-file", "cordova-plugin-lottie-splashscreen"]
   	},
   	"files": ["src/main.ts", "src/polyfills.ts"],
   	"include": ["src/**/*.d.ts"]
   }
   ```
   
   Base `tsconfig.json` is:
   ```json
   {
   	"compileOnSave": false,
   	"compilerOptions": {
   		"baseUrl": "./",
   		"outDir": "./dist/out-tsc",
   		"sourceMap": true,
   		"declaration": false,
   		"module": "esnext",
   		"moduleResolution": "node",
   		"emitDecoratorMetadata": true,
   		"experimentalDecorators": true,
   		"importHelpers": true,
   		"noImplicitAny": true,
   		"strictNullChecks": false,
   		"noUnusedLocals": true,
   		"noUnusedParameters": true,
   		"resolveJsonModule": true,
   		"allowSyntheticDefaultImports": true,
   		"allowUnreachableCode": false,
   		"target": "es2015",
   		"typeRoots": ["node_modules/@types"],
   		"lib": ["es2020", "dom"]
   	},
   	"angularCompilerOptions": {
   		"disableTypeScriptVersionCheck": true,
   		"fullTemplateTypeCheck": true,
   		"strictInjectionParameters": true
   	}
   }
   
   ```
   
   Blind guess: You are missing the `cordova-plugin-file` entry in the `types` array.
   
   Edit: Oh and no need to call `import 'cordova-plugin-file'`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] breautek commented on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648289677


   Related: https://github.com/apache/cordova/issues/39


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] kputh edited a comment on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
kputh edited a comment on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648731239


   Update: I replaced the import with `/// <reference types="cordova-plugin-file" />`. The static code analysis was satisfied with the import, but the compiler complained that the definition file is not a module.
   
   > How did you add the files to your tsconfig?
   
   My _tsconfig.json_ look roughly like this:
   ```
   {
     "files": [ "src/entry-point.ts" ],
     "include": [ "types/**/*.d.ts" ],
     "exclude": [ "src/**/*.spec.ts" ]
   }
   ```
   I implicitly use the default _typeRoots_ configuration.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] breautek commented on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648296112


   Currently a workaround would be to create your own definition file that you can include in the project, which would declare the variables and functions added by the `cordova-plugin-file`, which for the time being, just to satisfy typescript, the declares types could be defined as `any`. An example of extending global (or in this case, the `window`) can be found on the [typescript docs](https://www.staging-typescript.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] kputh commented on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
kputh commented on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648731239


   Update: I replaced the import with `/// <reference types="cordova-plugin-file" />`. The static code analysis was satisfied with the import, but the compiler complained that the definition file is not a module.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] kputh edited a comment on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
kputh edited a comment on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648731239


   Update: I replaced the import with `/// <reference types="cordova-plugin-file" />`. The static code analysis was satisfied with the import, but the compiler complained that the definition file is not a module.
   
   > How did you add the files to your tsconfig?
   
   My _tsconfig.json_ look roughly like this:
   ```
   {
     "files": [ "src/main.ts" ],
     "include": [ "types/**/*.d.ts" ],
     "exclude": [ "src/**/*.spec.ts" ]
   }
   ```
   I implicitly use the default _typeRoots_ configuration.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] timbru31 commented on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
timbru31 commented on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648436517


   How did you add the files to your tsconfig? 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] kputh edited a comment on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
kputh edited a comment on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648731239


   Update: I replaced the import with `/// <reference types="cordova-plugin-file" />`. The static code analysis was satisfied with the import, but the compiler complained that the definition file is not a module.
   
   My _tsconfig.json_ look roughly like this:
   ```
   {
     "files": [ "src/main.ts" ],
     "include": [ "types/**/*.d.ts" ],
     "exclude": [ "src/**/*.spec.ts" ]
   }
   ```
   I implicitly use the default type roots configuration.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] kputh commented on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
kputh commented on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-650972326


   > Blind guess: You are missing the `cordova-plugin-file` entry in the `types` array.
   
   The compiler and static code analysis work with this. But it's definitely something that should be documented.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] breautek commented on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648444965


   > How did you add the files to your tsconfig?
   
   In my projects where i need to write my own type definitions cause a third party doesn't supply them, I don't think I do... instead I believe I use the triple slash directive to reference the d.ts file.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] timbru31 commented on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
timbru31 commented on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648819057


   This one works fine for us:
   
   ```json
   {
   	"extends": "./tsconfig.json",
   	"compilerOptions": {
   		"outDir": "./out-tsc/app",
   		"preserveConstEnums": true,
   		"types": ["node", "cordova", "cordova-plugin-file", "cordova-plugin-lottie-splashscreen"]
   	},
   	"files": ["src/main.ts", "src/polyfills.ts"],
   	"include": ["src/**/*.d.ts"]
   }
   ```
   
   Base `tsconfig.json` is:
   ```json
   {
   	"compileOnSave": false,
   	"compilerOptions": {
   		"baseUrl": "./",
   		"outDir": "./dist/out-tsc",
   		"sourceMap": true,
   		"declaration": false,
   		"module": "esnext",
   		"moduleResolution": "node",
   		"emitDecoratorMetadata": true,
   		"experimentalDecorators": true,
   		"importHelpers": true,
   		"noImplicitAny": true,
   		"strictNullChecks": false,
   		"noUnusedLocals": true,
   		"noUnusedParameters": true,
   		"resolveJsonModule": true,
   		"allowSyntheticDefaultImports": true,
   		"allowUnreachableCode": false,
   		"target": "es2015",
   		"typeRoots": ["node_modules/@types"],
   		"lib": ["es2020", "dom"]
   	},
   	"angularCompilerOptions": {
   		"disableTypeScriptVersionCheck": true,
   		"fullTemplateTypeCheck": true,
   		"strictInjectionParameters": true
   	}
   }
   
   ```
   
   Blind guess: You are missing the `cordova-plugin-file` entry in the `types` array.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] kputh edited a comment on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
kputh edited a comment on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648731239


   Update: I replaced the import with `/// <reference types="cordova-plugin-file" />`. The static code analysis was satisfied with the import, but the compiler complained that the definition file is not a module.
   
   > How did you add the files to your tsconfig?
   
   My _tsconfig.json_ look roughly like this:
   ```
   {
     "files": [ "src/main.ts" ],
     "include": [ "types/**/*.d.ts" ],
     "exclude": [ "src/**/*.spec.ts" ]
   }
   ```
   I implicitly use the default type roots configuration.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] kputh edited a comment on issue #400: Add documentation on how to use this plugin with TypeScript

Posted by GitBox <gi...@apache.org>.
kputh edited a comment on issue #400:
URL: https://github.com/apache/cordova-plugin-file/issues/400#issuecomment-648731239


   Update: I replaced the import with `/// <reference types="cordova-plugin-file" />`. The static code analysis was satisfied with the import, but the compiler complained that the definition file is not a module.
   
   My _tsconfig.json_ look roughly like this:
   ```
   {
     "files": [ "src/main.ts" ],
     "include": [ "types/**/*.d.ts" ],
     "exclude": [ "src/**/*.spec.ts" ]
   }
   ```
   I use the default type roots configuration.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org