Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1241: mark @internals and improve jsdoc #1242

Merged
merged 1 commit into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { fileURLToPath } from 'url'
import type * as _ts from 'typescript'
import { Module, createRequire as nodeCreateRequire, createRequireFromPath as nodeCreateRequireFromPath } from 'module'
import type _createRequire from 'create-require'
// tslint:disable-next-line:deprecation
export const createRequire = nodeCreateRequire ?? nodeCreateRequireFromPath ?? require('create-require') as typeof _createRequire

/** @internal */
export const createRequire = nodeCreateRequire ?? nodeCreateRequireFromPath ?? require('create-require') as typeof _createRequire // tslint:disable-line:deprecation

export { createRepl, CreateReplOptions, ReplService } from './repl'

Expand Down Expand Up @@ -343,6 +344,7 @@ export interface TypeInfo {
/**
* Default register options, including values specified via environment
* variables.
* @internal
*/
export const DEFAULTS: RegisterOptions = {
cwd: env.TS_NODE_CWD ?? env.TS_NODE_DIR, // tslint:disable-line:deprecation
Expand Down Expand Up @@ -435,7 +437,7 @@ export interface Service {
/**
* Re-export of `Service` interface for backwards-compatibility
* @deprecated use `Service` instead
* @see Service
* @see {Service}
*/
export type Register = Service

Expand Down
10 changes: 10 additions & 0 deletions src/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export interface CreateReplOptions {
stderr?: NodeJS.WritableStream
}

/**
* Create a ts-node REPL instance.
*
* Usage example:
*
* const repl = tsNode.createRepl()
* const service = tsNode.create({...repl.evalAwarePartialHost})
* repl.setService(service)
* repl.start()
*/
export function createRepl (options: CreateReplOptions = {}) {
let service = options.service
const state = options.state ?? new EvalState(join(process.cwd(), EVAL_FILENAME))
Expand Down