@servicenow/sdk - v4.4.1
    Preparing search index...

    Project that holds source files.

    Hierarchy (View Summary)

    Index

    Constructors

    • Initializes a new instance.

      Parameters

      Returns Project

    Accessors

    Methods

    • Adds an existing directory from the path or throws if it doesn't exist.

      Will return the directory if it was already added.

      Parameters

      Returns Directory

      DirectoryNotFoundError when the directory does not exist.

    • Adds an existing directory from the path or returns undefined if it doesn't exist.

      Will return the directory if it was already added.

      Parameters

      Returns Directory | undefined

    • Adds an existing source file from a file path or throws if it doesn't exist.

      Will return the source file if it was already added.

      Parameters

      • filePath: string

        File path to get the file from.

      Returns SourceFile

      FileNotFoundError when the file is not found.

    • Adds a source file from a file path if it exists or returns undefined.

      Will return the source file if it was already added.

      Parameters

      • filePath: string

        File path to get the file from.

      Returns SourceFile | undefined

    • Adds source files based on file globs.

      Parameters

      • fileGlobs: string | readonly string[]

        File glob or globs to add files based on.

      Returns SourceFile[]

      The matched source files.

    • Adds all the source files from the specified tsconfig.json.

      Note that this is done by default when specifying a tsconfig file in the constructor and not explicitly setting the skipAddingFilesFromTsConfig option to true.

      Parameters

      • tsConfigFilePath: string

        File path to the tsconfig.json file.

      Returns SourceFile[]

    • Creates a directory at the specified path.

      Parameters

      • dirPath: string

        Path to create the directory at.

      Returns Directory

    • Creates a source file at the specified file path with the specified text.

      Note: The file will not be created and saved to the file system until .save() is called on the source file.

      Parameters

      Returns SourceFile

      • InvalidOperationError if a source file already exists at the provided file path.
    • Creates a writer with the current manipulation settings.

      Returns CodeBlockWriter

      Generally it's best to use a provided writer, but this may be useful in some scenarios.

    • Asynchronously emits all the source files to the file system as JavaScript files.

      Parameters

      • OptionalemitOptions: EmitOptions

        Optional emit options.

      Returns Promise<EmitResult>

    • Synchronously emits all the source files to the file system as JavaScript files.

      Parameters

      • OptionalemitOptions: EmitOptions

        Optional emit options.

      Returns EmitResult

    • Emits all the source files to memory.

      Parameters

      • OptionalemitOptions: EmitOptions

        Optional emit options.

      Returns MemoryEmitResult

    • Enables logging to the console.

      Parameters

      • Optionalenabled: boolean

        Enabled.

      Returns void

    • Forgets the nodes created in the scope of the passed in block.

      This is an advanced method that can be used to easily "forget" all the nodes created within the scope of the block.

      Type Parameters

      • T = void

      Parameters

      • block: (remember: (...node: Node<tsc.Node>[]) => void) => T

        Block of code to run. Use the remember callback or return a node to remember it.

      Returns T

    • Forgets the nodes created in the scope of the passed in block asynchronously.

      This is an advanced method that can be used to easily "forget" all the nodes created within the scope of the block.

      Type Parameters

      • T = void

      Parameters

      • block: (remember: (...node: Node<tsc.Node>[]) => void) => Promise<T>

        Block of code to run. Use the remember callback or return a node to remember it.

      Returns Promise<T>

    • Formats an array of diagnostics with their color and context into a string.

      Parameters

      • diagnostics: readonly Diagnostic<tsc.Diagnostic>[]

        Diagnostics to get a string of.

      • Optionalopts: { newLineChar?: "\n" | "\r\n" }

      Returns string

    • Gets the specified ambient module symbol or returns undefined if not found.

      Parameters

      • moduleName: string

        The ambient module name with or without quotes.

      Returns Symbol | undefined

    • Gets the specified ambient module symbol or throws if not found.

      Parameters

      • moduleName: string

        The ambient module name with or without quotes.

      • Optionalmessage: string | (() => string)

      Returns Symbol

    • Gets the ambient module symbols (ex. modules in the

      Returns Symbol[]

      folder or node_modules).

    • Gets the compiler options.

      Returns tsc.CompilerOptions

    • Gets the diagnostics found when parsing the tsconfig.json file provided in the project's constructor.

      Returns Diagnostic<tsc.Diagnostic>[]

    • Gets all the directories.

      Returns Directory[]

    • Gets a directory by the specified path or returns undefined if it doesn't exist.

      Parameters

      • dirPath: string

        Directory path.

      Returns Directory | undefined

    • Gets a directory by the specified path or throws if it doesn't exist.

      Parameters

      • dirPath: string

        Path to create the directory at.

      • Optionalmessage: string | (() => string)

      Returns Directory

    • Gets the file system.

      Returns FileSystemHost

    • Gets the language service.

      Returns LanguageService

    • Gets a ts.ModuleResolutionHost for the project.

      Returns ModuleResolutionHost

    • Gets the program.

      Returns Program

    • Gets the directories without a parent.

      Returns Directory[]

    • Gets a source file by a file name or file path. Returns undefined if none exists.

      Parameters

      • fileNameOrPath: string

        File name or path that the path could end with or equal.

      Returns SourceFile | undefined

    • Gets a source file by a search function. Returns undefined if none exists.

      Parameters

      • searchFunction: (file: SourceFile) => boolean

        Search function.

      Returns SourceFile | undefined

    • Gets a source file by a file name or file path. Throws an error if it doesn't exist.

      Parameters

      • fileNameOrPath: string

        File name or path that the path could end with or equal.

      Returns SourceFile

    • Gets a source file by a search function. Throws an error if it doesn't exist.

      Parameters

      • searchFunction: (file: SourceFile) => boolean

        Search function.

      Returns SourceFile

    • Gets all the source files added to the project.

      Returns SourceFile[]

    • Gets all the source files added to the project that match a pattern.

      Parameters

      • globPattern: string

        Glob pattern for filtering out the source files.

      Returns SourceFile[]

    • Gets all the source files added to the project that match the passed in patterns.

      Parameters

      • globPatterns: readonly string[]

        Glob patterns for filtering out the source files.

      Returns SourceFile[]

    • Gets the type checker.

      Returns TypeChecker

    • Removes a source file from the project.

      Parameters

      Returns boolean

      True if removed.

    • Adds the source files the project's source files depend on to the project.

      Returns SourceFile[]

      The added source files.

      • This should be done after source files are added to the project, preferably once to avoid doing more work than necessary.
      • This is done by default when creating a Project and providing a tsconfig.json and not specifying to not add the source files.
    • Saves all the unsaved source files to the file system and deletes all deleted files.

      Returns Promise<void>

    • Synchronously saves all the unsaved source files to the file system and deletes all deleted files.

      Remarks: This might be very slow compared to the asynchronous version if there are a lot of files.

      Returns void