Move library files to lib/

This commit is contained in:
2020-01-27 20:03:15 +05:30
parent 1df5364928
commit 66248b8e26
22 changed files with 0 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import * as ts from "typescript";
import { INIT_SOURCEFILE, UPDATE_SOURCEFILE, CLEAR_SOURCEFILE } from "./types";
export function initSourceFile(sourceFile: ts.SourceFile) {
return {
type: INIT_SOURCEFILE,
payload: { sourceFile }
};
}
export function updateSourceFile(sourceFile: ts.SourceFile) {
return {
type: UPDATE_SOURCEFILE,
payload: { sourceFile }
};
}
export function clearSourceFile() {
return {
type: CLEAR_SOURCEFILE,
};
}
+35
View File
@@ -0,0 +1,35 @@
import {
INIT_SOURCEFILE,
UPDATE_SOURCEFILE,
CLEAR_SOURCEFILE,
SourceFilesState,
SourceFilesActionTypes
} from "./types";
const initialState: SourceFilesState = {
inititalSourceFile: undefined,
currentSourceFile: undefined
};
export function sourceFilesReducer(
state = initialState,
action: SourceFilesActionTypes
): SourceFilesState {
switch (action.type) {
case INIT_SOURCEFILE:
return {
...state,
inititalSourceFile: action.payload.sourceFile,
currentSourceFile: action.payload.sourceFile
};
case UPDATE_SOURCEFILE:
return {
...state,
currentSourceFile: action.payload.sourceFile
};
case CLEAR_SOURCEFILE:
return initialState;
default:
return state;
}
}
+31
View File
@@ -0,0 +1,31 @@
import * as ts from "typescript";
// Describing the shape of the sourceFile's slice of state
export interface SourceFilesState {
inititalSourceFile?: ts.SourceFile;
currentSourceFile?: ts.SourceFile;
}
// Describing the different ACTION NAMES available
export const INIT_SOURCEFILE = "INIT_SOURCEFILE";
export const UPDATE_SOURCEFILE = "UPDATE_SOURCEFILE";
export const CLEAR_SOURCEFILE = "CLEAR_SOURCEFILE";
interface InitSourceFileAction {
type: typeof INIT_SOURCEFILE;
payload: { sourceFile: ts.SourceFile };
}
interface UpdateSourceFileAction {
type: typeof UPDATE_SOURCEFILE;
payload: { sourceFile: ts.SourceFile };
}
interface ClearSourceFileAction {
type: typeof CLEAR_SOURCEFILE;
}
export type SourceFilesActionTypes =
| InitSourceFileAction
| UpdateSourceFileAction
| ClearSourceFileAction;