diff --git a/.gitignore b/.gitignore
index 7cd5b1b..4fe241a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
/node_modules/
/build/
-/typings/
+/src/typings/
npm-debug.log
\ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 98d149b..9c7a78c 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -9,13 +9,13 @@
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
- "program": "build/app.js",
+ "program": "${workspaceRoot}/build/app.js",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
- "cwd": ".",
+ "cwd": "${workspaceRoot}",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Optional arguments passed to the runtime executable.
@@ -25,7 +25,7 @@
// Use JavaScript source maps (if they exist).
"sourceMaps": true,
// If JavaScript source maps are enabled, the generated code is expected in this directory.
- "outDir": "build"
+ "outDir": "${workspaceRoot}/build"
},
{
"name": "Attach",
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 5a73a75..9a03ebb 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -3,16 +3,13 @@
"command": "npm",
"isShellCommand": true,
"showOutput": "silent",
+ "args": ["run"],
"tasks": [
{
"taskName": "build",
- "args": ["run"],
"isBuildCommand": true,
- "problemMatcher": {
- "base": "$tsc",
- "fileLocation": ["relative", "${workspaceRoot}/src"]
- }
+ "problemMatcher": "$tsc"
},
{
"taskName": "test",
diff --git a/README.md b/README.md
index 5c15d77..48b04dd 100644
--- a/README.md
+++ b/README.md
@@ -17,27 +17,28 @@ The project currently provides the following features:
.vscode/
launch.json # Defines launch tasks for debugging etc.
tasks.json # Defines tasks available e.g. build & test
-
-custom_typings/ # Place your custom typings within this directory
- tsd.d.ts # Custom typings should be added to this file, e.g.:
- # ///
+
+build/ # The output directory of JavaScript files
+ # when built from TypeScript
src/ # The root of all TypeScript source code
- lib/
+ app/
+ app.ts # The main entry point for the project.
mymodule.ts # A sample module
test/
app.test.ts # A sample test
-
- _ref.d.ts # The root type definition file.
- # Reference this in all your TypeScript files.
+ app.test.ts # A sample module test with sinon spies
+
+ typings/ # Typings downloaded using the typings command
- app.ts # The main entry point for the project.
+ custom.d.ts # An example of custom ambient typings
+
tsconfig.json # TypeScript compilation settings
+ typings.json # TypeScript package definition file for typings
package.json
README.md
-tsd.json # TypeScript package definition file for tsd
```
## Getting Started
@@ -51,37 +52,41 @@ This repository is ready for you to clone and start building your code around it
$ npm install
```
-4. You will need [`tsd`][tsd] to allow the TypeScript to compile without errors. It's recommended to install this globally:
+4. You will need [`typings`][typings] to allow the TypeScript to compile without errors. It's recommended to install this globally:
```bash
- $ npm install tsd -g
+ $ npm install typings -g
```
-5. Run `tsd install` to fetch the required module type definitions defined in `tsd.json`:
+5. Change to the `src` directory and run `typings install` to fetch the required module type definitions defined in `typings.json`:
```bash
+ $ cd src
+
# if installed globally (recommended)
- $ tsd install
+ $ typings install
# otherwise
- $ ./node_modules/.bin/tsd install
+ $ ../node_modules/.bin/typings install
```
### Building
-1. Open VSCode and select the root of the repository as the project folder
+1. Open VSCode, hit CTRL/Cmd+Shift+P, type `open folder` and select the root of this repository
2. Build with one of the following shortcuts:
- * Hitting CTRL/Cmd+Shift+B to build, which is declared in the `.settings/tasks.json` file with the `isBuildCommand` marker
+ * Press CTRL/Cmd+Shift+B to build, which is declared in the `.settings/tasks.json` file with the `isBuildCommand` marker
* Press CTRL/Cmd+Shift+P and select the `Tasks: Run Build Task` option
* Press CTRL/Cmd+Shift+P, delete the `>` and type `task build`
3. If there were no errors, you should see a new directory, `build`, in the root with the following content:
```
build/
- lib/
- mymodule.js
+ app/
+ app.js
+ app.js.map
+ mymodule.js
mymodule.js.map
test/
app.test.js
app.test.js.map
- app.js
- app.js.map
+ mymodule.test.js
+ mymodule.test.js.map
```
### Error Navigation
@@ -90,7 +95,7 @@ After building or testing, errors are captured (defined in the `.settings/tasks.
Your `.ts` files have been compiled to `.js` files within the `build` directory, and each should have a `.js.map` _sourcemap_ file alongside it to allow stack traces to correctly report the line in the original file. See [this StackOverflow article][sourcemapquestion] for an overview of what a sourcemap is.
### Testing
-There's a sample test located in the `test` folder. You can run them by hitting CTRL/Command+Shift+T (or use the `Tasks` menu and run `Tasks: Run Test Task`)
+There are sample tests located in the `test` folder. You can run them by hitting CTRL/Command+Shift+T (or use the `Tasks` menu and run `Tasks: Run Test Task`)
### Running and Debugging
To run the project in debug mode, simply hit F5! Place breakpoints in your TypeScript code and view them in the debugger (CTRL+Shift+D or Cmd+Shift+D).
@@ -104,4 +109,4 @@ MIT
[vscode]: https://code.visualstudio.com/
[nodejsdownload]: https://nodejs.org/download/
[sourcemapquestion]: http://stackoverflow.com/questions/21719562/javascript-map-files-javascript-source-maps
-[tsd]: https://www.npmjs.com/package/tsd
+[typings]: https://www.npmjs.com/package/typings
diff --git a/custom_typings/tsd.d.ts b/custom_typings/tsd.d.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/package.json b/package.json
index 8501af0..5db20b6 100644
--- a/package.json
+++ b/package.json
@@ -1,21 +1,22 @@
{
- "name": "vscode-typescript-example",
+ "name": "vscode-typescript-boilerplate",
"version": "0.1.0",
"description": "A project skeleton for TypeScript development in Visual Studio Code.",
- "main": "build/app.js",
+ "main": "build/app/app.js",
"scripts": {
- "build": "cd src && tsc",
- "test": "mocha build/test --require source-map-support/register",
+ "build": "tsc -p src/ || true",
+ "test": "mocha build/test --require source-map-support/register || true",
"clean": "rimraf build"
},
"repository": {
"type": "git",
- "url": "git+https://github.com/codesleuth/vscode-typescript-example.git"
+ "url": "git+https://github.com/codesleuth/vscode-typescript-boilerplate.git"
},
"keywords": [
"vscode",
"typescript",
"example",
+ "boilerplate",
"project",
"skeleton",
"debug",
@@ -26,17 +27,18 @@
"author": "David Wood (http://www.codesleuth.co.uk/)",
"license": "MIT",
"bugs": {
- "url": "https://github.com/codesleuth/vscode-typescript-example/issues"
+ "url": "https://github.com/codesleuth/vscode-typescript-boilerplate/issues"
},
- "homepage": "https://github.com/codesleuth/vscode-typescript-example#readme",
+ "homepage": "https://github.com/codesleuth/vscode-typescript-boilerplate#readme",
"private": true,
"devDependencies": {
- "mocha": "^2.2.5",
- "rimraf": "^2.4.3",
- "tsd": "^0.6.3",
- "typescript": "^1.5.3"
+ "mocha": "^2.4.5",
+ "rimraf": "^2.5.2",
+ "sinon": "^1.17.3",
+ "typescript": "^1.8.9",
+ "typings": "^0.7.9"
},
"dependencies": {
- "source-map-support": "^0.3.2"
+ "source-map-support": "^0.4.0"
}
}
diff --git a/src/_ref.d.ts b/src/_ref.d.ts
deleted file mode 100644
index e7504d3..0000000
--- a/src/_ref.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-///
-///
\ No newline at end of file
diff --git a/src/app.ts b/src/app/app.ts
similarity index 52%
rename from src/app.ts
rename to src/app/app.ts
index 0bdfd13..3e6a804 100644
--- a/src/app.ts
+++ b/src/app/app.ts
@@ -1,6 +1,6 @@
import 'source-map-support/register'
-import mymodule = require('./lib/mymodule')
+import {SayGoodbye} from './mymodule'
console.log('Hey there, VSCode user!')
-mymodule.SayGoodbye();
\ No newline at end of file
+SayGoodbye(console.log)
\ No newline at end of file
diff --git a/src/app/mymodule.ts b/src/app/mymodule.ts
new file mode 100644
index 0000000..340b083
--- /dev/null
+++ b/src/app/mymodule.ts
@@ -0,0 +1,3 @@
+export function SayGoodbye(log: (s: string) => void) {
+ log("Goodbye :(")
+}
\ No newline at end of file
diff --git a/src/custom.d.ts b/src/custom.d.ts
new file mode 100644
index 0000000..e916740
--- /dev/null
+++ b/src/custom.d.ts
@@ -0,0 +1,8 @@
+declare module "some_module" {
+ function some_module(string: any): void;
+
+ module some_module {
+ }
+
+ export = some_module;
+}
\ No newline at end of file
diff --git a/src/lib/mymodule.ts b/src/lib/mymodule.ts
deleted file mode 100644
index e6b8302..0000000
--- a/src/lib/mymodule.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-///
-
-export function SayGoodbye() {
- console.log("Goodbye :(")
-}
\ No newline at end of file
diff --git a/src/test/app.test.ts b/src/test/app.test.ts
index 393b6ec..72e1f6d 100644
--- a/src/test/app.test.ts
+++ b/src/test/app.test.ts
@@ -1,6 +1,4 @@
-///
-
-import assert = require('assert')
+import * as assert from 'assert'
describe('Some suite', () => {
diff --git a/src/test/mymodule.test.ts b/src/test/mymodule.test.ts
new file mode 100644
index 0000000..3dbdd10
--- /dev/null
+++ b/src/test/mymodule.test.ts
@@ -0,0 +1,17 @@
+import * as sinon from 'sinon'
+import {SayGoodbye} from '../app/mymodule'
+
+describe('My Module', () => {
+
+ describe('#SayGoodbye', () => {
+
+ it('should say goodbye', () => {
+ let logSpy = sinon.spy()
+ SayGoodbye(logSpy)
+
+ sinon.assert.calledWith(logSpy, 'Goodbye :(')
+ })
+
+ })
+
+})
\ No newline at end of file
diff --git a/src/tsconfig.json b/src/tsconfig.json
index 9648bac..f66f233 100644
--- a/src/tsconfig.json
+++ b/src/tsconfig.json
@@ -1,9 +1,13 @@
{
"compilerOptions": {
- "target": "ES5",
+ "target": "es6",
"module": "commonjs",
"sourceMap": true,
"outDir": "../build/",
"removeComments": true
- }
+ },
+ "exclude": [
+ "typings/browser.d.ts",
+ "typings/browser"
+ ]
}
\ No newline at end of file
diff --git a/src/typings.json b/src/typings.json
new file mode 100644
index 0000000..c7e51ae
--- /dev/null
+++ b/src/typings.json
@@ -0,0 +1,11 @@
+{
+ "name": "vscode-typescript-boilerplate",
+ "version": false,
+ "dependencies": {
+ "sinon": "registry:npm/sinon#1.16.0+20160309002336"
+ },
+ "ambientDependencies": {
+ "mocha": "registry:dt/mocha#2.2.5+20160317120654",
+ "node": "registry:dt/node#4.0.0+20160319033040"
+ }
+}
diff --git a/tsd.json b/tsd.json
deleted file mode 100644
index 814ed14..0000000
--- a/tsd.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "version": "v4",
- "repo": "borisyankov/DefinitelyTyped",
- "ref": "master",
- "path": "typings",
- "bundle": "typings/tsd.d.ts",
- "installed": {
- "mocha/mocha.d.ts": {
- "commit": "e5de5c4daf8cdc33ed60704cd6e8021c99a89f92"
- },
- "node/node.d.ts": {
- "commit": "e5de5c4daf8cdc33ed60704cd6e8021c99a89f92"
- }
- }
-}