Ver Fonte

Add tsc support

painor há 4 anos atrás
pai
commit
44d24535f7
6 ficheiros alterados com 1449 adições e 1399 exclusões
  1. 3 0
      gramjs/client/auth.ts
  2. 3 0
      gramjs/client/downloadFile.ts
  3. 2 0
      gramjs/client/uploadFile.ts
  4. 1432 1396
      package-lock.json
  5. 3 0
      package.json
  6. 6 3
      tsconfig.json

+ 3 - 0
gramjs/client/auth.ts

@@ -1,7 +1,10 @@
 import  { default as Api }  from '../tl/api';
 import TelegramClient from './TelegramClient';
+// @ts-ignore
 import * as utils from '../Utils';
+// @ts-ignore
 import { sleep } from '../Helpers';
+// @ts-ignore
 import { computeCheck as computePasswordSrpCheck } from '../Password';
 
 export interface UserAuthParams {

+ 3 - 0
gramjs/client/downloadFile.ts

@@ -1,6 +1,8 @@
 import { default as Api } from '../tl/api';
 import TelegramClient from './TelegramClient';
+// @ts-ignore
 import { getAppropriatedPartSize } from '../Utils';
+// @ts-ignore
 import { sleep } from '../Helpers';
 
 export interface progressCallback {
@@ -48,6 +50,7 @@ export async function downloadFile(
         partSizeKb = fileSize ? getAppropriatedPartSize(fileSize) : DEFAULT_CHUNK_SIZE;
     }
 
+    // @ts-ignore
     const partSize = partSizeKb * 1024;
     const partsCount = end ? Math.ceil((end - start) / partSize) : 1;
 

+ 2 - 0
gramjs/client/uploadFile.ts

@@ -1,7 +1,9 @@
 import { default as Api } from '../tl/api';
 
 import TelegramClient from './TelegramClient';
+// @ts-ignore
 import { generateRandomBytes, readBigIntFromBuffer, sleep } from '../Helpers';
+// @ts-ignore
 import { getAppropriatedPartSize } from '../Utils';
 
 interface OnProgress {

Diff do ficheiro suprimidas por serem muito extensas
+ 1432 - 1396
package-lock.json


+ 3 - 0
package.json

@@ -5,6 +5,8 @@
   "main": "index.js",
   "scripts": {
     "test": "jest",
+    "postinstall": "npm run tsc",
+    "tsc": "tsc",
     "lint": "eslint .",
     "generate": "node ./gramjs/tl/types-generator/generate.js"
   },
@@ -57,6 +59,7 @@
     "async-mutex": "^0.1.4",
     "big-integer": "painor/BigInteger.js",
     "browser-or-node": "^1.3.0",
+    "jest": "^26.6.3",
     "pako": "^1.0.10",
     "websocket": "^1.0.30"
   }

+ 6 - 3
tsconfig.json

@@ -1,19 +1,22 @@
 {
     "compilerOptions": {
         // We don't care about this since Parcel runs Babel after TypeScript
-        "target": "esnext",
+        "module": "commonjs",
+        "target": "es5",
         "lib": [
             "dom",
+            "es2015",
+            "es5",
+            "es6",
             "es7"
         ],
 
-        "allowJs": true,
+        "allowJs": false,
         "skipLibCheck": true,
         "esModuleInterop": true,
         "allowSyntheticDefaultImports": true,
         "strict": true,
         "forceConsistentCasingInFileNames": true,
-        "module": "esnext",
         "moduleResolution": "node",
         "resolveJsonModule": true,
         "isolatedModules": true,

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff