1
0
Fork 0

stricter typescript

This commit is contained in:
ChaotiCryptidz 2022-01-19 15:33:07 +00:00
parent 120bcb8e1e
commit 153c5725aa
5 changed files with 12 additions and 8 deletions

View file

@ -29,10 +29,10 @@ export class KVSecretVew extends Component<KVSecretViewProps, unknown> {
} else { } else {
return ( return (
<> <>
{Array.from(secretsMap).map((data: [string, string]) => ( {Array.from(secretsMap).map((data: [string, unknown]) => (
<Grid size={GridSizes.NORMAL}> <Grid size={GridSizes.NORMAL}>
<CopyableInputBox text={data[0]} copyable /> <CopyableInputBox text={data[0]} copyable />
<CopyableInputBox text={data[1]} copyable /> <CopyableInputBox text={data[1] as string} copyable />
</Grid> </Grid>
))} ))}
</> </>

View file

@ -41,7 +41,7 @@ export class KeyValueEditorSettings extends Component<DefaultPageProps> {
type="number" type="number"
value={this.props.settings.kvEditorIndent} value={this.props.settings.kvEditorIndent}
onChange={() => { onChange={() => {
const value = this.indentInputRef.current.value; const value = this.indentInputRef.current?.value;
const indent = parseInt(value); const indent = parseInt(value);
this.props.settings.kvEditorIndent = indent; this.props.settings.kvEditorIndent = indent;
settingsSavedNotification(); settingsSavedNotification();

View file

@ -46,6 +46,7 @@ type UnsealPageState = {
mode: string; mode: string;
keys_submitted: number; keys_submitted: number;
keys_needed: number; keys_needed: number;
timer: number;
}; };
export class Unseal extends Component<DefaultPageProps, UnsealPageState> { export class Unseal extends Component<DefaultPageProps, UnsealPageState> {
@ -55,11 +56,10 @@ export class Unseal extends Component<DefaultPageProps, UnsealPageState> {
mode: UnsealInputModes.FORM_INPUT, mode: UnsealInputModes.FORM_INPUT,
keys_submitted: 0, keys_submitted: 0,
keys_needed: 0, keys_needed: 0,
timer: 0,
}; };
} }
timer: number;
async submitKey(key: string): Promise<void> { async submitKey(key: string): Promise<void> {
try { try {
await this.props.api.submitUnsealKey(key); await this.props.api.submitUnsealKey(key);
@ -83,14 +83,15 @@ export class Unseal extends Component<DefaultPageProps, UnsealPageState> {
} }
componentWillUnmount(): void { componentWillUnmount(): void {
clearInterval(this.timer); clearInterval(this.state.timer);
} }
componentDidMount(): void { componentDidMount(): void {
this.updateStateWithSealStatus(); this.updateStateWithSealStatus();
this.timer = setInterval(() => { const timer = setInterval(() => {
this.updateStateWithSealStatus(); this.updateStateWithSealStatus();
}, 500) as unknown as number; }, 500) as unknown as number;
this.setState({timer: timer});
} }
render(): JSX.Element { render(): JSX.Element {

View file

@ -14,10 +14,11 @@ export const sortedObjectMap = (obj: Record<string, unknown>): Map<string, unkno
export function getKeyByObjectPropertyValue( export function getKeyByObjectPropertyValue(
map: Record<string, unknown>, map: Record<string, unknown>,
searchValue: unknown, searchValue: unknown,
): string { ): string | null {
for (const key of getObjectKeys(map)) { for (const key of getObjectKeys(map)) {
if (map[key] === searchValue) return key; if (map[key] === searchValue) return key;
} }
return null;
} }
export function verifyJSONString(str: string): boolean { export function verifyJSONString(str: string): boolean {

View file

@ -6,8 +6,10 @@
"module": "es6", "module": "es6",
"target": "es2019", "target": "es2019",
"strictBindCallApply": true, "strictBindCallApply": true,
"strictNullChecks": false,
"noImplicitThis": true, "noImplicitThis": true,
"allowJs": true, "allowJs": true,
"strict": true,
"moduleResolution": "node", "moduleResolution": "node",
"jsx": "react-jsx", "jsx": "react-jsx",
"jsxImportSource": "preact", "jsxImportSource": "preact",