feat: add typescript types + type tests (#48)

* feat: add typescript types

* feat: add typescript type tests

* chore: bump deps

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Cayman 2020-02-06 06:57:16 -06:00 committed by GitHub
parent 52d9dfc062
commit 74830fa5d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 2 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ coverage
.lock-wscript .lock-wscript
build build
docs
# Dependency directory # Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git

View File

@ -10,6 +10,7 @@
"test": "aegir test", "test": "aegir test",
"test:node": "aegir test --target node", "test:node": "aegir test --target node",
"test:browser": "aegir test --target browser", "test:browser": "aegir test --target browser",
"test:types": "npx tsc",
"release": "aegir release", "release": "aegir release",
"release-minor": "aegir release --type minor", "release-minor": "aegir release --type minor",
"release-major": "aegir release --type major", "release-major": "aegir release --type major",
@ -27,11 +28,13 @@
"bugs": "https://github.com/multiformats/js-mafmt/issues", "bugs": "https://github.com/multiformats/js-mafmt/issues",
"homepage": "https://github.com/multiformats/js-mafmt#readme", "homepage": "https://github.com/multiformats/js-mafmt#readme",
"devDependencies": { "devDependencies": {
"aegir": "^20.0.0", "@types/chai": "^4.2.8",
"@types/mocha": "^7.0.1",
"aegir": "^20.6.0",
"chai": "^4.2.0" "chai": "^4.2.0"
}, },
"dependencies": { "dependencies": {
"multiaddr": "^7.0.0" "multiaddr": "^7.3.0"
}, },
"contributors": [ "contributors": [
"Alan Shaw <alan@tableflip.io>", "Alan Shaw <alan@tableflip.io>",

28
src/index.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
import Multiaddr = require('multiaddr');
export declare interface Mafmt {
toString(): string;
input?: (Mafmt | (() => Mafmt))[];
matches: (a: string | Buffer | Multiaddr) => boolean;
partialMatch: (protos: string[]) => boolean;
}
export const DNS: Mafmt;
export const DNS4: Mafmt;
export const DNS6: Mafmt;
export const IP: Mafmt;
export const TCP: Mafmt;
export const UDP: Mafmt;
export const UTP: Mafmt;
export const HTTP: Mafmt;
export const HTTPS: Mafmt;
export const WebSockets: Mafmt;
export const WebSocketsSecure: Mafmt;
export const WebSocketStar: Mafmt;
export const WebRTCStar: Mafmt;
export const WebRTCDirect: Mafmt;
export const Reliable: Mafmt;
export const Stardust: Mafmt;
export const Circuit: Mafmt;
export const P2P: Mafmt;
export const IPFS: Mafmt;

38
tsconfig.json Normal file
View File

@ -0,0 +1,38 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"target": "ES5",
"noImplicitAny": false,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"allowJs": true,
"checkJs": true,
"baseUrl": ".",
"paths": {
"mafmt": [
"./src",
"../src",
]
},
"types": [
"node",
"mocha",
"chai"
],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"./src/index.d.ts",
],
"include": [
"./test/**/*.spec.js"
]
}