Explorar o código

Add typescript for type checking

John Lees-Miller %!s(int64=6) %!d(string=hai) anos
pai
achega
1a38f4e4ff

+ 0 - 3
libraries/o-error/.eslintrc.json

@@ -17,9 +17,6 @@
       "files": ["test/**/*.js"],
       "env": {
         "mocha": true
-      },
-      "globals": {
-        "expect": "readonly"
       }
     }
   ]

+ 12 - 0
libraries/o-error/package-lock.json

@@ -36,6 +36,12 @@
       "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
       "dev": true
     },
+    "@types/node": {
+      "version": "13.13.2",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.2.tgz",
+      "integrity": "sha512-LB2R1Oyhpg8gu4SON/mfforE525+Hi/M1ineICEDftqNVTyFg1aRIeGuTvXAoWHc4nbrFncWtJgMmoyRvuGh7A==",
+      "dev": true
+    },
     "acorn": {
       "version": "7.1.1",
       "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz",
@@ -2207,6 +2213,12 @@
       "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
       "dev": true
     },
+    "typescript": {
+      "version": "3.8.3",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
+      "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
+      "dev": true
+    },
     "uri-js": {
       "version": "4.2.2",
       "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",

+ 5 - 2
libraries/o-error/package.json

@@ -5,12 +5,14 @@
   "main": "index.js",
   "scripts": {
     "lint": "eslint .",
-    "test": "mocha --require test/support"
+    "test": "mocha",
+    "typecheck": "tsc --allowJs --checkJs --noEmit --moduleResolution node --target ES6 *.js test/**/*.js"
   },
   "author": "Overleaf (https://www.overleaf.com)",
   "license": "MIT",
   "repository": "github:overleaf/o-error",
   "devDependencies": {
+    "@types/node": "^13.13.2",
     "chai": "^3.3.0",
     "eslint": "^6.8.0",
     "eslint-config-prettier": "^6.10.1",
@@ -24,6 +26,7 @@
     "eslint-plugin-promise": "^4.2.1",
     "eslint-plugin-standard": "^4.0.1",
     "mocha": "^7.1.1",
-    "prettier": "^2.0.2"
+    "prettier": "^2.0.2",
+    "typescript": "^3.8.3"
   }
 }

+ 2 - 0
libraries/o-error/test/http.test.js

@@ -1,3 +1,5 @@
+const { expect } = require('chai')
+
 const HttpErrors = require('../http')
 
 const { expectError } = require('./support')

+ 1 - 0
libraries/o-error/test/o-error-util.test.js

@@ -1,4 +1,5 @@
 const { getFullInfo, getFullStack, hasCauseInstanceOf } = require('..')
+const { expect } = require('chai')
 
 describe('OError.getFullInfo', function () {
   it('works on a normal error', function () {

+ 2 - 0
libraries/o-error/test/o-error.test.js

@@ -1,3 +1,5 @@
+const { expect } = require('chai')
+
 const OError = require('..')
 const { expectError } = require('./support')
 

+ 2 - 4
libraries/o-error/test/support/index.js

@@ -1,8 +1,6 @@
-'use strict'
+const { expect } = require('chai')
 
-var chai = require('chai')
-
-global.expect = chai.expect
+const OError = require('../..')
 
 exports.expectError = function OErrorExpectError(e, expected) {
   // should set the name to the error's name