(loader *fileLoader)
| 55 | } |
| 56 | |
| 57 | func (t *parseTask) load(loader *fileLoader) { |
| 58 | t.loaded = true |
| 59 | if t.isForAutomaticTypeDirective { |
| 60 | t.loadAutomaticTypeDirectives(loader) |
| 61 | return |
| 62 | } |
| 63 | if loader.opts.Tracing != nil { |
| 64 | defer loader.opts.Tracing.Push(tracing.PhaseProgram, "findSourceFile", map[string]any{"fileName": t.normalizedFilePath}, false)() |
| 65 | } |
| 66 | redirect := loader.projectReferenceFileMapper.getParseFileRedirect(t) |
| 67 | if redirect != "" { |
| 68 | t.redirect(loader, redirect) |
| 69 | return |
| 70 | } |
| 71 | |
| 72 | if tspath.HasExtension(t.normalizedFilePath) { |
| 73 | compilerOptions := loader.opts.Config.CompilerOptions() |
| 74 | allowNonTsExtensions := compilerOptions.AllowNonTsExtensions.IsTrue() |
| 75 | if !allowNonTsExtensions { |
| 76 | canonicalFileName := tspath.GetCanonicalFileName(t.normalizedFilePath, loader.opts.Host.FS().UseCaseSensitiveFileNames()) |
| 77 | if !loader.isSupportedExtension(canonicalFileName) { |
| 78 | if tspath.HasJSFileExtension(canonicalFileName) { |
| 79 | t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{ |
| 80 | kind: processingDiagnosticKindExplainingFileInclude, |
| 81 | data: &includeExplainingDiagnostic{ |
| 82 | diagnosticReason: t.includeReason, |
| 83 | message: diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, |
| 84 | args: []any{t.normalizedFilePath}, |
| 85 | }, |
| 86 | }) |
| 87 | } else { |
| 88 | t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{ |
| 89 | kind: processingDiagnosticKindExplainingFileInclude, |
| 90 | data: &includeExplainingDiagnostic{ |
| 91 | diagnosticReason: t.includeReason, |
| 92 | message: diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, |
| 93 | args: []any{t.normalizedFilePath, "'" + strings.Join(core.Flatten(loader.supportedExtensions), "', '") + "'"}, |
| 94 | }, |
| 95 | }) |
| 96 | } |
| 97 | return |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | loader.totalFileCount.Add(1) |
| 103 | if t.libFile != nil { |
| 104 | loader.libFileCount.Add(1) |
| 105 | // Default lib files are all scripts; we can safely skip looking up their package.json |
| 106 | // to avoid adding spurious lookups to file watcher tracking. |
| 107 | t.metadata = ast.SourceFileMetaData{ImpliedNodeFormat: core.ResolutionModeCommonJS} |
| 108 | } else { |
| 109 | t.metadata = loader.loadSourceFileMetaData(t.normalizedFilePath) |
| 110 | } |
| 111 | |
| 112 | file := loader.parseSourceFile(t) |
| 113 | if file == nil { |
| 114 | return |
nothing calls this directly
no test coverage detected