mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
CR feedback
This commit is contained in:
+4
-14
@@ -2577,7 +2577,7 @@ namespace ts {
|
||||
return links.type = checkExpression((<BinaryExpression>declaration).right);
|
||||
}
|
||||
// Handle exports.p = expr
|
||||
if (declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) {
|
||||
if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
return checkExpressionCached((<BinaryExpression>declaration.parent).right);
|
||||
}
|
||||
// Handle variable, parameter or property
|
||||
@@ -9377,11 +9377,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
let exprType = checkExpression(node.expression);
|
||||
if (exprType === cjsRequireType) {
|
||||
if (node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) {
|
||||
return resolveExternalModuleTypeByLiteral(<StringLiteral>node.arguments[0]);
|
||||
}
|
||||
// In JavaScript files, calls to any identifier 'require' are treated as external module imports
|
||||
if (isInJavaScriptFile(node) && isRequireCall(node)) {
|
||||
return resolveExternalModuleTypeByLiteral(<StringLiteral>node.arguments[0]);
|
||||
}
|
||||
|
||||
return getReturnTypeOfSignature(signature);
|
||||
@@ -14925,14 +14923,6 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize special symbols
|
||||
if (compilerOptions.allowNonTsExtensions) {
|
||||
let req = getExportedSymbolFromNamespace("CommonJS", "require");
|
||||
if (req) {
|
||||
globals["require"] = req;
|
||||
}
|
||||
}
|
||||
|
||||
getSymbolLinks(undefinedSymbol).type = undefinedType;
|
||||
getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments");
|
||||
getSymbolLinks(unknownSymbol).type = unknownType;
|
||||
|
||||
@@ -1039,7 +1039,7 @@ namespace ts {
|
||||
return isInJavaScriptFile(file);
|
||||
}
|
||||
|
||||
function isInJavaScriptFile(node: Node): boolean {
|
||||
export function isInJavaScriptFile(node: Node): boolean {
|
||||
return node && !!(node.parserContextFlags & ParserContextFlags.JavaScriptFile);
|
||||
}
|
||||
|
||||
@@ -1053,7 +1053,8 @@ namespace ts {
|
||||
return expression.kind === SyntaxKind.CallExpression &&
|
||||
(<CallExpression>expression).expression.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>(<CallExpression>expression).expression).text === "require" &&
|
||||
(<CallExpression>expression).arguments.length === 1;
|
||||
(<CallExpression>expression).arguments.length === 1 &&
|
||||
(<CallExpression>expression).arguments[0].kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
-16
@@ -1183,22 +1183,6 @@ interface PromiseLike<T> {
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
|
||||
|
||||
declare namespace CommonJS {
|
||||
export var require: Require;
|
||||
|
||||
export var exports: any;
|
||||
|
||||
interface Exports { }
|
||||
interface Module {
|
||||
exports: Exports;
|
||||
}
|
||||
|
||||
interface Require {
|
||||
(moduleName: string): any;
|
||||
}
|
||||
}
|
||||
|
||||
interface ArrayLike<T> {
|
||||
length: number;
|
||||
[n: number]: T;
|
||||
|
||||
Reference in New Issue
Block a user