Skip to content

Commit 52fef42

Browse files
committed
Merge branch 'master' into lazyConfiguredProjectsFromExternalProject
2 parents fc90b8f + 9106fdb commit 52fef42

File tree

58 files changed

+2293
-889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2293
-889
lines changed

src/compiler/checker.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,9 @@ namespace ts {
370370
finally {
371371
cancellationToken = undefined;
372372
}
373-
}
373+
},
374+
375+
getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
374376
};
375377

376378
function getResolvedSignatureWorker(nodeIn: CallLikeExpression, candidatesOutArray: Signature[] | undefined, argumentCount: number | undefined, isForSignatureHelp: boolean): Signature | undefined {
@@ -1208,17 +1210,23 @@ namespace ts {
12081210
// local types not visible outside the function body
12091211
: false;
12101212
}
1211-
if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.FunctionScopedVariable) {
1212-
// parameters are visible only inside function body, parameter list and return type
1213-
// technically for parameter list case here we might mix parameters and variables declared in function,
1214-
// however it is detected separately when checking initializers of parameters
1215-
// to make sure that they reference no variables declared after them.
1216-
useResult =
1213+
if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.Variable) {
1214+
// parameter initializer will lookup as normal variable scope when targeting es2015+
1215+
if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && result.valueDeclaration !== lastLocation) {
1216+
useResult = false;
1217+
}
1218+
else if (result.flags & SymbolFlags.FunctionScopedVariable) {
1219+
// parameters are visible only inside function body, parameter list and return type
1220+
// technically for parameter list case here we might mix parameters and variables declared in function,
1221+
// however it is detected separately when checking initializers of parameters
1222+
// to make sure that they reference no variables declared after them.
1223+
useResult =
12171224
lastLocation.kind === SyntaxKind.Parameter ||
12181225
(
12191226
lastLocation === (<FunctionLikeDeclaration>location).type &&
12201227
!!findAncestor(result.valueDeclaration, isParameter)
12211228
);
1229+
}
12221230
}
12231231
}
12241232
else if (location.kind === SyntaxKind.ConditionalType) {
@@ -2280,8 +2288,6 @@ namespace ts {
22802288
return getPackagesSet().has(getTypesPackageName(packageName));
22812289
}
22822290

2283-
// An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
2284-
// and an external module with no 'export =' declaration resolves to the module itself.
22852291
function resolveExternalModuleSymbol(moduleSymbol: Symbol, dontResolveAlias?: boolean): Symbol;
22862292
function resolveExternalModuleSymbol(moduleSymbol: Symbol | undefined, dontResolveAlias?: boolean): Symbol | undefined;
22872293
function resolveExternalModuleSymbol(moduleSymbol: Symbol, dontResolveAlias?: boolean): Symbol {
@@ -3920,13 +3926,22 @@ namespace ts {
39203926
const links = getSymbolLinks(symbol);
39213927
let specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
39223928
if (!specifier) {
3923-
specifier = moduleSpecifiers.getModuleSpecifierForDeclarationFile(
3929+
const isBundle = (compilerOptions.out || compilerOptions.outFile);
3930+
// For declaration bundles, we need to generate absolute paths relative to the common source dir for imports,
3931+
// just like how the declaration emitter does for the ambient module declarations - we can easily accomplish this
3932+
// using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative
3933+
// specifier preference
3934+
const { moduleResolverHost } = context.tracker;
3935+
const specifierCompilerOptions = isBundle ? { ...compilerOptions, baseUrl: moduleResolverHost.getCommonSourceDirectory() } : compilerOptions;
3936+
specifier = first(first(moduleSpecifiers.getModuleSpecifiers(
39243937
symbol,
3925-
compilerOptions,
3938+
specifierCompilerOptions,
39263939
contextFile,
3927-
context.tracker.moduleResolverHost,
3940+
moduleResolverHost,
3941+
host.getSourceFiles(),
3942+
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "relative" },
39283943
host.redirectTargetsMap,
3929-
);
3944+
)));
39303945
links.specifierCache = links.specifierCache || createMap();
39313946
links.specifierCache.set(contextFile.path, specifier);
39323947
}

src/compiler/commandLineParser.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,11 @@ namespace ts {
815815
}
816816

817817
function getOptionNameMap(): OptionNameMap {
818-
if (optionNameMapCache) {
819-
return optionNameMapCache;
820-
}
818+
return optionNameMapCache || (optionNameMapCache = createOptionNameMap(optionDeclarations));
819+
}
821820

821+
/*@internal*/
822+
export function createOptionNameMap(optionDeclarations: ReadonlyArray<CommandLineOption>): OptionNameMap {
822823
const optionNameMap = createMap<CommandLineOption>();
823824
const shortOptionNames = createMap<string>();
824825
forEach(optionDeclarations, option => {
@@ -828,8 +829,7 @@ namespace ts {
828829
}
829830
});
830831

831-
optionNameMapCache = { optionNameMap, shortOptionNames };
832-
return optionNameMapCache;
832+
return { optionNameMap, shortOptionNames };
833833
}
834834

835835
/* @internal */
@@ -979,7 +979,12 @@ namespace ts {
979979
}
980980

981981
/** @internal */
982-
export function getOptionFromName(optionName: string, allowShort = false): CommandLineOption | undefined {
982+
export function getOptionFromName(optionName: string, allowShort?: boolean): CommandLineOption | undefined {
983+
return getOptionDeclarationFromName(getOptionNameMap, optionName, allowShort);
984+
}
985+
986+
/*@internal*/
987+
export function getOptionDeclarationFromName(getOptionNameMap: () => OptionNameMap, optionName: string, allowShort = false): CommandLineOption | undefined {
983988
optionName = optionName.toLowerCase();
984989
const { optionNameMap, shortOptionNames } = getOptionNameMap();
985990
// Try to translate short option names to their full equivalents.

src/compiler/diagnosticMessages.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,6 +2896,11 @@
28962896
"category": "Error",
28972897
"code": 5071
28982898
},
2899+
"Unknown build option '{0}'.": {
2900+
"category": "Error",
2901+
"code": 5072
2902+
},
2903+
28992904

29002905
"Generates a sourcemap for each corresponding '.d.ts' file.": {
29012906
"category": "Message",

0 commit comments

Comments
 (0)