Skip to content

Commit

Permalink
Tsify main (#4520)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Jan 14, 2023
1 parent 07f37ab commit 33167a3
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 223 deletions.
2 changes: 1 addition & 1 deletion lib/common-utils.ts
Expand Up @@ -29,6 +29,6 @@ export function isString(x: any): x is string {
// Object.keys is typed as returning :string[] for some reason
// This util is for cases where the key is a union of a few possible keys and we
// want the resulting array properly typed.
export function keys<K extends string | number | symbol>(o: Record<K, any>): K[] {
export function keys<K extends string | number | symbol>(o: Partial<Record<K, any>>): K[] {
return Object.keys(o) as K[];
}
3 changes: 1 addition & 2 deletions lib/compilers/hook.ts
Expand Up @@ -24,12 +24,11 @@

import path from 'path';

import {ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces';
import {CompilationResult, ExecutionOptions} from '../../types/compilation/compilation.interfaces';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces';
import {BaseCompiler} from '../base-compiler';

import {AsmResultSource, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces';

export class HookCompiler extends BaseCompiler {
static get key(): string {
return 'hook';
Expand Down
3 changes: 2 additions & 1 deletion lib/options-handler.ts
Expand Up @@ -54,6 +54,7 @@ export type OptionHandlerArguments = {
suppressConsoleLog: boolean;
};

// TODO: Is this the same as Options in static/options.interfaces.ts?
type OptionsType = {
googleAnalyticsAccount: string;
googleAnalyticsEnabled: boolean;
Expand Down Expand Up @@ -188,7 +189,7 @@ export class ClientOptionsHandler {
sentryEnvironment: ceProps('sentryEnvironment') || defArgs.env[0],
release: defArgs.releaseBuildNumber || defArgs.gitReleaseName,
gitReleaseCommit: defArgs.gitReleaseName || '',
cookieDomainRe: cookieDomainRe,
cookieDomainRe,
localStoragePrefix: ceProps('localStoragePrefix'),
cvCompilerCountMax: ceProps('cvCompilerCountMax', 6),
defaultFontScale: ceProps('defaultFontScale', 14),
Expand Down
35 changes: 23 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -26,6 +26,7 @@
"@sentry/node": "^7.28.1",
"@types/body-parser": "^1.19.2",
"@types/file-saver": "^2.0.5",
"@types/js-cookie": "^3.0.2",
"@types/http-proxy": "^1.17.9",
"@types/request": "^2.48.8",
"aws-sdk": "^2.1048.0",
Expand Down
3 changes: 1 addition & 2 deletions static/analytics.ts
Expand Up @@ -93,5 +93,4 @@ class GAProxy {
}
}

const ga = new GAProxy();
export {ga};
export const ga = new GAProxy();
10 changes: 5 additions & 5 deletions static/components.interfaces.ts
Expand Up @@ -60,12 +60,12 @@ export interface ComponentConfig<S> {
componentState: S;
}

type StateWithLanguage = {lang: string};
export type StateWithLanguage = {lang: string};
// TODO(#4490 The War of The Types) We should normalize state types
type StateWithEditor = {source: string | number};
type StateWithTree = {tree: number};
type StateWithId = {id: number};
type EmptyState = Record<never, never>;
export type StateWithEditor = {source: string | number};
export type StateWithTree = {tree: number};
export type StateWithId = {id: number};
export type EmptyState = Record<never, never>;

export type EmptyCompilerState = StateWithLanguage & StateWithEditor;
export type PopulatedCompilerState = StateWithEditor & {
Expand Down
4 changes: 3 additions & 1 deletion static/global.ts
Expand Up @@ -25,7 +25,7 @@
import {IFrontendTesting} from './tests/frontend-testing.interfaces';
import {Options} from './options.interfaces';

type CompilerExplorerOptions = Record<string, unknown> & Options;
export type CompilerExplorerOptions = Record<string, unknown> & Options;

declare global {
export interface Window {
Expand All @@ -36,6 +36,8 @@ declare global {
ga: any;
GoogleAnalyticsObject: any;
hasUIBeenReset: boolean;
PRODUCTION: boolean;
onSponsorClick: (sponsorUrl: string) => void;
}
}

Expand Down
4 changes: 2 additions & 2 deletions static/hub.ts
Expand Up @@ -100,9 +100,9 @@ export class Hub {
public subdomainLangId: string | undefined;
public defaultLangId: string;

public constructor(public readonly layout: GoldenLayout, subLangId: string, defaultLangId: string) {
public constructor(public readonly layout: GoldenLayout, subLangId: string | undefined, defaultLangId: string) {
this.lastOpenedLangId = null;
this.subdomainLangId = subLangId || undefined;
this.subdomainLangId = subLangId;
this.defaultLangId = defaultLangId;
this.compilerService = new CompilerService(this.layout.eventHub);

Expand Down
2 changes: 1 addition & 1 deletion static/local.ts
Expand Up @@ -26,7 +26,7 @@ import {options} from './options';

const prefix = options.localStoragePrefix ?? '';

export function get(key: string, ifNotPresent: string): string {
export function get<T>(key: string, ifNotPresent: T): string | T {
try {
return window.localStorage.getItem(prefix + key) ?? ifNotPresent;
} catch (e) {
Expand Down

0 comments on commit 33167a3

Please sign in to comment.