diff --git a/types/mithril-global/index.d.ts b/types/mithril-global/index.d.ts new file mode 100644 index 0000000000..4dd8240303 --- /dev/null +++ b/types/mithril-global/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for Mithril 1.1 +// Project: https://mithril.js.org/ +// Definitions by: Mike Linkovich , Isiah Meadows +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +// Global Mithril types + +/// + +import * as mithril from 'mithril'; +import * as stream from 'mithril/stream'; + +declare namespace MithrilGlobal { + export type Lifecycle = mithril.Lifecycle; + export type Hyperscript = mithril.Hyperscript; + export type RouteResolver = mithril.RouteResolver; + export type RouteDefs = mithril.RouteDefs; + export type RouteOptions = mithril.RouteOptions; + export type Route = mithril.Route; + export type RequestOptions = mithril.RequestOptions; + export type JsonpOptions = mithril.JsonpOptions; + export type Child = mithril.Child; + export type ChildArray = mithril.ChildArray; + export type Children = mithril.Children; + export type ChildArrayOrPrimitive = mithril.ChildArrayOrPrimitive; + export type Vnode = mithril.Vnode; + export type VnodeDOM = mithril.VnodeDOM; + export type CVnode = mithril.CVnode; + export type CVnodeDOM = mithril.CVnodeDOM; + export type Component = mithril.Component; + export type Comp = mithril.Comp + export type ClassComponent = mithril.ClassComponent; + export type FactoryComponent = mithril.FactoryComponent; + export type ComponentTypes = mithril.ComponentTypes; + export type Attributes = mithril.Attributes; + export type Stream = stream.Stream; + export type Static = mithril.Static & {stream: stream.Static}; +} + +declare const MithrilGlobal: MithrilGlobal.Static; +export = MithrilGlobal; +export as namespace m; diff --git a/types/mithril-global/mithril-global-tests.ts b/types/mithril-global/mithril-global-tests.ts new file mode 100644 index 0000000000..a8aa577320 --- /dev/null +++ b/types/mithril-global/mithril-global-tests.ts @@ -0,0 +1,13 @@ +// Test global mithril types + +const comp = { + view() { + return m('span', "Test") + } +} as m.Comp<{},{}> + +m.mount(document.getElementById('comp')!, comp) + +const vnode = m('div', 'Test') + +const s: m.Stream = m.stream(1) diff --git a/types/mithril-global/tsconfig.json b/types/mithril-global/tsconfig.json new file mode 100644 index 0000000000..cb58123eb0 --- /dev/null +++ b/types/mithril-global/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es2015", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "suppressImplicitAnyIndexErrors": true, + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [] + }, + "files": [ + "index.d.ts", + "mithril-global-tests.ts" + ], + "atom": { + "rewriteTsconfig": false + } +} diff --git a/types/mithril-global/tslint.json b/types/mithril-global/tslint.json new file mode 100644 index 0000000000..250b1b7b5f --- /dev/null +++ b/types/mithril-global/tslint.json @@ -0,0 +1,23 @@ +{ + "extends": "../tslint.json", + "rules": { + "array-type": [false, "array"], + "quotemark": [false, "double"], + "semicolon": [false, "always"], + "space-before-function-paren": [false, "always"], + "max-line-length": [false, 200], + "no-empty-interface": false, + "no-redundant-modifiers": false, + "only-arrow-functions": [false], + "prefer-for-of": false, + "unified-signatures": false, + "whitespace": [ + false, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +}