Skip to content

Commit

Permalink
feat(hdom-components): enable TS strict compiler flags (refactor)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 4, 2019
1 parent 3143141 commit 6233ba2
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 11 deletions.
5 changes: 5 additions & 0 deletions packages/hdom-components/adr/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Architecture Decision Records

* [1. Record architecture decisions](0001-record-architecture-decisions.md)
* [2. Component configuration](0002-component-configuration.md)
* [3. Component configuration via context](0003-component-configuration-via-context.md)
2 changes: 1 addition & 1 deletion packages/hdom-components/src/button-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface ButtonGroupItem extends Array<any> {
}

export type ButtonGroup = (
_,
_: any,
args: ButtonGroupArgs,
...buttons: ButtonGroupItem[]
) => any;
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const button = (opts?: Partial<ButtonOpts>): Button => {
{
...mergeAttribs(opts.attribs, args.attribs),
onclick: opts.preventDefault
? (e) => (e.preventDefault(), args.onclick(e))
? (e: Event) => (e.preventDefault(), args.onclick(e))
: args.onclick
},
...body
Expand Down
12 changes: 10 additions & 2 deletions packages/hdom-components/src/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ export interface CanvasHandlers<T extends CanvasContext> {
* @param handlers user handlers
* @param opts canvas context creation options
*/
const _canvas = (type, handlers: Partial<CanvasHandlers<any>>, opts) => {
let el, ctx;
const _canvas = (
type: string,
handlers: Partial<CanvasHandlers<any>>,
opts: Canvas2DContextAttributes | WebGLContextAttributes
) => {
let el: HTMLCanvasElement;
let ctx:
| CanvasRenderingContext2D
| WebGLRenderingContext
| WebGL2RenderingContext;
let frame = 0;
let time = 0;
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/fps-counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const fpsCounter = (opts?: Partial<FpsCounterOpts>) => {
sparkline: {},
...opts
};
return {
return <any>{
init() {
this.last = Date.now();
this.lastLabel = this.last;
Expand Down
9 changes: 7 additions & 2 deletions packages/hdom-components/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ export const link = (attribs: any, body: any) => [
body
];

export const appLink = (_, attribs: any, onclick: EventListener, body: any) => [
export const appLink = (
_: any,
attribs: any,
onclick: EventListener,
body: any
) => [
"a",
{
href: "#",
onclick: (e) => {
onclick: (e: Event) => {
e.preventDefault();
onclick(e);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface NotificationArgs {
* @param opts
*/
export const notification = (opts?: Partial<NotificationOpts>) => {
return (_, args: Partial<NotificationArgs>, body: any) => [
return (_: any, args: Partial<NotificationArgs>, body: any) => [
"div",
{ ...opts.attribs, ...args.attribs },
opts.icon,
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/pager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const pager = (opts: PagerOpts) => {
},
opts
);
return (_, id: number, num: number, pageLen = 10, maxBts = 5) => {
return (_: any, id: number, num: number, pageLen = 10, maxBts = 5) => {
const bt = opts.button;
const step = opts.navStep;
const maxID = Math.floor(Math.max(0, num - 1) / pageLen);
Expand Down
6 changes: 5 additions & 1 deletion packages/hdom-components/src/sparkline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export interface SparklineOpts {
* @param opts config options
* @param vals data values
*/
export const sparkline = (_, opts: Partial<SparklineOpts>, vals: number[]) => {
export const sparkline = (
_: any,
opts: Partial<SparklineOpts>,
vals: number[]
) => {
opts = {
min: 0,
max: 100,
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const title = (opts?: Partial<TitleOpts>) => {
},
opts
);
return (_, title, subtitle) => [
return (_: any, title: any, subtitle: any) => [
opts.element,
opts.attribs,
title,
Expand Down

0 comments on commit 6233ba2

Please sign in to comment.