@@ -11,7 +11,6 @@ import { resolve } from '@angular-devkit/core/node';
11
11
import * as path from 'path' ;
12
12
import { SemVer , satisfies } from 'semver' ;
13
13
import { isWarningEnabled } from '../utilities/config' ;
14
- import { requireProjectModule } from '../utilities/require-project-module' ;
15
14
16
15
17
16
export class Version {
@@ -131,10 +130,23 @@ export class Version {
131
130
if ( ! isWarningEnabled ( 'typescriptMismatch' ) ) {
132
131
return ;
133
132
}
134
- let compilerVersion : string , tsVersion : string ;
133
+
134
+ let compilerVersion : string ;
135
+ let tsVersion : string ;
136
+ let compilerTypeScriptPeerVersion : string ;
135
137
try {
136
- compilerVersion = requireProjectModule ( projectRoot , '@angular/compiler-cli' ) . VERSION . full ;
137
- tsVersion = requireProjectModule ( projectRoot , 'typescript' ) . version ;
138
+ const resolveOptions = {
139
+ basedir : projectRoot ,
140
+ checkGlobal : false ,
141
+ checkLocal : true ,
142
+ } ;
143
+ const compilerPackagePath = resolve ( '@angular/compiler-cli/package.json' , resolveOptions ) ;
144
+ const typescriptProjectPath = resolve ( 'typescript' , resolveOptions ) ;
145
+ const compilerPackageInfo = require ( compilerPackagePath ) ;
146
+
147
+ compilerVersion = compilerPackageInfo [ 'version' ] ;
148
+ compilerTypeScriptPeerVersion = compilerPackageInfo [ 'peerDependencies' ] [ 'typescript' ] ;
149
+ tsVersion = require ( typescriptProjectPath ) . version ;
138
150
} catch {
139
151
console . error ( terminal . bold ( terminal . red ( tags . stripIndents `
140
152
Versions of @angular/compiler-cli and typescript could not be determined.
@@ -149,18 +161,17 @@ export class Version {
149
161
return ;
150
162
}
151
163
164
+ // These versions do not have accurate typescript peer dependencies
152
165
const versionCombos = [
153
166
{ compiler : '>=2.3.1 <3.0.0' , typescript : '>=2.0.2 <2.3.0' } ,
154
167
{ compiler : '>=4.0.0-beta.0 <5.0.0' , typescript : '>=2.1.0 <2.4.0' } ,
155
- { compiler : '>=5.0.0-beta.0 <5.1.0' , typescript : '>=2.4.2 <2.5.0' } ,
156
- { compiler : '>=5.1.0-beta.0 <5.2.0' , typescript : '>=2.4.2 <2.6.0' } ,
157
- { compiler : '>=5.2.0-beta.0 <6.0.0' , typescript : '>=2.4.2 <2.7.0' } ,
158
- { compiler : '>=6.0.0-beta.0 <6.1.0-beta.0' , typescript : '>=2.7.0 <2.8.0' } ,
159
- { compiler : '>=6.1.0-beta.0 <6.1.0-rc.0' , typescript : '>=2.7.2 <2.9.0' } ,
160
- { compiler : '>=6.1.0-rc.0 <7.0.0' , typescript : '>=2.7.2 <2.10.0' } ,
168
+ { compiler : '5.0.0-beta.0 - 5.0.0-rc.2' , typescript : '>=2.4.2 <2.5.0' } ,
161
169
] ;
162
170
163
- const currentCombo = versionCombos . find ( ( combo ) => satisfies ( compilerVersion , combo . compiler ) ) ;
171
+ let currentCombo = versionCombos . find ( ( combo ) => satisfies ( compilerVersion , combo . compiler ) ) ;
172
+ if ( ! currentCombo && compilerTypeScriptPeerVersion ) {
173
+ currentCombo = { compiler : compilerVersion , typescript : compilerTypeScriptPeerVersion } ;
174
+ }
164
175
165
176
if ( currentCombo && ! satisfies ( tsVersion , currentCombo . typescript ) ) {
166
177
// First line of warning looks weird being split in two, disable tslint for it.
0 commit comments