Merge pull request #15742 from spacejack/mithril-1.1-global

Add types for Mithril 1.1 global version
This commit is contained in:
Yui
2017-04-14 08:01:07 -07:00
committed by GitHub
4 changed files with 101 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
// Type definitions for Mithril 1.1
// Project: https://mithril.js.org/
// Definitions by: Mike Linkovich <https://github.com/spacejack>, Isiah Meadows <https://github.com/isiahmeadows>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// Global Mithril types
/// <reference types="mithril" />
import * as mithril from 'mithril';
import * as stream from 'mithril/stream';
declare namespace MithrilGlobal {
export type Lifecycle<A,S> = mithril.Lifecycle<A,S>;
export type Hyperscript = mithril.Hyperscript;
export type RouteResolver<S,P> = mithril.RouteResolver<S,P>;
export type RouteDefs = mithril.RouteDefs;
export type RouteOptions = mithril.RouteOptions;
export type Route = mithril.Route;
export type RequestOptions<T> = mithril.RequestOptions<T>;
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<A,S> = mithril.Vnode<A,S>;
export type VnodeDOM<A,S> = mithril.VnodeDOM<A,S>;
export type CVnode<A> = mithril.CVnode<A>;
export type CVnodeDOM<A> = mithril.CVnodeDOM<A>;
export type Component<A,S> = mithril.Component<A,S>;
export type Comp<A,S> = mithril.Comp<A,S>
export type ClassComponent<A> = mithril.ClassComponent<A>;
export type FactoryComponent<A> = mithril.FactoryComponent<A>;
export type ComponentTypes<A,S> = mithril.ComponentTypes<A,S>;
export type Attributes = mithril.Attributes;
export type Stream<T> = stream.Stream<T>;
export type Static = mithril.Static & {stream: stream.Static};
}
declare const MithrilGlobal: MithrilGlobal.Static;
export = MithrilGlobal;
export as namespace m;
@@ -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<number> = m.stream(1)
+22
View File
@@ -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
}
}
+23
View File
@@ -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"
]
}
}