diff --git a/.gitignore b/.gitignore index e4c5b0e..6780e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ coverage .lock-wscript build +docs # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git diff --git a/package.json b/package.json index a2000ed..dd85794 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "test": "aegir test", "test:node": "aegir test --target node", "test:browser": "aegir test --target browser", + "test:types": "npx tsc", "release": "aegir release", "release-minor": "aegir release --type minor", "release-major": "aegir release --type major", @@ -27,11 +28,13 @@ "bugs": "https://github.com/multiformats/js-mafmt/issues", "homepage": "https://github.com/multiformats/js-mafmt#readme", "devDependencies": { - "aegir": "^20.0.0", + "@types/chai": "^4.2.8", + "@types/mocha": "^7.0.1", + "aegir": "^20.6.0", "chai": "^4.2.0" }, "dependencies": { - "multiaddr": "^7.0.0" + "multiaddr": "^7.3.0" }, "contributors": [ "Alan Shaw ", diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..34fcef8 --- /dev/null +++ b/src/index.d.ts @@ -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; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..df493db --- /dev/null +++ b/tsconfig.json @@ -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" + ] +}