瀏覽代碼

Avoid using require typing in main package

Steven Silvester 8 年之前
父節點
當前提交
865e88b031
共有 5 個文件被更改,包括 9 次插入5 次删除
  1. 2 1
      package.json
  2. 5 1
      src/codemirror/index.ts
  3. 1 1
      src/tsconfig.json
  4. 0 1
      src/typings.d.ts
  5. 1 1
      test/src/tsconfig.json

+ 2 - 1
package.json

@@ -31,7 +31,7 @@
     "@types/marked": "0.0.28",
     "@types/mathjax": "0.0.31",
     "@types/mocha": "^2.2.32",
-    "@types/requirejs": "^2.1.28",
+    "@types/node": "^6.0.45",
     "@types/sanitize-html": "^1.13.31",
     "awesome-typescript-loader": "^2.2.4",
     "concurrently": "^2.0.0",
@@ -54,6 +54,7 @@
     "karma-remap-coverage": "^0.1.1",
     "karma-sourcemap-loader": "^0.3.7",
     "mocha": "^2.3.4",
+    "node": "0.0.0",
     "raw-loader": "^0.5.1",
     "rimraf": "^2.5.0",
     "style-loader": "^0.13.0",

+ 5 - 1
src/codemirror/index.ts

@@ -15,6 +15,10 @@ import 'codemirror/mode/r/r';
 import 'codemirror/mode/markdown/markdown';
 
 
+// Stub for the require function.
+declare var require: any;
+
+
 /**
  * Load a codemirror mode by file name.
  */
@@ -68,7 +72,7 @@ function requireMode(mode: string | CodeMirror.modespec): Promise<CodeMirror.mod
 
   // Fetch the mode asynchronously.
   return new Promise<CodeMirror.modespec>((resolve, reject) => {
-    (require as any)([`codemirror/mode/${info.mode}/${info.mode}`], () => {
+    require([`codemirror/mode/${info.mode}/${info.mode}`], () => {
       resolve(info);
     });
   });

+ 1 - 1
src/tsconfig.json

@@ -4,7 +4,7 @@
     "noImplicitAny": true,
     "noEmitOnError": true,
     "lib": ["dom", "es5", "es2015.collection", "es2015.promise"],
-    "types": ["mathjax", "requirejs"],
+    "types": ["mathjax"],
     "module": "commonjs",
     "moduleResolution": "node",
     "target": "ES5",

+ 0 - 1
src/typings.d.ts

@@ -7,7 +7,6 @@
  * and the @types typing resolution.
  */
 /// <reference path="../node_modules/@types/mathjax/index.d.ts"/>
-/// <reference path="../node_modules/@types/requirejs/index.d.ts"/>
 /// <reference path="../node_modules/typescript/lib/lib.es2015.promise.d.ts"/>
 /// <reference path="../node_modules/typescript/lib/lib.dom.d.ts"/>
 /// <reference path="../node_modules/typescript/lib/lib.es5.d.ts"/>

+ 1 - 1
test/src/tsconfig.json

@@ -3,7 +3,7 @@
     "noImplicitAny": true,
     "noEmitOnError": true,
     "lib": ["dom", "es5", "es2015.promise"],
-    "types": ["mocha", "expect.js", "requirejs"],
+    "types": ["mocha", "expect.js", "node"],
     "module": "commonjs",
     "moduleResolution": "node",
     "target": "ES5",