Forráskód Böngészése

Use a single typescript config for all types tests.

Renée Kooi 6 éve
szülő
commit
36e5a82393

+ 1 - 1
package.json

@@ -95,7 +95,7 @@
     "test:acceptance": "npm run test:prepare-ci && wdio test/endtoend/wdio.remote.conf.js",
     "test:acceptance:local": "npm run test:build && wdio test/endtoend/wdio.local.conf.js",
     "test:unit": "jest --testPathPattern=./src --coverage",
-    "test:type": "tsc -p packages/uppy/types && tsc -p packages/@uppy/core/types",
+    "test:type": "tsc -p .",
     "test": "npm run lint && npm run test:unit && npm run test:type",
     "test:watch": "jest --watch --testPathPattern=src",
     "travis:deletecache": "travis cache --delete",

+ 11 - 0
packages/@uppy/aws-s3/types/aws-s3-tests.ts

@@ -0,0 +1,11 @@
+import Uppy, { UppyFile } from '@uppy/core';
+import AwsS3 from '../';
+
+{
+  const uppy = Uppy();
+  uppy.use(AwsS3, {
+    getUploadParameters(file) {
+      file // $ExpectType UppyFile
+    }
+  });
+}

+ 3 - 3
packages/@uppy/server-utils/types/index.d.ts

@@ -35,7 +35,7 @@ export class Socket {
   constructor (opts: SocketOptions);
   close (): void;
   send (action: string, payload: any): void;
-  on (action: string, handler: (any) => void);
-  emit (action: string, payload: (any) => void);
-  once (action: string, handler: (any) => void);
+  on (action: string, handler: (param: any) => void): void;
+  once (action: string, handler: (param: any) => void): void;
+  emit (action: string, payload: (param: any) => void): void;
 }

+ 8 - 8
packages/@uppy/utils/types/index.d.ts

@@ -34,7 +34,7 @@ declare module '@uppy/utils/lib/emitSocketProgress' {
     bytesTotal: number;
   }
 
-  export default function emitSocketProgress(uploader: object, progressData: ProgressData, file: UppyFile);
+  export default function emitSocketProgress(uploader: object, progressData: ProgressData, file: UppyFile): void;
 }
 
 declare module '@uppy/utils/lib/findAllDOMElements' {
@@ -42,7 +42,7 @@ declare module '@uppy/utils/lib/findAllDOMElements' {
 }
 
 declare module '@uppy/utils/lib/findDOMElement' {
-  export default function findDOMElement(element: string | HTMLElement): HTMLElement?;
+  export default function findDOMElement(element: string | HTMLElement): HTMLElement | null;
 }
 
 declare module '@uppy/utils/lib/generateFileID' {
@@ -62,7 +62,7 @@ declare module '@uppy/utils/lib/getFileNameAndExtension' {
 }
 
 declare module '@uppy/utils/lib/getFileType' {
-  export default function getFileType(file: UppyFile): string?;
+  export default function getFileType(file: UppyFile): string | null;
 }
 
 declare module '@uppy/utils/lib/getFileTypeExtension' {
@@ -100,10 +100,10 @@ declare module '@uppy/utils/lib/isTouchDevice' {
 declare module '@uppy/utils/lib/limitPromises' {
   // TODO guess this could be generic but it's probably fine this way
   // because it's mostly for internal use
-  type LimitedFunction = (...args: any[]) => Promise<any>;
-  type LimitedFunctionFactory = (fn: function) => LimitedFunction;
+  type LimitedFunction<T> = (...args: any[]) => Promise<T>;
+  type LimitedFunctionFactory<T> = (fn: (...args: any[]) => Promise<T>) => LimitedFunction<T>;
 
-  export default function limitPromises(limit: number): LimitedFunctionFactory;
+  export default function limitPromises<T>(limit: number): LimitedFunctionFactory<T>;
 }
 
 declare module '@uppy/utils/lib/prettyETA' {
@@ -115,9 +115,9 @@ declare module '@uppy/utils/lib/secondsToTime' {
 }
 
 declare module '@uppy/utils/lib/settle' {
-  export default function settle(promises: Promise[]): Promise<{ successful: any[], failed: any[] }>;
+  export default function settle<T>(promises: Promise<T>[]): Promise<{ successful: T[], failed: any[] }>;
 }
 
 declare module '@uppy/utils/lib/toArray' {
-  export default function toArray(list: any): Array;
+  export default function toArray(list: any): any[];
 }

+ 0 - 27
packages/uppy/types/tsconfig.json

@@ -1,27 +0,0 @@
-{
-  "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "lib": [
-      "dom",
-      "esnext"
-    ],
-    "noImplicitAny": true,
-    "noImplicitThis": true,
-    "strictNullChecks": true,
-    "baseUrl": "../",
-    "typeRoots": [
-      "../"
-    ],
-    "types": [],
-    "noEmit": true,
-    "esModuleInterop": true,
-    "allowSyntheticDefaultImports": true,
-    "strictFunctionTypes": true,
-    "forceConsistentCasingInFileNames": true
-  },
-  "files": [
-    "index.d.ts",
-    "uppy-tests.ts"
-  ]
-}

+ 2 - 9
packages/@uppy/core/types/tsconfig.json → tsconfig.json

@@ -1,5 +1,6 @@
 {
   "compilerOptions": {
+    "noEmit": true,
     "target": "esnext",
     "module": "commonjs",
     "lib": [
@@ -9,19 +10,11 @@
     "noImplicitAny": true,
     "noImplicitThis": true,
     "strictNullChecks": true,
-    "baseUrl": "../",
-    "typeRoots": [
-      "../"
-    ],
     "types": [],
     "noEmit": true,
     "esModuleInterop": true,
     "allowSyntheticDefaultImports": true,
     "strictFunctionTypes": true,
     "forceConsistentCasingInFileNames": true
-  },
-  "files": [
-    "index.d.ts",
-    "core-tests.ts"
-  ]
+  }
 }