mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
Support loading additional TS lib files (#3863)
Fixes #3726 This PR provides support for referencing other lib files (like lib.dom.d.ts that are not used by default in Deno.
This commit is contained in:
parent
3d5bed35e0
commit
046bbb2691
22 changed files with 284 additions and 67 deletions
|
@ -26,6 +26,8 @@ export interface SourceFileJson {
|
|||
sourceCode: string;
|
||||
}
|
||||
|
||||
export const ASSETS = "$asset$";
|
||||
|
||||
/** Returns the TypeScript Extension enum for a given media type. */
|
||||
function getExtension(fileName: string, mediaType: MediaType): ts.Extension {
|
||||
switch (mediaType) {
|
||||
|
@ -109,7 +111,7 @@ export class SourceFile {
|
|||
this.processed = true;
|
||||
const files = (this.importedFiles = [] as Array<[string, string]>);
|
||||
|
||||
function process(references: ts.FileReference[]): void {
|
||||
function process(references: Array<{ fileName: string }>): void {
|
||||
for (const { fileName } of references) {
|
||||
files.push([fileName, fileName]);
|
||||
}
|
||||
|
@ -133,7 +135,15 @@ export class SourceFile {
|
|||
process(importedFiles);
|
||||
}
|
||||
process(referencedFiles);
|
||||
process(libReferenceDirectives);
|
||||
// built in libs comes across as `"dom"` for example, and should be filtered
|
||||
// out during pre-processing as they are either already cached or they will
|
||||
// be lazily fetched by the compiler host. Ones that contain full files are
|
||||
// not filtered out and will be fetched as normal.
|
||||
process(
|
||||
libReferenceDirectives.filter(
|
||||
({ fileName }) => !ts.libMap.has(fileName.toLowerCase())
|
||||
)
|
||||
);
|
||||
process(typeReferenceDirectives);
|
||||
return files;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue