Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve all tsc errors #217

Merged
merged 30 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
593afe2
Start typing the TS
Jakob37 Jan 31, 2025
4212653
Working through the types
Jakob37 Jan 31, 2025
9177ace
Merge branch 'jw/quick_hg002_load_util' into jw/ts-types
Jakob37 Jan 31, 2025
8b937de
Some base container typing
Jakob37 Jan 31, 2025
43fc740
Further types
Jakob37 Jan 31, 2025
434b5e7
More type cleanup
Jakob37 Jan 31, 2025
811cb80
Working through the types
Jakob37 Jan 31, 2025
8529f60
Add variable type
Jakob37 Jan 31, 2025
11fa86b
Clean up some types
Jakob37 Jan 31, 2025
d420874
More type checking
Jakob37 Jan 31, 2025
983ebbd
Working through typing
Jakob37 Feb 3, 2025
bef7994
More types
Jakob37 Feb 3, 2025
abae2cd
Merge attempt
Jakob37 Feb 5, 2025
5c68487
Fix tsc blocking code errors
Jakob37 Feb 5, 2025
6ff8ff5
Configure to run in development mode. Fix the parameter issue.
Jakob37 Feb 5, 2025
7492ee9
Type fixes
Jakob37 Feb 5, 2025
708fc6d
Overview type issues resolved
Jakob37 Feb 5, 2025
fe94e96
Ideogram types resolved
Jakob37 Feb 5, 2025
97bfb4e
Starting iterating on transcript issues
Jakob37 Feb 5, 2025
4d29856
Types in transcripts.ts
Jakob37 Feb 5, 2025
c638d31
Resolve annotation.ts type issues
Jakob37 Feb 5, 2025
1634827
Resolve variant types
Jakob37 Feb 5, 2025
63b558a
Resolve further types
Jakob37 Feb 5, 2025
a8a0017
Resolve last type errors
Jakob37 Feb 5, 2025
56b7844
Types
Jakob37 Feb 5, 2025
e2ef4ec
Changelog
Jakob37 Feb 5, 2025
4006d87
Merge master branch
Jakob37 Feb 5, 2025
4aa80e4
Looking through the changes
Jakob37 Feb 5, 2025
3be0b10
Fix jest export
Jakob37 Feb 5, 2025
224e7fb
@ts-expect-error instead of @ts-ignore
Jakob37 Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ gens/static/css/*
!gens/static/css/.gitkeep
*.min.css
*.min.js
*.map
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)
- Switched from JS to TS and updated required parts of the build chain.

### Fixed
- Resolved all type errors from tsc
- Initial type hints added to command and db modules

## 3.0.1
Expand Down
9 changes: 9 additions & 0 deletions assets/js/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// FIXME: Move all UI style variables here

Check notice on line 1 in assets/js/constants.ts

View check run for this annotation

codefactor.io / CodeFactor

assets/js/constants.ts#L1

Unexpected 'fixme' comment: 'FIXME: Move all UI style variables here'. (no-warning-comments)
export const COLORS = {
"lightgray": "#e5e5e5"
}

export const FONTSIZES = {
"small": 10,
"medium": 18
}
84 changes: 60 additions & 24 deletions assets/js/draw/graph.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
// graph related objects
import { COLORS, FONTSIZES } from "../constants";
import { drawRect, drawLine, drawRotatedText, drawText } from "./shapes";

// Draws vertical tick marks for selected values between
// xStart and xEnd with step length.
// The amplitude scales the values to drawing size
export function drawVerticalTicks(
export function drawVerticalTicks({
ctx,
renderX,
y,
xStart,
xEnd,
xoStart,
xoEnd,
width,
yMargin,
titleColor,
}:{
ctx: CanvasRenderingContext2D,
renderX: number,
y: number,
Expand All @@ -15,7 +27,7 @@ export function drawVerticalTicks(
width: number,
yMargin: number,
titleColor: string,
) {
} ) {
const lineThickness = 1;
const lineWidth = 5;
const regionSize = xEnd - xStart;
Expand All @@ -39,15 +51,15 @@ export function drawVerticalTicks(
const value = numberWithCommas(step.toFixed(0));

// Draw text and ticks only for the leftmost box
drawRotatedText(
drawRotatedText({
ctx,
value,
10,
renderX + xStep + 8,
y - value.length - 3 * yMargin,
-Math.PI / 4,
titleColor,
);
text: value,
textSize: FONTSIZES.small,
posx: renderX + xStep + 8,
posy: y - value.length - 3 * yMargin,
rotDegrees: -Math.PI / 4,
color: titleColor,
});

// Draw tick line
drawLine({
Expand All @@ -66,15 +78,27 @@ export function drawVerticalTicks(
// yStart and yEnd with step length.
// The amplitude scales the values to drawing size
export function drawGraphLines(
ctx: CanvasRenderingContext2D,
x: number,
y: number,
yStart: number,
yEnd: number,
stepLength: number,
yMargin: number,
width: number,
height: number,
{
ctx,
x,
y,
yStart,
yEnd,
stepLength,
yMargin,
width,
height,
}: {
ctx: CanvasRenderingContext2D,
x: number,
y: number,
yStart: number,
yEnd: number,
stepLength: number,
yMargin: number,
width: number,
height: number,
}
) {
const ampl = (height - 2 * yMargin) / (yStart - yEnd); // Amplitude for scaling y-axis to fill whole height
const lineThickness = 1;
Expand All @@ -88,13 +112,13 @@ export function drawGraphLines(
y: yPos,
x2: x + width - 2 * lineThickness,
y2: yPos,
color: "#e5e5e5",
color: COLORS.lightgray,
});
}
}

// Creates a graph for one chromosome data type
export function createGraph(
export function createGraph({
ctx,
x,
y,
Expand All @@ -106,8 +130,21 @@ export function createGraph(
step,
addTicks,
color = "black",
open,
) {
open = false,
}: {
ctx: CanvasRenderingContext2D,
x: number,
y: number,
width: number,
height: number,
yMargin: number,
yStart: number,
yEnd: number,
step: number,
addTicks: boolean,
color?: string,
open?: boolean
}) {
// Draw tick marks
if (addTicks) {
drawTicks(
Expand Down Expand Up @@ -153,7 +190,6 @@ function drawTicks(
x: x - lineWidth,
y: y + (yStart - step) * ampl + 2.2,
text: step.toFixed(1),
textSize: 10,
align: "right",
});

Expand Down
36 changes: 19 additions & 17 deletions assets/js/draw/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
export function drawPoints({
ctx,
data,
color, // FIXME: Currently not used?

Check notice on line 7 in assets/js/draw/shapes.ts

View check run for this annotation

codefactor.io / CodeFactor

assets/js/draw/shapes.ts#L7

'color' is defined but never used. (@typescript-eslint/no-unused-vars)

Check notice on line 7 in assets/js/draw/shapes.ts

View check run for this annotation

codefactor.io / CodeFactor

assets/js/draw/shapes.ts#L7

Unexpected 'fixme' comment: 'FIXME: Currently not used?'. (no-warning-comments)
}: {
ctx: CanvasRenderingContext2D;
data: number[];
color: string,
}) {
ctx.fillStyle = "#000";
for (let i = 0; i < data.length; i += 2) {
Expand All @@ -28,23 +30,23 @@
text,
posx,
posy,
rot_degrees,
textSize,
rotDegrees,
color = "black",
}: {
ctx: CanvasRenderingContext2D;
text: string;
posx: number;
posy: number;
rot_degrees: number;
textSize: number;
color: string;
rotDegrees?: number;
color?: string;
}) {
ctx.save();
ctx.fillStyle = color;
ctx.font = "".concat(textSize.toString(), "px Arial");
ctx.translate(posx, posy); // Position for text
ctx.rotate(rot_degrees); // Rotate rot degrees
ctx.rotate(rotDegrees); // Rotate rot degrees
ctx.textAlign = "center";
ctx.fillText(text, 0, 9);
ctx.restore();
Expand All @@ -63,11 +65,11 @@
x: number;
y: number;
text: string;
fontProp: string;
align: CanvasTextAlign;
fontProp?: number|string;
align?: CanvasTextAlign;
}) {
ctx.save();
ctx.font = "".concat(fontProp, "px Arial");
ctx.font = "".concat(fontProp.toString(), "px Arial");
ctx.textAlign = align;
ctx.textBaseline = "middle";
ctx.fillStyle = "black";
Expand Down Expand Up @@ -98,8 +100,8 @@
y: number;
x2: number;
y2: number;
lineWidth: number;
color: string;
lineWidth?: number;
color?: string;
}) {
// transpose coordinates .5 px to become sharper
x = Math.floor(x) + 0.5;
Expand Down Expand Up @@ -135,10 +137,10 @@
width: number;
height: number;
lineWidth: number;
color: string | null;
fillColor: string | null;
open: boolean;
debug: boolean;
color?: string | null;
fillColor?: string | null;
open?: boolean;
debug?: boolean;
}) {
x = Math.floor(x) + 0.5;
y = Math.floor(y) + 0.5;
Expand Down Expand Up @@ -186,8 +188,8 @@
y: number;
dir: number;
height: number;
lineWidth: number;
color: string;
lineWidth?: number;
color?: string;
}) {
const width = dir * lineWidth;
ctx.save();
Expand Down Expand Up @@ -220,8 +222,8 @@
y: number;
x2: number;
height: number;
color: string;
lineWidth: number;
color?: string;
lineWidth?: number;
}) {
ctx.save();
ctx.strokeStyle = color;
Expand Down
10 changes: 6 additions & 4 deletions assets/js/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// functions for making api requests to Gens
/* global _apiHost */

async function request(url, params, method = "GET") {
// options passed to hte fetch request
const options = {
async function request(url: string, params: string, method: RequestType = "GET") {
// options passed to the fetch request
const options: RequestOptions = {
method,
headers: {
"Content-Type": "application/json",
Expand All @@ -20,6 +20,7 @@ async function request(url, params, method = "GET") {
}
}
// fetch returns a promise
// @ts-expect-error - FIXME: This should not be global
const response = await fetch(_apiHost + url, options);

if (response.status !== 200) {
Expand All @@ -42,7 +43,8 @@ export function objectToQueryString(obj) {
}

// A generic error handler that just returns an object with status=error and message
function generateErrorResponse(message) {
function generateErrorResponse(message: string): Error {
// @ts-expect-error - FIXME: This should not take two arguments or?
return new Error({
status: "error",
message,
Expand Down
2 changes: 2 additions & 0 deletions assets/js/gens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
delete window.location;
const inputElem = document.createElement("input");
document.createElement = jest.fn().mockReturnValueOnce(inputElem);
// @ts-expect-error FIXME: Unsure about these, look into at a later point
delete window.createElement;
// @ts-expect-error

Check warning on line 12 in assets/js/gens.test.ts

View check run for this annotation

codefactor.io / CodeFactor

assets/js/gens.test.ts#L12

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer. (@typescript-eslint/ban-ts-comment)
window.location = new URL("https://www.example.com/sampleId?foo=bar&doo=moo");
// run function
copyPermalink("38", "1:10-100");
Expand Down
9 changes: 9 additions & 0 deletions assets/js/gens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export function initCanvases({
scoutBaseURL,
selectedVariant,
annotationFile,
}: {
sampleName: string,
caseId: string,
genomeBuild: number,
hgFileDir: string,
uiColors: UIColors,
scoutBaseURL: string,
selectedVariant: string,
annotationFile: string
}) {
// initialize and return the different canvases
// WEBGL values
Expand Down
Loading