MCPcopy Index your code
hub / github.com/angular/angular / parseNgCompilerOptions

Function parseNgCompilerOptions

packages/language-service/src/language_service.ts:949–998  ·  view source on GitHub ↗
(
  project: ts.server.Project,
  host: ConfigurationHost,
  config: LanguageServiceConfig,
)

Source from the content-addressed store, hash-verified

947}
948
949function parseNgCompilerOptions(
950 project: ts.server.Project,
951 host: ConfigurationHost,
952 config: LanguageServiceConfig,
953): CompilerOptions {
954 if (!(project instanceof ts.server.ConfiguredProject)) {
955 return {};
956 }
957 const {options, errors} = readConfiguration(
958 project.getConfigFilePath(),
959 /* existingOptions */ undefined,
960 host,
961 );
962 if (errors.length > 0) {
963 project.setProjectErrors(errors);
964 }
965
966 // Projects loaded into the Language Service often include test files which are not part of the
967 // app's main compilation unit, and these test files often include inline NgModules that declare
968 // components from the app. These declarations conflict with the main declarations of such
969 // components in the app's NgModules. This conflict is not normally present during regular
970 // compilation because the app and the tests are part of separate compilation units.
971 //
972 // As a temporary mitigation of this problem, we instruct the compiler to ignore classes which
973 // are not exported. In many cases, this ensures the test NgModules are ignored by the compiler
974 // and only the real component declaration is used.
975 options.compileNonExportedClasses = false;
976
977 // If `forceStrictTemplates` is true, always enable `strictTemplates`
978 // regardless of its value in tsconfig.json.
979 if (config['forceStrictTemplates'] === true) {
980 options.strictTemplates = true;
981 }
982 if (config['enableSelectorless'] === true) {
983 options['_enableSelectorless'] = true;
984 }
985
986 options['_angularCoreVersion'] = config['angularCoreVersion'];
987
988 if (project.getCurrentDirectory()) {
989 // Attempt to resolve the version of @angular/core that is installed in the project.
990 // This is useful for monorepos where different projects may use different versions of Angular.
991 const detectedVersion = detectAngularCoreVersion(project, host);
992 if (detectedVersion !== null) {
993 options['_angularCoreVersion'] = detectedVersion;
994 }
995 }
996
997 return options;
998}
999
1000function detectAngularCoreVersion(
1001 project: ts.server.ConfiguredProject,

Callers 2

constructorMethod · 0.85
watchConfigFileMethod · 0.85

Calls 3

readConfigurationFunction · 0.90
detectAngularCoreVersionFunction · 0.85
getCurrentDirectoryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…