build: typescript 3.7 support (#33717)
This PR updates TypeScript version to 3.7 while retaining compatibility with TS3.6. PR Close #33717
This commit is contained in:
@ -34,7 +34,7 @@
|
||||
"@angular/compiler-cli": "0.0.0-PLACEHOLDER",
|
||||
"@bazel/typescript": "0.*",
|
||||
"terser": "^4.3.1",
|
||||
"typescript": ">=3.6 <3.7",
|
||||
"typescript": ">=3.6 <3.8",
|
||||
"rollup": ">=1.20.0",
|
||||
"rollup-plugin-commonjs": ">=9.0.0",
|
||||
"rollup-plugin-node-resolve": ">=4.2.0",
|
||||
|
@ -25,7 +25,7 @@
|
||||
"peerDependencies": {
|
||||
"@angular/compiler": "0.0.0-PLACEHOLDER",
|
||||
"tslib": "^1.10.0",
|
||||
"typescript": ">=3.6 <3.7"
|
||||
"typescript": ">=3.6 <3.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0"
|
||||
|
@ -19,7 +19,7 @@ const MIN_TS_VERSION = '3.6.4';
|
||||
* ∀ supported typescript version v, v < MAX_TS_VERSION
|
||||
* MAX_TS_VERSION is not considered as a supported TypeScript version
|
||||
*/
|
||||
const MAX_TS_VERSION = '3.7.0';
|
||||
const MAX_TS_VERSION = '3.8.0';
|
||||
|
||||
/**
|
||||
* The currently used version of TypeScript, which can be adjusted for testing purposes using
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {Type} from '../interface/type';
|
||||
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
||||
|
||||
import {InjectableType, getInjectableDef, ɵɵInjectableDef, ɵɵdefineInjectable} from './interface/defs';
|
||||
import {InjectableType, getInjectableDef, ɵɵdefineInjectable} from './interface/defs';
|
||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider} from './interface/provider';
|
||||
import {compileInjectable as render3CompileInjectable} from './jit/injectable';
|
||||
import {convertInjectableProviderToFactory} from './util';
|
||||
|
@ -157,8 +157,8 @@ class TypeScriptSymbolQuery implements SymbolQuery {
|
||||
const context: TypeContext = {node: this.source, program: this.program, checker: this.checker};
|
||||
const typeSymbol = findClassSymbolInContext(type, context);
|
||||
if (typeSymbol) {
|
||||
const contextType = this.getTemplateRefContextType(typeSymbol);
|
||||
if (contextType) return new SymbolWrapper(contextType, context).members();
|
||||
const contextType = this.getTemplateRefContextType(typeSymbol, context);
|
||||
if (contextType) return contextType.members();
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ class TypeScriptSymbolQuery implements SymbolQuery {
|
||||
return spanAt(this.source, line, column);
|
||||
}
|
||||
|
||||
private getTemplateRefContextType(typeSymbol: ts.Symbol): ts.Symbol|undefined {
|
||||
private getTemplateRefContextType(typeSymbol: ts.Symbol, context: TypeContext): Symbol|undefined {
|
||||
const type = this.checker.getTypeOfSymbolAtLocation(typeSymbol, this.source);
|
||||
const constructor = type.symbol && type.symbol.members &&
|
||||
getFromSymbolTable(type.symbol.members !, '__constructor');
|
||||
@ -196,9 +196,10 @@ class TypeScriptSymbolQuery implements SymbolQuery {
|
||||
for (const parameter of constructorDeclaration.parameters) {
|
||||
const type = this.checker.getTypeAtLocation(parameter.type !);
|
||||
if (type.symbol !.name == 'TemplateRef' && isReferenceType(type)) {
|
||||
const typeReference = type as ts.TypeReference;
|
||||
if (typeReference.typeArguments && typeReference.typeArguments.length === 1) {
|
||||
return typeReference.typeArguments[0].symbol;
|
||||
const typeWrapper = new TypeWrapper(type, context);
|
||||
const typeArguments = typeWrapper.typeArguments();
|
||||
if (typeArguments && typeArguments.length === 1) {
|
||||
return typeArguments[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -313,8 +314,15 @@ class TypeWrapper implements Symbol {
|
||||
}
|
||||
|
||||
typeArguments(): Symbol[]|undefined {
|
||||
// TODO: use checker.getTypeArguments when TS 3.7 lands in the monorepo.
|
||||
const typeArguments: ReadonlyArray<ts.Type> = (this.tsType as any).typeArguments;
|
||||
if (!isReferenceType(this.tsType)) return;
|
||||
|
||||
const typeReference = (this.tsType as ts.TypeReference);
|
||||
let typeArguments: ReadonlyArray<ts.Type>|undefined;
|
||||
if (this.context.checker.getTypeArguments) {
|
||||
typeArguments = this.context.checker.getTypeArguments(typeReference);
|
||||
} else {
|
||||
typeArguments = typeReference.typeArguments;
|
||||
}
|
||||
if (!typeArguments) return undefined;
|
||||
return typeArguments.map(ta => new TypeWrapper(ta, this.context));
|
||||
}
|
||||
|
@ -32,4 +32,4 @@ export const INITIAL_CONFIG = new InjectionToken<PlatformConfig>('Server.INITIAL
|
||||
* @publicApi
|
||||
*/
|
||||
export const BEFORE_APP_SERIALIZED =
|
||||
new InjectionToken<Array<() => void>>('Server.RENDER_MODULE_HOOK');
|
||||
new InjectionToken<Array<() => void | Promise<void>>>('Server.RENDER_MODULE_HOOK');
|
||||
|
@ -150,7 +150,7 @@ describe(
|
||||
|
||||
it('cancel fetch should invoke onCancelTask',
|
||||
ifEnvSupportsWithDone('AbortController', (done: DoneFn) => {
|
||||
if (isSafari) {
|
||||
if (isSafari()) {
|
||||
// safari not work with AbortController
|
||||
done();
|
||||
return;
|
||||
@ -177,7 +177,7 @@ describe(
|
||||
|
||||
it('cancel fetchTask should trigger abort',
|
||||
ifEnvSupportsWithDone('AbortController', (done: DoneFn) => {
|
||||
if (isSafari) {
|
||||
if (isSafari()) {
|
||||
// safari not work with AbortController
|
||||
done();
|
||||
return;
|
||||
|
Reference in New Issue
Block a user