Browse Source

chore: upgrade ts generator for better type safety (#20975)

* chore: upgrade ts generator for better type safety

* spec: fix tests
Samuel Attard 5 years ago
parent
commit
fcee7212ce

+ 1 - 3
docs/api/protocol.md

@@ -389,9 +389,7 @@ which sends a `Buffer` as a response.
       * `url` String
       * `method` String (optional)
       * `session` Session | null (optional)
-      * `uploadData` Object (optional)
-        * `contentType` String - MIME type of the content.
-        * `data` String - Content to be sent.
+      * `uploadData` [ProtocolResponseUploadData](structures/protocol-response-upload-data.md) (optional)
 * `completion` Function (optional)
   * `error` Error
 

+ 1 - 1
docs/api/structures/protocol-response-upload-data.md

@@ -1,4 +1,4 @@
 # ProtocolResponseUploadData Object
 
 * `contentType` String - MIME type of the content.
-* `data` String - Content to be sent.
+* `data` String | Buffer - Content to be sent.

+ 2 - 2
package.json

@@ -5,7 +5,7 @@
   "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
   "devDependencies": {
     "@electron/docs-parser": "^0.4.2",
-    "@electron/typescript-definitions": "^8.6.1",
+    "@electron/typescript-definitions": "^8.6.4",
     "@octokit/rest": "^16.3.2",
     "@primer/octicons": "^9.1.1",
     "@types/basic-auth": "^1.1.2",
@@ -138,4 +138,4 @@
     "@types/multiparty": "^0.0.32",
     "@types/temp": "^0.8.34"
   }
-}
+}

+ 2 - 2
spec-main/api-protocol-spec.ts

@@ -529,12 +529,12 @@ describe('protocol module', () => {
       const port = (server.address() as AddressInfo).port
       const url = `http://127.0.0.1:${port}`
       await interceptHttpProtocol('http', (request, callback) => {
-        const data = {
+        const data: Electron.RedirectRequest = {
           url: url,
           method: 'POST',
           uploadData: {
             contentType: 'application/x-www-form-urlencoded',
-            bytes: request.uploadData[0].bytes
+            data: request.uploadData[0].bytes
           },
           session: null
         }

+ 4 - 4
yarn.lock

@@ -40,10 +40,10 @@
     ora "^3.4.0"
     pretty-ms "^5.0.0"
 
-"@electron/typescript-definitions@^8.6.1":
-  version "8.6.3"
-  resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.6.3.tgz#6868d71bd56b6219150123969d1a6634629ef566"
-  integrity sha512-/PLUskJu2+W8BKkQQBQq2C0WFUyAeBaGEutt2sJkzzhkTWoVcKG4M36Me45+D0CiRqgAxTO9qR68O96+8vtIfg==
+"@electron/typescript-definitions@^8.6.4":
+  version "8.6.4"
+  resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.6.4.tgz#d4727c825afcebf6ff00a7d18416878288cac632"
+  integrity sha512-Fb4o56fikSE3id61U0MbPVBPcweVw8YwzO+JtT9aOorJR4baJZGmpsGxuaHeLSGv+D0Zd5XiWk13cEM/nv9fFw==
   dependencies:
     "@electron/docs-parser" "^0.4.1"
     "@types/node" "^11.13.7"