Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TypeStrong/ts-node
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.4
Choose a base ref
...
head repository: TypeStrong/ts-node
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.5
Choose a head ref
  • 7 commits
  • 6 files changed
  • 3 contributors

Commits on May 8, 2017

  1. Copy the full SHA
    cc3bf22 View commit details

Commits on May 12, 2017

  1. Update yn default option

    blakeembrey committed May 12, 2017
    Copy the full SHA
    d018300 View commit details

Commits on May 17, 2017

  1. Copy the full SHA
    b751a56 View commit details

Commits on Jun 2, 2017

  1. Copy the full SHA
    633d537 View commit details
  2. Copy the full SHA
    7dfb3e3 View commit details

Commits on Jun 6, 2017

  1. Add --inspect-brk to known flags (#343)

    Deilan authored and blakeembrey committed Jun 6, 2017
    Copy the full SHA
    5cf97b1 View commit details
  2. 3.0.5

    blakeembrey committed Jun 6, 2017
    Copy the full SHA
    c18331a View commit details
Showing with 37 additions and 34 deletions.
  1. +7 −7 .travis.yml
  2. +5 −4 package.json
  3. +7 −3 src/_bin.ts
  4. +1 −0 src/bin.ts
  5. +16 −19 src/index.ts
  6. +1 −1 typings.json
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -15,14 +15,14 @@ script:
- npm run test-cov

env:
- NODE=stable TYPESCRIPT=typescript@1.6
- NODE=stable TYPESCRIPT=typescript@1.7
- NODE=stable TYPESCRIPT=typescript@1.8
- NODE=stable TYPESCRIPT=typescript@2.0
- NODE=stable TYPESCRIPT=typescript@2.1
- NODE=6 TYPESCRIPT=typescript@1.6
- NODE=6 TYPESCRIPT=typescript@1.7
- NODE=6 TYPESCRIPT=typescript@1.8
- NODE=6 TYPESCRIPT=typescript@2.0
- NODE=6 TYPESCRIPT=typescript@2.1
- NODE=4 TYPESCRIPT=typescript@latest
- NODE=stable TYPESCRIPT=typescript@latest
- NODE=stable TYPESCRIPT=typescript@next
- NODE=6 TYPESCRIPT=typescript@latest
- NODE=6 TYPESCRIPT=typescript@next

node_js:
- stable
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "ts-node",
"version": "3.0.4",
"version": "3.0.5",
"preferGlobal": true,
"description": "TypeScript execution environment and REPL for node",
"main": "dist/index.js",
"bin": {
"ts-node": "dist/bin.js"
"ts-node": "dist/bin.js",
"_ts-node": "dist/_bin.js"
},
"files": [
"dist/",
@@ -49,7 +50,7 @@
},
"homepage": "https://github.com/TypeStrong/ts-node",
"devDependencies": {
"chai": "^3.0.0",
"chai": "^4.0.1",
"istanbul": "^0.4.0",
"mocha": "^3.0.0",
"ntypescript": "^1.201507091536.1",
@@ -71,6 +72,6 @@
"source-map-support": "^0.4.0",
"tsconfig": "^6.0.0",
"v8flags": "^2.0.11",
"yn": "^1.2.0"
"yn": "^2.0.0"
}
}
10 changes: 7 additions & 3 deletions src/_bin.ts
Original file line number Diff line number Diff line change
@@ -281,9 +281,13 @@ function startRepl () {
useGlobal: false
})

const undo = appendEval('')
// Hard fix for TypeScript forcing `Object.defineProperty(exports, ...)`.
appendEval('exports = module.exports\n')

repl.on('reset', undo)
// Bookmark the point where we should reset the REPL state.
const reset = appendEval('')

repl.on('reset', reset)

repl.defineCommand('type', {
help: 'Check the type of a TypeScript identifier',
@@ -294,7 +298,7 @@ function startRepl () {
}

const undo = appendEval(identifier)
const { name, comment } = service.getTypeInfo(EVAL_PATH, EVAL_INSTANCE.input.length)
const { name, comment } = service.getTypeInfo(EVAL_INSTANCE.input, EVAL_PATH, EVAL_INSTANCE.input.length)

undo()

1 change: 1 addition & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ v8flags(function (err, v8flags) {
'--debug',
'--debug-brk',
'--inspect',
'--inspect-brk',
'--nolazy',
'--no-deprecation',
'--log-timer-events',
35 changes: 16 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ export interface TypeInfo {
const DEFAULTS = {
getFile,
fileExists,
cache: process.env['TS_NODE_CACHE'] ? yn(process.env['TS_NODE_CACHE']) : true,
cache: yn(process.env['TS_NODE_CACHE'], { default: true }),
cacheDirectory: process.env['TS_NODE_CACHE_DIRECTORY'],
disableWarnings: yn(process.env['TS_NODE_DISABLE_WARNINGS']),
compiler: process.env['TS_NODE_COMPILER'],
@@ -116,7 +116,7 @@ export interface Register {
cwd: string
extensions: string[]
compile (code: string, fileName: string, lineOffset?: number): string
getTypeInfo (fileName: string, position: number): TypeInfo
getTypeInfo (code: string, fileName: string, position: number): TypeInfo
}

/**
@@ -146,7 +146,12 @@ export function register (options: Options = {}): Register {
const cacheDirectory = options.cacheDirectory || DEFAULTS.cacheDirectory || getTmpDir()
const compilerOptions = Object.assign({}, DEFAULTS.compilerOptions, options.compilerOptions)
const originalJsHandler = require.extensions['.js']
const cache: Cache = { contents: {}, versions: {}, sourceMaps: {} }

const cache: Cache = {
contents: Object.create(null),
versions: Object.create(null),
sourceMaps: Object.create(null)
}

const ignore = arrify(
(
@@ -244,36 +249,29 @@ export function register (options: Options = {}): Register {
getExtension
)

let getTypeInfo = function (_fileName: string, _position: number): TypeInfo {
let getTypeInfo = function (_code: string, _fileName: string, _position: number): TypeInfo {
throw new TypeError(`No type information available under "--fast" mode`)
}

// Use full language services when the fast option is disabled.
if (!fast) {
// Add the file to the project.
const addVersion = function (fileName: string) {
if (!cache.versions.hasOwnProperty(fileName)) {
cache.versions[fileName] = 1
}
}

// Set the file contents into cache.
const addCache = function (code: string, fileName: string) {
const setCache = function (code: string, fileName: string) {
cache.contents[fileName] = code
cache.versions[fileName] += 1
cache.versions[fileName] = (cache.versions[fileName] + 1) || 1
}

// Create the compiler host for type checking.
const serviceHost = {
getScriptFileNames: () => Object.keys(cache.versions),
getScriptVersion: (fileName: string) => String(cache.versions[fileName]),
getScriptSnapshot (fileName: string) {
if (!cache.contents.hasOwnProperty(fileName)) {
if (!cache.contents[fileName]) {
if (!fileExists(fileName)) {
return undefined
}

cache.contents[fileName] = getFile(fileName)
setCache(getFile(fileName), fileName)
}

return ts.ScriptSnapshot.fromString(cache.contents[fileName])
@@ -327,16 +325,15 @@ export function register (options: Options = {}): Register {
fileExists,
cache,
function (code: string, fileName: string, lineOffset?: number) {
addVersion(fileName)
addCache(code, fileName)
setCache(code, fileName)

return getOutput(code, fileName, lineOffset)
},
getExtension
)

getTypeInfo = function (fileName: string, position: number) {
addVersion(fileName)
getTypeInfo = function (code: string, fileName: string, position: number) {
setCache(code, fileName)

const info = service.getQuickInfoAtPosition(fileName, position)
const name = ts.displayPartsToString(info ? info.displayParts : [])
2 changes: 1 addition & 1 deletion typings.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"tsconfig": "npm:tsconfig",
"v8flags": "registry:npm/v8flags#3.0.0+20161011212142",
"xtend": "registry:npm/xtend#4.0.0+20160211003958",
"yn": "registry:npm/yn#1.2.0+20161006191459"
"yn": "registry:npm/yn#1.3.0+20170508185912"
},
"globalDependencies": {
"node": "registry:env/node#6.0.0+20170213133316"