Skip to content

Commit

Permalink
Add poelstra3poc: compiling version of poelstra3 (although it doe…
Browse files Browse the repository at this point in the history
…sn't run, see readme).
  • Loading branch information
poelstra committed Apr 22, 2015
1 parent 366ebb5 commit cd3f4ac
Show file tree
Hide file tree
Showing 21 changed files with 148 additions and 0 deletions.
23 changes: 23 additions & 0 deletions poelstra3poc/README.md
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!
Empty file.
6 changes: 6 additions & 0 deletions poelstra3poc/dist/myprogram.js
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);
2 changes: 2 additions & 0 deletions poelstra3poc/node_modules/mylib/dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions poelstra3poc/node_modules/mylib/dist/index.js

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.

6 changes: 6 additions & 0 deletions poelstra3poc/node_modules/mylib/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions poelstra3poc/node_modules/mylib/ts/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions poelstra3poc/node_modules/mylib/ts/tsconfig.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions poelstra3poc/node_modules/mylib/typings/myutils/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions poelstra3poc/node_modules/myotherlib/dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions poelstra3poc/node_modules/myotherlib/dist/index.js

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.

6 changes: 6 additions & 0 deletions poelstra3poc/node_modules/myotherlib/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions poelstra3poc/node_modules/myotherlib/ts/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions poelstra3poc/node_modules/myotherlib/ts/tsconfig.json

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.

8 changes: 8 additions & 0 deletions poelstra3poc/ts/myprogram.ts
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
19 changes: 19 additions & 0 deletions poelstra3poc/ts/tsconfig.json
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"
]
}

0 comments on commit cd3f4ac

Please sign in to comment.