mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into fix19349
This commit is contained in:
+16
-19
@@ -6726,6 +6726,16 @@ namespace ts {
|
||||
isInJavaScriptFile(signature.declaration));
|
||||
}
|
||||
|
||||
function getBaseSignature(signature: Signature) {
|
||||
const typeParameters = signature.typeParameters;
|
||||
if (typeParameters) {
|
||||
const typeEraser = createTypeEraser(typeParameters);
|
||||
const baseConstraints = map(typeParameters, tp => instantiateType(getBaseConstraintOfType(tp), typeEraser) || emptyObjectType);
|
||||
return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true);
|
||||
}
|
||||
return signature;
|
||||
}
|
||||
|
||||
function getOrCreateTypeFromSignature(signature: Signature): ObjectType {
|
||||
// There are two ways to declare a construct signature, one is by declaring a class constructor
|
||||
// using the constructor keyword, and the other is declaring a bare construct signature in an
|
||||
@@ -10955,7 +10965,7 @@ namespace ts {
|
||||
const targetLen = targetSignatures.length;
|
||||
const len = sourceLen < targetLen ? sourceLen : targetLen;
|
||||
for (let i = 0; i < len; i++) {
|
||||
inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]));
|
||||
inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getBaseSignature(targetSignatures[targetLen - len + i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13430,7 +13440,7 @@ namespace ts {
|
||||
// exists. Otherwise, it is the type of the string index signature in T, if one exists.
|
||||
function getContextualTypeForObjectLiteralMethod(node: MethodDeclaration): Type {
|
||||
Debug.assert(isObjectLiteralMethod(node));
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return undefined;
|
||||
}
|
||||
@@ -13549,7 +13559,7 @@ namespace ts {
|
||||
* @returns the contextual type of an expression.
|
||||
*/
|
||||
function getContextualType(node: Expression): Type | undefined {
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return undefined;
|
||||
}
|
||||
@@ -23114,21 +23124,8 @@ namespace ts {
|
||||
|
||||
// Language service support
|
||||
|
||||
function isInsideWithStatementBody(node: Node): boolean {
|
||||
if (node) {
|
||||
while (node.parent) {
|
||||
if (node.parent.kind === SyntaxKind.WithStatement && (<WithStatement>node.parent).statement === node) {
|
||||
return true;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] {
|
||||
if (isInsideWithStatementBody(location)) {
|
||||
if (location.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return [];
|
||||
}
|
||||
@@ -23428,7 +23425,7 @@ namespace ts {
|
||||
return isExternalModule(<SourceFile>node) ? getMergedSymbol(node.symbol) : undefined;
|
||||
}
|
||||
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return undefined;
|
||||
}
|
||||
@@ -23536,7 +23533,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getTypeOfNode(node: Node): Type {
|
||||
if (isInsideWithStatementBody(node)) {
|
||||
if (node.flags & NodeFlags.InWithStatement) {
|
||||
// We cannot answer semantic questions within a with block, do not proceed any further
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -4724,7 +4724,7 @@ namespace ts {
|
||||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
node.expression = allowInAnd(parseExpression);
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
node.statement = parseStatement();
|
||||
node.statement = doInsideOfContext(NodeFlags.InWithStatement, parseStatement);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -451,6 +451,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
PossiblyContainsDynamicImport = 1 << 19,
|
||||
JSDoc = 1 << 20, // If node was parsed inside jsdoc
|
||||
/* @internal */ InWithStatement = 1 << 21, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`)
|
||||
|
||||
BlockScoped = Let | Const,
|
||||
|
||||
@@ -458,7 +459,7 @@ namespace ts {
|
||||
ReachabilityAndEmitFlags = ReachabilityCheckFlags | HasAsyncFunctions,
|
||||
|
||||
// Parsing context flags
|
||||
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile,
|
||||
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile | InWithStatement,
|
||||
|
||||
// Exclude these flags when parsing a Type
|
||||
TypeExcludesFlags = YieldContext | AwaitContext,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [
|
||||
Diagnostics.Cannot_find_module_0.code,
|
||||
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code,
|
||||
],
|
||||
getCodeActions: context => {
|
||||
|
||||
Reference in New Issue
Block a user