Socket
Socket
Sign inDemoInstall

ts-node

Package Overview
Dependencies
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-node - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

39

dist/bin.js

@@ -37,3 +37,13 @@ #!/usr/bin/env node

cache: index_1.DEFAULTS.cache,
files: index_1.DEFAULTS.files
files: index_1.DEFAULTS.files,
pretty: index_1.DEFAULTS.pretty,
typeCheck: index_1.DEFAULTS.typeCheck,
transpileOnly: index_1.DEFAULTS.transpileOnly,
cacheDirectory: index_1.DEFAULTS.cacheDirectory,
ignore: index_1.DEFAULTS.ignore,
project: index_1.DEFAULTS.project,
skipIgnore: index_1.DEFAULTS.skipIgnore,
skipProject: index_1.DEFAULTS.skipProject,
compiler: index_1.DEFAULTS.compiler,
ignoreDiagnostics: index_1.DEFAULTS.ignoreDiagnostics
}

@@ -51,14 +61,14 @@ });

var service = index_1.register({
files: argv.files || index_1.DEFAULTS.files,
pretty: argv.pretty || index_1.DEFAULTS.pretty,
typeCheck: argv.typeCheck || index_1.DEFAULTS.typeCheck,
transpileOnly: argv.transpileOnly || index_1.DEFAULTS.transpileOnly,
cache: argv.cache || index_1.DEFAULTS.cache,
cacheDirectory: argv.cacheDirectory || index_1.DEFAULTS.cacheDirectory,
ignore: argv.ignore || index_1.DEFAULTS.ignore,
project: argv.project || index_1.DEFAULTS.project,
skipIgnore: argv.skipIgnore || index_1.DEFAULTS.skipIgnore,
skipProject: argv.skipProject || index_1.DEFAULTS.skipProject,
compiler: argv.compiler || index_1.DEFAULTS.compiler,
ignoreDiagnostics: argv.ignoreDiagnostics || index_1.DEFAULTS.ignoreDiagnostics,
files: argv.files,
pretty: argv.pretty,
typeCheck: argv.typeCheck,
transpileOnly: argv.transpileOnly,
cache: argv.cache,
cacheDirectory: argv.cacheDirectory,
ignore: argv.ignore,
project: argv.project,
skipIgnore: argv.skipIgnore,
skipProject: argv.skipProject,
compiler: argv.compiler,
ignoreDiagnostics: argv.ignoreDiagnostics,
compilerOptions: index_1.parse(argv.compilerOptions) || index_1.DEFAULTS.compilerOptions,

@@ -300,3 +310,4 @@ readFile: isEval ? readFileEval : undefined,

1160,
1161 // "Unterminated regular expression literal."
1161,
2355 // "A function whose declared type is neither 'void' nor 'any' must return a value."
]);

@@ -303,0 +314,0 @@ /**

@@ -339,2 +339,3 @@ "use strict";

delete config.options.outFile;
delete config.options.composite;
delete config.options.declarationDir;

@@ -341,0 +342,0 @@ delete config.options.declarationMap;

@@ -189,2 +189,8 @@ "use strict";

});
it('should allow custom typings', function (done) {
child_process_1.exec(BIN_EXEC + " tests/custom-types", function (err, stdout) {
chai_1.expect(err).to.match(/Error: Cannot find module 'does-not-exist'/);
return done();
});
});
});

@@ -191,0 +197,0 @@ describe('register', function () {

{
"name": "ts-node",
"version": "7.0.0",
"version": "7.0.1",
"description": "TypeScript execution environment and REPL for node.js, with source map support",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -10,4 +10,2 @@ # ![TypeScript Node](logo.svg)

**Tip:** `ts-node` differs slightly from `tsc`. It will not load files from `tsconfig.json` by default. Instead, `ts-node` starts from the input file and discovers the rest of the project tree through imports and references.
## Installation

@@ -96,4 +94,8 @@

**TypeScript Node** works by registering the TypeScript compiler for `.tsx?` and `.jsx?` extension (when `allowJs == true`). When node.js has an extension registered (via `require.extensions`), it will use the extension internally for module resolution. When an extension is unknown to node.js, it handles the file as `.js` (JavaScript).
**TypeScript Node** works by registering the TypeScript compiler for `.tsx?` and `.jsx?` (when `allowJs == true`) extensions. When node.js has an extension registered (via `require.extensions`), it will use the extension internally for module resolution. When an extension is unknown to node.js, it handles the file as `.js` (JavaScript). By default, **TypeScript Node** avoids compiling files in `/node_modules/` for three reasons:
1. Modules should always be published in a format node.js can consume
2. Transpiling the entire dependency tree will make your project slower
3. Differing behaviours between TypeScript and node.js (e.g. ES2015 modules) can result in a project that works until you decide to support a feature natively from node.js
**P.S.** This means if you don't register an extension, it is compiled as JavaScript. When `ts-node` is used with `allowJs`, JavaScript files are transpiled using the TypeScript compiler.

@@ -126,14 +128,14 @@

* `-T, --transpileOnly` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`)
* `-T, --transpileOnly` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`, default: `false`)
* `--cacheDirectory` Configure the output file cache directory (`TS_NODE_CACHE_DIRECTORY`)
* `-I, --ignore [pattern]` Override the path patterns to skip compilation (`TS_NODE_IGNORE`)
* `-I, --ignore [pattern]` Override the path patterns to skip compilation (`TS_NODE_IGNORE`, default: `/node_modules/`)
* `-P, --project [path]` Path to TypeScript JSON project file (`TS_NODE_PROJECT`)
* `-C, --compiler [name]` Specify a custom TypeScript compiler (`TS_NODE_COMPILER`)
* `-C, --compiler [name]` Specify a custom TypeScript compiler (`TS_NODE_COMPILER`, default: `typescript`)
* `-D, --ignoreDiagnostics [code]` Ignore TypeScript warnings by diagnostic code (`TS_NODE_IGNORE_DIAGNOSTICS`)
* `-O, --compilerOptions [opts]` JSON object to merge with compiler options (`TS_NODE_COMPILER_OPTIONS`)
* `--files` Load files from `tsconfig.json` on startup (`TS_NODE_FILES`)
* `--pretty` Use pretty diagnostic formatter (`TS_NODE_PRETTY`)
* `--no-cache` Disable the local TypeScript Node cache (`TS_NODE_CACHE`)
* `--skip-project` Skip project config resolution and loading (`TS_NODE_SKIP_PROJECT`)
* `--skip-ignore` Skip ignore checks (`TS_NODE_SKIP_IGNORE`)
* `--files` Load files from `tsconfig.json` on startup (`TS_NODE_FILES`, default: `false`)
* `--pretty` Use pretty diagnostic formatter (`TS_NODE_PRETTY`, default: `false`)
* `--no-cache` Disable the local TypeScript Node cache (`TS_NODE_CACHE`, default: `true`)
* `--skip-project` Skip project config resolution and loading (`TS_NODE_SKIP_PROJECT`, default: `false`)
* `--skip-ignore` Skip ignore checks (`TS_NODE_SKIP_IGNORE`, default: `false`)

@@ -146,2 +148,34 @@ ### Programmatic Only Options

## Help! My Types Are Missing!
**TypeScript Node** does _not_ use `files`, `include` or `exclude`, by default. This is because a large majority projects do not use all of the files in a project directory (e.g. `Gulpfile.ts`, runtime vs tests) and parsing every file for types slows startup time. Instead, `ts-node` starts with the script file (e.g. `ts-node index.ts`) and TypeScript resolves dependencies based on imports and references.
For global definitions, you can use [`typeRoots`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types):
```json
{
"compilerOptions": {
"typeRoots" : ["./node_modules/@types", "./typings"]
}
}
```
> A types package is a folder with a file called `index.d.ts` or a folder with a `package.json` that has a types field.
> -- <cite>[TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types)</cite>
For module definitions, you can use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping):
```json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"custom-module-type": ["types/custom-module-type"]
}
}
}
```
**Tip:** If you _must_ use `files`, enable `--files` flags or set `TS_NODE_FILES=true`.
## Watching and Restarting

@@ -148,0 +182,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc