-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
poelstra3poc
: compiling version of poelstra3
(although it doe…
…sn't run, see readme).
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
This tree shows an almost fully working example of having a mix of native and non-Typescript packages. | ||
|
||
It is a direct copy of `poelstra3`, and is a proof-of-concept of how external module resolution would work if | ||
https://github.com/Microsoft/TypeScript/issues/2338 and https://github.com/Microsoft/TypeScript/issues/2839 is implemented. | ||
|
||
It has the following relevant changes compared to `poelstra3`: | ||
* `import ... = require("...");` statements were rewritten from e.g. `myutils` to its 'resolved' equivalent `../typings/myutils/index` | ||
|
||
It compiles! (using tsc 1.5.0-alpha) | ||
|
||
In contrast to `poelstra2poc`, this one doesn't run in practice, because of: | ||
``` | ||
$ node ../dist/myprogram.js | ||
module.js:340 | ||
throw err; | ||
^ | ||
Error: Cannot find module '../typings/myutils/index' | ||
``` | ||
|
||
That's to be expected, because we made `tsc` happy by resolving to the typings, but that's not where the `.js` lives. | ||
|
||
However, hovering over the `a` and `b` vars in `myprogram.ts` shows correct types! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var mylib = require("../node_modules/mylib/dist/index"); | ||
var myotherlib = require('../node_modules/myotherlib/dist/index'); | ||
var a = mylib.myfunc(); | ||
var b = myotherlib.myotherfunc(); | ||
console.log(typeof a.foo); | ||
console.log(typeof b.foo); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import mylib = require("../node_modules/mylib/dist/index"); | ||
import myotherlib = require('../node_modules/myotherlib/dist/index'); | ||
|
||
var a = mylib.myfunc(); | ||
var b = myotherlib.myotherfunc(); | ||
|
||
console.log(typeof a.foo); // string | ||
console.log(typeof b.foo); // number |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "1.4.1", | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"noImplicitAny": false, | ||
"removeComments": true, | ||
"noLib": false, | ||
"outDir": "../dist", | ||
"declaration": true | ||
}, | ||
"filesGlob": [ | ||
"./**/*.ts", | ||
"!./node_modules/**/*.ts" | ||
], | ||
"files": [ | ||
"./myprogram.ts" | ||
] | ||
} |