Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/deno/cli/js/compiler_sourcefile.ts>SourceFile

A modern runtime for JavaScript and TypeScript.
Go to Latest
class SourceFile
import { SourceFile } from "https://deno.land/x/deno@v0.30.0/cli/js/compiler_sourcefile.ts";

A self registering abstraction of source files.

Constructors

new
SourceFile(json: SourceFileJson)

Properties

extension: ts.Extension
filename: string
optional
importedFiles: Array<[string, string]>

An array of tuples which represent the imports for the source file. The first element is the one that will be requested at compile time, the second is the one that should be actually resolved. This provides the feature of type directives for Deno.

mediaType: MediaType
processed: boolean
optional
sourceCode: string
optional
tsSourceFile: ts.SourceFile
url: string

Methods

cache(moduleSpecifier: string, containingFile?: string): void

Cache the source file to be able to be retrieved by moduleSpecifier and containingFile.

imports(): Array<[string, string]>

Process the imports for the file and return them.

Static Properties

private
_moduleCache: Map<string, SourceFile>

A cache of all the source files which have been loaded indexed by the url.

private
_specifierCache: Map<string, Map<string, SourceFile>>

A cache of source files based on module specifiers and containing files which is used by the TypeScript compiler to resolve the url

Static Methods

get(url: string): SourceFile | undefined

Retrieve a SourceFile based on a url

getUrl(moduleSpecifier: string, containingFile: string): string | undefined

Retrieve a SourceFile based on a moduleSpecifier and containingFile or return undefined if not preset.

has(url: string): boolean

Determine if a source file exists or not