Skip to content

Commit

Permalink
Move script into src/index.ts (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
danvk committed Jan 20, 2017
1 parent 8693b91 commit 2f66825
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ jspm_packages

# editor
.vscode/

# Generated JS files
src/*.js
src/*.js.map
23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
{
"name": "typings-checker",
"version": "1.0.0",
"description": "",
"main": "typecheck.ts",
"description": "Positive and negative assertions about TypeScript types and errors",
"main": "src/index.js",
"scripts": {
"test": "tsc && ./update-tests.sh"
"test": "./update-tests.sh"
},
"bin": {
"typings-checker": "src/index.js"
},
"author": "Dan Vanderkam (danvdk@gmail.com)",
"license": "ISC",
"tags": [
"typescript",
"typings",
"definitelytyped"
],
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/lodash": "^4.14.47",
"@types/mocha": "^2.2.36",
"@types/node": "^7.0.0",
"@types/underscore": "^1.7.36",
"chai": "^3.5.0",
"mocha": "^3.2.0",
"ts-node": "^2.0.0",
"typescript": "^2.1.4"
"ts-node": "^2.0.0"
},
"dependencies": {
"@types/lodash": "^4.14.47",
"@types/underscore": "^1.7.36",
"lodash": "^4.17.4",
"tslint": "^4.3.1",
"underscore": "^1.8.3"
"typescript": "^2.1.4"
}
}
12 changes: 11 additions & 1 deletion typecheck.ts → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#!/usr/bin/env ts-node
/**
* This script reads a TypeScript file and verifies that it produces the expected types and errors.
*
* Usage:
*
* typings-checker yourtsfile.ts
*
* The exit code indicates whether all assertions passed.
*/

import * as ts from 'typescript';
import * as _ from 'lodash';
import { scanAllTokens } from 'tslint';

const [,, tsFile] = process.argv;

// TODO: read options from a tsconfig.json file.
const options: ts.CompilerOptions = {};
const host = ts.createCompilerHost(options, true);

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "es5",
"noImplicitAny": true,
"sourceMap": true,
"noEmit": true
"noEmit": false
},
"exclude": [
"sample.ts",
Expand Down
6 changes: 5 additions & 1 deletion update-tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
set -o errexit
tsc
set +o errexit

for test in $(find tests -name '*.ts'); do
./typecheck.ts $test > $test.out 2>&1
node src/index.js $test > $test.out 2>&1
done

# This shows changes and sets the exit code.
Expand Down

0 comments on commit 2f66825

Please sign in to comment.