( project: ts.server.Project, host: ConfigurationHost, config: LanguageServiceConfig, )
| 947 | } |
| 948 | |
| 949 | function 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 | |
| 1000 | function detectAngularCoreVersion( |
| 1001 | project: ts.server.ConfiguredProject, |
no test coverage detected
searching dependent graphs…