@@ -370,7 +370,9 @@ namespace ts {
370
370
finally {
371
371
cancellationToken = undefined;
372
372
}
373
- }
373
+ },
374
+
375
+ getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
374
376
};
375
377
376
378
function getResolvedSignatureWorker(nodeIn: CallLikeExpression, candidatesOutArray: Signature[] | undefined, argumentCount: number | undefined, isForSignatureHelp: boolean): Signature | undefined {
@@ -1208,17 +1210,23 @@ namespace ts {
1208
1210
// local types not visible outside the function body
1209
1211
: false;
1210
1212
}
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 =
1217
1224
lastLocation.kind === SyntaxKind.Parameter ||
1218
1225
(
1219
1226
lastLocation === (<FunctionLikeDeclaration>location).type &&
1220
1227
!!findAncestor(result.valueDeclaration, isParameter)
1221
1228
);
1229
+ }
1222
1230
}
1223
1231
}
1224
1232
else if (location.kind === SyntaxKind.ConditionalType) {
@@ -2280,8 +2288,6 @@ namespace ts {
2280
2288
return getPackagesSet().has(getTypesPackageName(packageName));
2281
2289
}
2282
2290
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.
2285
2291
function resolveExternalModuleSymbol(moduleSymbol: Symbol, dontResolveAlias?: boolean): Symbol;
2286
2292
function resolveExternalModuleSymbol(moduleSymbol: Symbol | undefined, dontResolveAlias?: boolean): Symbol | undefined;
2287
2293
function resolveExternalModuleSymbol(moduleSymbol: Symbol, dontResolveAlias?: boolean): Symbol {
@@ -3920,13 +3926,22 @@ namespace ts {
3920
3926
const links = getSymbolLinks(symbol);
3921
3927
let specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
3922
3928
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(
3924
3937
symbol,
3925
- compilerOptions ,
3938
+ specifierCompilerOptions ,
3926
3939
contextFile,
3927
- context.tracker.moduleResolverHost,
3940
+ moduleResolverHost,
3941
+ host.getSourceFiles(),
3942
+ { importModuleSpecifierPreference: isBundle ? "non-relative" : "relative" },
3928
3943
host.redirectTargetsMap,
3929
- );
3944
+ ))) ;
3930
3945
links.specifierCache = links.specifierCache || createMap();
3931
3946
links.specifierCache.set(contextFile.path, specifier);
3932
3947
}
0 commit comments