Skip to content

Commit

Permalink
Task: Update typings (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagomapmarques authored Sep 26, 2019
1 parent fecccb6 commit ab648f1
Show file tree
Hide file tree
Showing 4 changed files with 387 additions and 481 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
"build:prod": "webpack --progress --bail --env prod",
"build:prod:watch": "yarn build:prod --watch --serve --open --spa",
"lint": "yarn lint:code && yarn lint:tests",
"lint:fix": "yarn lint:code:fix && yarn lint:tests:fix",
"lint:fix": "yarn lint:code -f && yarn lint:tests -f",
"lint:code": "biotope-quality-gate -c ./lint.config.js -p ./src/app,./config,./typings,./*.js",
"lint:code:fix": "biotope-quality-gate -c ./lint.config.js -p ./src/app,./config,./typings,./*.js -f",
"lint:tests": "biotope-quality-gate -t -p ./src/app,./src/testing",
"lint:tests:fix": "biotope-quality-gate -t -p ./src/app,./src/testing -f",
"start": "yarn watch",
"test": "jest --config jest.config.js",
"test:no-cache": "yarn test --no-cache",
Expand Down
31 changes: 11 additions & 20 deletions typings/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@

// BASE DEFINITIONS

declare interface IndexObject<T> {
[key: string]: T;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-empty-interface
declare interface IndexObjectAny extends IndexObject<any> {}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare type RecordAny = Record<string, any>;

declare module '*.style' {
interface ImportedStyle extends IndexObject<string> {
// FIXME: toString should be specified as described in the comment beside it, but due to the
// definition of IndexObject, the value of all keys should be of the same type (string).
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toString: any; // should be of type "() => string"
type ImportedStyle = Record<string, string>;
interface ToStringObject {
toString: () => string;
}
const style: ImportedStyle;

const style: ImportedStyle & ToStringObject;
export = style;
}

Expand All @@ -25,12 +18,10 @@ declare module '*.svg' {
export default content;
}

// FIXME: Typescript limitation on importing deconstructed json files
// declare module '*.json' {
// const content: IndexObjectAny;
// export = content;
// }
declare module '*.json';
declare module '*.json' {
const content: RecordAny;
export = content;
}

// ENVIRONMENT VARIABLES DEFINITION

Expand Down
2 changes: 1 addition & 1 deletion typings/testing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface MockImportsInterface {
add: (moduleName: string) => void;
}

declare function mockStyle(styleModule: IndexObject<string>): IndexObject<string>;
declare function mockStyle(styleModule: Record<string, string>): Record<string, string>;

// eslint-disable-next-line no-unused-vars
declare const MockImports: MockImportsInterface;
Expand Down
Loading

0 comments on commit ab648f1

Please sign in to comment.