Skip to content

can i create a drop-in repl with variables in scope from preloaded files? #1279

Description

@adccb

basically i have a new typescript project, and i'd love to be able to start up a repl and instantly have access to project types defined in a file. specifically, things defined like:

export type Dict<T> = Record<string, T>;
export type StringDict = Dict<string>;
export type Collection<T> = T[] | Dict<T>;

i'd love to be able to say ts-node -r src/types/index.ts and have it create a repl where i can just use Dict. is this possible?

Activity

  1. adccb commented on Mar 19, 2021

    @adccb
    Author

    for clarity, i've tried setting up a repl_setup.ts that looks like this:

    export * as types from './src/types/index'

    but it doesn't look like these variables are populated in the repl at all—

    > ts-node -r ./src/repl_setup.ts
    
    > types.Maybe
    [eval].ts:1:1 - error TS2304: Cannot find name 'types'.
    
    1 types.Maybe
      ~~~~~
    

    is there some other way to do this?

  2. locked and limited conversation to collaborators on Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions