Skip to content

Commit 8b88980

Browse files
committed
chore: add types to import functions
1 parent 27c6198 commit 8b88980

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

packages/generators/add-generator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
} from "./utils/add/questions";
1010

1111
import {
12-
replaceAt,
1312
traverseAndGetProperties,
1413
webpackDevServerSchema,
1514
webpackSchema
@@ -112,7 +111,7 @@ export default class AddGenerator extends Generator {
112111
.then((mergeFileAnswer: {
113112
mergeFile: string,
114113
mergeConfigName: string
115-
}) => {
114+
}):void => {
116115
const resolvedPath = resolve(process.cwd(), mergeFileAnswer.mergeFile);
117116
// eslint-disable-next-line
118117
this.configuration.config[action] = [mergeFileAnswer.mergeConfigName, resolvedPath];

packages/generators/utils/add/questions/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Question } from "inquirer";
1616
* @param {string} action action for which question has to be prompted
1717
* @returns {Question} Question for given action
1818
*/
19-
export const manualOrListInput: (action: string) => Question = (action: string) => {
19+
export const manualOrListInput = (action: string): Question => {
2020
const actionQuestion = `What do you want to add to ${action}?`;
2121
return Input("actionAnswer", actionQuestion);
2222
};
@@ -42,9 +42,9 @@ export const topScopeQuestion: Question = Input(
4242
"What do you want to add to topScope?",
4343
);
4444

45-
const mergeFileQuestionsFunction = () => {
45+
const mergeFileQuestionsFunction = (): Question[] => {
4646
const mergePathQuestion = "What is the location of webpack configuration with which you want to merge current configuration?";
47-
const mergePathValidator = (path: string) => {
47+
const mergePathValidator = (path: string): boolean|string => {
4848
const resolvedPath = resolve(process.cwd(), path);
4949
if (existsSync(resolvedPath)) {
5050
if (/\.js$/.test(path)) {

packages/utils/ast-utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function isImportPresent (j: JSCodeshift, ast: Node, path: string): boolean {
77
throw new Error(`path parameter should be string, recieved ${typeof path}`);
88
}
99
let isPresent = false;
10-
ast.find(j.CallExpression).forEach(callExp => {
10+
ast.find(j.CallExpression).forEach((callExp: Node): void => {
1111
if ((callExp.value as Node).callee.name === 'require' && (callExp.value as Node).arguments[0].value === path) {
1212
isPresent = true;
1313
}
@@ -648,11 +648,11 @@ function parseMerge(j: JSCodeshift, ast: Node, value: string[], action: string):
648648
return false; // TODO: debug later
649649
}
650650

651-
function addMergeImports(configIdentifier: string, configPath: string) {
651+
function addMergeImports(configIdentifier: string, configPath: string): void {
652652
if (typeof configIdentifier !== "string" || typeof configPath !== "string") {
653-
throw new Error(`Both parameters should be string. Recieved ${configIdentifier}, ${configPath}`)
653+
throw new Error(`Both parameters should be string. recieved ${typeof configIdentifier}, ${typeof configPath}`)
654654
}
655-
ast.find(j.Program).forEach(p => {
655+
ast.find(j.Program).forEach((p: Node): void => {
656656
if (!isImportPresent(j, ast, 'webpack-merge')) {
657657
(p.value as Node).body.splice(-1, 0, `const merge = require('webpack-merge')`);
658658
}

0 commit comments

Comments
 (0)