Upgrade "boolean-trivia" lint to new "argument-trivia" lint that uses type info, has quick fixes, etc. (#53002)
This commit is contained in:
Родитель
3a3146e25f
Коммит
ac55b297b7
|
@ -97,7 +97,7 @@
|
|||
"allowDeclarations": true
|
||||
}],
|
||||
"local/no-double-space": "error",
|
||||
"local/boolean-trivia": "error",
|
||||
"local/argument-trivia": "error",
|
||||
"local/no-in-operator": "error",
|
||||
"local/simple-indent": "error",
|
||||
"local/debug-assert": "error",
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
const { AST_NODE_TYPES, TSESTree, ESLintUtils } = require("@typescript-eslint/utils");
|
||||
const { createRule } = require("./utils.cjs");
|
||||
const ts = require("typescript");
|
||||
|
||||
const unset = Symbol();
|
||||
/**
|
||||
* @template T
|
||||
* @param {() => T} fn
|
||||
* @returns {() => T}
|
||||
*/
|
||||
function memoize(fn) {
|
||||
/** @type {T | unset} */
|
||||
let value = unset;
|
||||
return () => {
|
||||
if (value === unset) {
|
||||
value = fn();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
module.exports = createRule({
|
||||
name: "argument-trivia",
|
||||
meta: {
|
||||
docs: {
|
||||
description: ``,
|
||||
recommended: "error",
|
||||
},
|
||||
messages: {
|
||||
argumentTriviaArgumentError: `Tag argument with parameter name`,
|
||||
argumentTriviaArgumentSpaceError: `There should be 1 space between an argument and its comment`,
|
||||
argumentTriviaArgumentNameError: `Argument name "{{ got }}" does not match expected name "{{ want }}"`,
|
||||
},
|
||||
schema: [],
|
||||
type: "problem",
|
||||
fixable: "code",
|
||||
},
|
||||
defaultOptions: [],
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCodeText = sourceCode.getText();
|
||||
|
||||
/** @type {(name: string) => boolean} */
|
||||
const isSetOrAssert = (name) => name.startsWith("set") || name.startsWith("assert");
|
||||
/** @type {(node: TSESTree.Node) => boolean} */
|
||||
const isTrivia = (node) => {
|
||||
if (node.type === AST_NODE_TYPES.Identifier) {
|
||||
return node.name === "undefined";
|
||||
}
|
||||
|
||||
if (node.type === AST_NODE_TYPES.Literal) {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return node.value === null || node.value === true || node.value === false;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/** @type {(node: TSESTree.CallExpression | TSESTree.NewExpression) => boolean} */
|
||||
const shouldIgnoreCalledExpression = (node) => {
|
||||
if (node.callee && node.callee.type === AST_NODE_TYPES.MemberExpression) {
|
||||
const methodName = node.callee.property.type === AST_NODE_TYPES.Identifier
|
||||
? node.callee.property.name
|
||||
: "";
|
||||
|
||||
if (isSetOrAssert(methodName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (methodName) {
|
||||
case "apply":
|
||||
case "call":
|
||||
case "equal":
|
||||
case "stringify":
|
||||
case "push":
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node.callee && node.callee.type === AST_NODE_TYPES.Identifier) {
|
||||
const functionName = node.callee.name;
|
||||
|
||||
if (isSetOrAssert(functionName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (functionName) {
|
||||
case "contains":
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
/** @type {(node: TSESTree.Node, i: number, getSignature: () => ts.Signature | undefined) => void} */
|
||||
const checkArg = (node, i, getSignature) => {
|
||||
if (!isTrivia(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const getExpectedName = memoize(() => {
|
||||
const signature = getSignature();
|
||||
if (signature) {
|
||||
const expectedName = signature.parameters[i]?.escapedName;
|
||||
if (expectedName) {
|
||||
const name = ts.unescapeLeadingUnderscores(expectedName);
|
||||
// If a parameter is unused, we prepend an underscore. Ignore this
|
||||
// so that we can switch between used and unused without modifying code,
|
||||
// requiring that arugments are tagged with the non-underscored name.
|
||||
return name.startsWith("_") ? name.slice(1) : name;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
const comments = sourceCode.getCommentsBefore(node);
|
||||
/** @type {TSESTree.Comment | undefined} */
|
||||
const comment = comments[comments.length - 1];
|
||||
|
||||
if (!comment || comment.type !== "Block") {
|
||||
const expectedName = getExpectedName();
|
||||
if (expectedName) {
|
||||
context.report({
|
||||
messageId: "argumentTriviaArgumentError",
|
||||
node,
|
||||
fix: (fixer) => {
|
||||
return fixer.insertTextBefore(node, `/*${expectedName}*/ `);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({ messageId: "argumentTriviaArgumentError", node });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const argRangeStart = node.range[0];
|
||||
const commentRangeEnd = comment.range[1];
|
||||
const expectedName = getExpectedName();
|
||||
if (expectedName) {
|
||||
const got = comment.value;
|
||||
if (got !== expectedName) {
|
||||
context.report({
|
||||
messageId: "argumentTriviaArgumentNameError",
|
||||
data: { got, want: expectedName },
|
||||
node: comment,
|
||||
fix: (fixer) => {
|
||||
return fixer.replaceText(comment, `/*${expectedName}*/`);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const hasNewLine = sourceCodeText.slice(commentRangeEnd, argRangeStart).indexOf("\n") >= 0;
|
||||
if (argRangeStart !== commentRangeEnd + 1 && !hasNewLine) {
|
||||
// TODO(jakebailey): range should be whitespace
|
||||
context.report({
|
||||
messageId: "argumentTriviaArgumentSpaceError",
|
||||
node,
|
||||
fix: (fixer) => {
|
||||
return fixer.replaceTextRange([commentRangeEnd, argRangeStart], " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {(node: TSESTree.CallExpression | TSESTree.NewExpression) => void} */
|
||||
const checkArgumentTrivia = (node) => {
|
||||
if (shouldIgnoreCalledExpression(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const getSignature = memoize(() => {
|
||||
if (context.parserServices?.hasFullTypeInformation) {
|
||||
const parserServices = ESLintUtils.getParserServices(context);
|
||||
const checker = parserServices.program.getTypeChecker();
|
||||
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
||||
return checker.getResolvedSignature(tsNode);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
for (let i = 0; i < node.arguments.length; i++) {
|
||||
const arg = node.arguments[i];
|
||||
checkArg(arg, i, getSignature);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
CallExpression: checkArgumentTrivia,
|
||||
NewExpression: checkArgumentTrivia,
|
||||
};
|
||||
},
|
||||
});
|
|
@ -1,110 +0,0 @@
|
|||
const { AST_NODE_TYPES, TSESTree } = require("@typescript-eslint/utils");
|
||||
const { createRule } = require("./utils.cjs");
|
||||
|
||||
module.exports = createRule({
|
||||
name: "boolean-trivia",
|
||||
meta: {
|
||||
docs: {
|
||||
description: ``,
|
||||
recommended: "error",
|
||||
},
|
||||
messages: {
|
||||
booleanTriviaArgumentError: `Tag argument with parameter name`,
|
||||
booleanTriviaArgumentSpaceError: `There should be 1 space between an argument and its comment`,
|
||||
},
|
||||
schema: [],
|
||||
type: "problem",
|
||||
},
|
||||
defaultOptions: [],
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCodeText = sourceCode.getText();
|
||||
|
||||
/** @type {(name: string) => boolean} */
|
||||
const isSetOrAssert = (name) => name.startsWith("set") || name.startsWith("assert");
|
||||
/** @type {(node: TSESTree.Node) => boolean} */
|
||||
const isTrivia = (node) => {
|
||||
if (node.type === AST_NODE_TYPES.Identifier) {
|
||||
return node.name === "undefined";
|
||||
}
|
||||
|
||||
if (node.type === AST_NODE_TYPES.Literal) {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return node.value === null || node.value === true || node.value === false;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/** @type {(node: TSESTree.CallExpression) => boolean} */
|
||||
const shouldIgnoreCalledExpression = (node) => {
|
||||
if (node.callee && node.callee.type === AST_NODE_TYPES.MemberExpression) {
|
||||
const methodName = node.callee.property.type === AST_NODE_TYPES.Identifier
|
||||
? node.callee.property.name
|
||||
: "";
|
||||
|
||||
if (isSetOrAssert(methodName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ["apply", "call", "equal", "fail", "isTrue", "output", "stringify", "push"].indexOf(methodName) >= 0;
|
||||
}
|
||||
|
||||
if (node.callee && node.callee.type === AST_NODE_TYPES.Identifier) {
|
||||
const functionName = node.callee.name;
|
||||
|
||||
if (isSetOrAssert(functionName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return [
|
||||
"createImportSpecifier",
|
||||
"createAnonymousType",
|
||||
"createSignature",
|
||||
"createProperty",
|
||||
"resolveName",
|
||||
"contains",
|
||||
].indexOf(functionName) >= 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/** @type {(node: TSESTree.Node) => void} */
|
||||
const checkArg = (node) => {
|
||||
if (!isTrivia(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const comments = sourceCode.getCommentsBefore(node);
|
||||
if (!comments || comments.length !== 1 || comments[0].type !== "Block") {
|
||||
context.report({ messageId: "booleanTriviaArgumentError", node });
|
||||
return;
|
||||
}
|
||||
|
||||
const argRangeStart = node.range[0];
|
||||
const commentRangeEnd = comments[0].range[1];
|
||||
const hasNewLine = sourceCodeText.slice(commentRangeEnd, argRangeStart).indexOf("\n") >= 0;
|
||||
|
||||
if (argRangeStart !== commentRangeEnd + 1 && !hasNewLine) {
|
||||
context.report({ messageId: "booleanTriviaArgumentSpaceError", node });
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {(node: TSESTree.CallExpression) => void} */
|
||||
const checkBooleanTrivia = (node) => {
|
||||
if (shouldIgnoreCalledExpression(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const arg of node.arguments) {
|
||||
checkArg(arg);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
CallExpression: checkBooleanTrivia,
|
||||
};
|
||||
},
|
||||
});
|
|
@ -1,5 +1,5 @@
|
|||
const { RuleTester } = require("./support/RuleTester.cjs");
|
||||
const rule = require("../rules/boolean-trivia.cjs");
|
||||
const rule = require("../rules/argument-trivia.cjs");
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
|
@ -8,7 +8,7 @@ const ruleTester = new RuleTester({
|
|||
parser: require.resolve("@typescript-eslint/parser"),
|
||||
});
|
||||
|
||||
ruleTester.run("boolean-trivia", rule, {
|
||||
ruleTester.run("argument-trivia", rule, {
|
||||
valid: [
|
||||
{
|
||||
code: `
|
||||
|
@ -48,6 +48,12 @@ const fn = (prop: boolean) => {};
|
|||
fn.apply(null, true);
|
||||
`,
|
||||
},
|
||||
{
|
||||
code: `
|
||||
const fn = (prop: boolean) => {};
|
||||
fn(/* first comment */ /* second comment */ false);
|
||||
`,
|
||||
},
|
||||
],
|
||||
|
||||
invalid: [
|
||||
|
@ -56,28 +62,25 @@ fn.apply(null, true);
|
|||
const fn = (prop: null) => {};
|
||||
fn(null);
|
||||
`,
|
||||
errors: [{ messageId: "booleanTriviaArgumentError" }],
|
||||
errors: [{ messageId: "argumentTriviaArgumentError" }],
|
||||
},
|
||||
{
|
||||
code: `
|
||||
const fn = (prop: boolean) => {};
|
||||
fn(false);
|
||||
`,
|
||||
errors: [{ messageId: "booleanTriviaArgumentError" }],
|
||||
errors: [{ messageId: "argumentTriviaArgumentError" }],
|
||||
},
|
||||
{
|
||||
code: `
|
||||
const fn = (prop: boolean) => {};
|
||||
fn(/* boolean arg */false);
|
||||
`,
|
||||
errors: [{ messageId: "booleanTriviaArgumentSpaceError" }],
|
||||
},
|
||||
{
|
||||
code: `
|
||||
errors: [{ messageId: "argumentTriviaArgumentSpaceError" }],
|
||||
output:`
|
||||
const fn = (prop: boolean) => {};
|
||||
fn(/* first comment */ /* second comment */ false);
|
||||
`,
|
||||
errors: [{ messageId: "booleanTriviaArgumentError" }],
|
||||
fn(/* boolean arg */ false);
|
||||
`
|
||||
},
|
||||
],
|
||||
});
|
|
@ -3309,7 +3309,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
|||
}
|
||||
else if (hasDynamicName(node)) {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Property | SymbolFlags.Assignment, InternalSymbolName.Computed);
|
||||
const sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false);
|
||||
const sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototypeProperty*/ false, /*containerIsClass*/ false);
|
||||
addLateBoundAssignmentDeclarationToSymbol(node, sym);
|
||||
}
|
||||
else {
|
||||
|
@ -3480,7 +3480,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
|||
function bindCallExpression(node: CallExpression) {
|
||||
// We're only inspecting call expressions to detect CommonJS modules, so we can skip
|
||||
// this check if we've already seen the module indicator
|
||||
if (!file.commonJsModuleIndicator && isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ false)) {
|
||||
if (!file.commonJsModuleIndicator && isRequireCall(node, /*requireStringLiteralLikeArgument*/ false)) {
|
||||
setCommonJsModuleIndicator(node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1622,7 +1622,7 @@ export function createBuilderProgram(kind: BuilderProgramKind, { newProgram, hos
|
|||
}
|
||||
else {
|
||||
// When whole program is affected, get all semantic diagnostics (eg when --out or --outFile is specified)
|
||||
result = state.program.getSemanticDiagnostics(/*targetSourceFile*/ undefined, cancellationToken);
|
||||
result = state.program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken);
|
||||
state.changedFilesSet.clear();
|
||||
state.programEmitPending = getBuilderFileEmit(state.compilerOptions);
|
||||
}
|
||||
|
|
|
@ -421,7 +421,7 @@ export namespace BuilderState {
|
|||
), sourceFiles!);
|
||||
},
|
||||
cancellationToken,
|
||||
/*emitOnlyDtsFiles*/ true,
|
||||
/*emitOnly*/ true,
|
||||
/*customTransformers*/ undefined,
|
||||
/*forceDtsEmit*/ true
|
||||
);
|
||||
|
|
|
@ -1970,28 +1970,28 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
return t;
|
||||
}, () => "(unreliable reporter)");
|
||||
|
||||
var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var emptyObjectType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var emptyJsxObjectType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
emptyJsxObjectType.objectFlags |= ObjectFlags.JsxAttributes;
|
||||
|
||||
var emptyTypeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, InternalSymbolName.Type);
|
||||
emptyTypeLiteralSymbol.members = createSymbolTable();
|
||||
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
|
||||
var unknownEmptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var unknownEmptyObjectType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
|
||||
|
||||
var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray) as ObjectType as GenericType;
|
||||
var emptyGenericType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray) as ObjectType as GenericType;
|
||||
emptyGenericType.instantiations = new Map<string, TypeReference>();
|
||||
|
||||
var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var anyFunctionType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
|
||||
// in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
|
||||
anyFunctionType.objectFlags |= ObjectFlags.NonInferrableType;
|
||||
|
||||
var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var noConstraintType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var circularConstraintType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
var resolvingDefaultType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
|
||||
var markerSuperType = createTypeParameter();
|
||||
var markerSubType = createTypeParameter();
|
||||
|
@ -2004,10 +2004,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
var noTypePredicate = createTypePredicate(TypePredicateKind.Identifier, "<<unresolved>>", 0, anyType);
|
||||
|
||||
var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
var silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
var anySignature = createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
var unknownSignature = createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
var resolvingSignature = createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
var silentNeverSignature = createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
|
||||
var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true);
|
||||
|
||||
|
@ -3354,7 +3354,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
if (!result) {
|
||||
if (originalLocation && isInJSFile(originalLocation) && originalLocation.parent) {
|
||||
if (isRequireCall(originalLocation.parent, /*checkArgumentIsStringLiteralLike*/ false)) {
|
||||
if (isRequireCall(originalLocation.parent, /*requireStringLiteralLikeArgument*/ false)) {
|
||||
return requireSymbol;
|
||||
}
|
||||
}
|
||||
|
@ -3638,7 +3638,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean {
|
||||
const namespaceMeaning = SymbolFlags.Namespace | (isInJSFile(errorLocation) ? SymbolFlags.Value : 0);
|
||||
if (meaning === namespaceMeaning) {
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~namespaceMeaning, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
const parent = errorLocation.parent;
|
||||
if (symbol) {
|
||||
if (isQualifiedName(parent)) {
|
||||
|
@ -3665,7 +3665,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
function checkAndReportErrorForUsingValueAsType(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean {
|
||||
if (meaning & (SymbolFlags.Type & ~SymbolFlags.Namespace)) {
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, ~SymbolFlags.Type & SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, ~SymbolFlags.Type & SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
if (symbol && !(symbol.flags & SymbolFlags.Namespace)) {
|
||||
error(errorLocation, Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, unescapeLeadingUnderscores(name));
|
||||
return true;
|
||||
|
@ -3697,7 +3697,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
const allFlags = symbol && getAllSymbolFlags(symbol);
|
||||
if (symbol && allFlags !== undefined && !(allFlags & SymbolFlags.Value)) {
|
||||
const rawName = unescapeLeadingUnderscores(name);
|
||||
|
@ -3752,7 +3752,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean {
|
||||
if (meaning & (SymbolFlags.Value & ~SymbolFlags.Type)) {
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
if (symbol) {
|
||||
error(
|
||||
errorLocation,
|
||||
|
@ -3762,7 +3762,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
}
|
||||
else if (meaning & (SymbolFlags.Type & ~SymbolFlags.Value)) {
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Module, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Module, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
if (symbol) {
|
||||
error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_type, unescapeLeadingUnderscores(name));
|
||||
return true;
|
||||
|
@ -4031,10 +4031,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
else if (hasSyntheticDefault || hasDefaultOnly) {
|
||||
// per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
|
||||
const resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
||||
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
|
||||
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteEmpty*/ false);
|
||||
return resolved;
|
||||
}
|
||||
markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, /*finalTarget*/ undefined, /*overwriteTypeOnly*/ false);
|
||||
markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ false);
|
||||
return exportDefaultSymbol;
|
||||
}
|
||||
|
||||
|
@ -4076,7 +4076,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
function getTargetOfNamespaceImport(node: NamespaceImport, dontResolveAlias: boolean): Symbol | undefined {
|
||||
const moduleSpecifier = node.parent.parent.moduleSpecifier;
|
||||
const immediate = resolveExternalModuleName(node, moduleSpecifier);
|
||||
const resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false);
|
||||
const resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, /*suppressInteropError*/ false);
|
||||
markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, /*overwriteEmpty*/ false);
|
||||
return resolved;
|
||||
}
|
||||
|
@ -4084,7 +4084,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
function getTargetOfNamespaceExport(node: NamespaceExport, dontResolveAlias: boolean): Symbol | undefined {
|
||||
const moduleSpecifier = node.parent.moduleSpecifier;
|
||||
const immediate = moduleSpecifier && resolveExternalModuleName(node, moduleSpecifier);
|
||||
const resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false);
|
||||
const resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, /*suppressInteropError*/ false);
|
||||
markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, /*overwriteEmpty*/ false);
|
||||
return resolved;
|
||||
}
|
||||
|
@ -4627,7 +4627,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
function tryGetQualifiedNameAsValue(node: QualifiedName) {
|
||||
let left: Identifier | QualifiedName = getFirstIdentifier(node);
|
||||
let symbol = resolveName(left, left.escapedText, SymbolFlags.Value, undefined, left, /*isUse*/ true);
|
||||
let symbol = resolveName(left, left.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, left, /*isUse*/ true);
|
||||
if (!symbol) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -4655,7 +4655,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
if (name.kind === SyntaxKind.Identifier) {
|
||||
const message = meaning === namespaceMeaning || nodeIsSynthesized(name) ? Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name));
|
||||
const symbolFromJSPrototype = isInJSFile(name) && !nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
|
||||
symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false));
|
||||
symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, /*excludeGlobals*/ false));
|
||||
if (!symbol) {
|
||||
return getMergedSymbol(symbolFromJSPrototype);
|
||||
}
|
||||
|
@ -5465,7 +5465,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
if (
|
||||
enclosingDeclaration &&
|
||||
container.flags & getQualifiedLeftMeaning(meaning) &&
|
||||
getAccessibleSymbolChain(container, enclosingDeclaration, SymbolFlags.Namespace, /*externalOnly*/ false)
|
||||
getAccessibleSymbolChain(container, enclosingDeclaration, SymbolFlags.Namespace, /*useOnlyExternalAliasing*/ false)
|
||||
) {
|
||||
return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope
|
||||
}
|
||||
|
@ -5831,7 +5831,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
}
|
||||
if (symbolFromSymbolTable.escapedName === symbol!.escapedName && symbolFromSymbolTable.exportSymbol) {
|
||||
if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), /*aliasSymbol*/ undefined, ignoreQualification)) {
|
||||
if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) {
|
||||
return [symbol!];
|
||||
}
|
||||
}
|
||||
|
@ -6134,11 +6134,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
const firstIdentifier = getFirstIdentifier(entityName);
|
||||
const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
if (symbol && symbol.flags & SymbolFlags.TypeParameter && meaning & SymbolFlags.Type) {
|
||||
return { accessibility: SymbolAccessibility.Accessible };
|
||||
}
|
||||
if (!symbol && isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfDeclaration(getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === SymbolAccessibility.Accessible) {
|
||||
if (!symbol && isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfDeclaration(getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false)), firstIdentifier, meaning, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) {
|
||||
return { accessibility: SymbolAccessibility.Accessible };
|
||||
}
|
||||
|
||||
|
@ -6693,7 +6693,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
// Always use 'typeof T' for type of class, enum, and module objects
|
||||
else if (symbol.flags & SymbolFlags.Class
|
||||
&& !getBaseTypeVariableOfClass(symbol)
|
||||
&& !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== SymbolAccessibility.Accessible)) ||
|
||||
&& !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible)) ||
|
||||
symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) ||
|
||||
shouldWriteTypeOfFunctionSymbol()) {
|
||||
return symbolToTypeNode(symbol, context, isInstanceType);
|
||||
|
@ -6814,7 +6814,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
if (nodes && nodes.length === 0) {
|
||||
// Ensure we explicitly make a copy of an empty array; visitNodes will not do this unless the array has elements,
|
||||
// which can lead to us reusing the same empty NodeArray more than once within the same AST during type noding.
|
||||
return setTextRange(factory.createNodeArray(/*nodes*/ undefined, nodes.hasTrailingComma), nodes);
|
||||
return setTextRange(factory.createNodeArray(/*elements*/ undefined, nodes.hasTrailingComma), nodes);
|
||||
}
|
||||
return visitNodes(nodes, visitor, test, start, count);
|
||||
}
|
||||
|
@ -7460,10 +7460,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const thisTag = getJSDocThisTag(signature.declaration);
|
||||
if (thisTag && thisTag.typeExpression) {
|
||||
return factory.createParameterDeclaration(
|
||||
/* modifiers */ undefined,
|
||||
/* dotDotDotToken */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
"this",
|
||||
/* questionToken */ undefined,
|
||||
/*questionToken*/ undefined,
|
||||
typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context)
|
||||
);
|
||||
}
|
||||
|
@ -7546,7 +7546,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
if (!context.tracker.canTrackSymbol) return;
|
||||
// get symbol of the first identifier of the entityName
|
||||
const firstIdentifier = getFirstIdentifier(accessExpression);
|
||||
const name = resolveName(firstIdentifier, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
||||
const name = resolveName(firstIdentifier, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
||||
if (name) {
|
||||
context.tracker.trackSymbol(name, enclosingDeclaration, SymbolFlags.Value);
|
||||
}
|
||||
|
@ -7911,7 +7911,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
function typeParameterShadowsNameInScope(escapedName: __String, context: NodeBuilderContext, type: TypeParameter) {
|
||||
const result = resolveName(context.enclosingDeclaration, escapedName, SymbolFlags.Type, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false);
|
||||
const result = resolveName(context.enclosingDeclaration, escapedName, SymbolFlags.Type, /*nameNotFoundMessage*/ undefined, escapedName, /*isUse*/ false);
|
||||
if (result) {
|
||||
if (result.flags & SymbolFlags.TypeParameter && result === type.symbol) {
|
||||
return false;
|
||||
|
@ -8182,7 +8182,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
introducesError = true;
|
||||
return { introducesError, node };
|
||||
}
|
||||
const sym = resolveEntityName(leftmost, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveALias*/ true);
|
||||
const sym = resolveEntityName(leftmost, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true);
|
||||
if (sym) {
|
||||
if (isSymbolAccessible(sym, context.enclosingDeclaration, SymbolFlags.All, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible) {
|
||||
introducesError = true;
|
||||
|
@ -8256,7 +8256,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
/*modifiers*/ undefined,
|
||||
[factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*dotdotdotToken*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
"x",
|
||||
/*questionToken*/ undefined,
|
||||
visitNode(node.typeArguments![0], visitExistingNodeTreeSymbols, isTypeNode)
|
||||
|
@ -8377,8 +8377,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
function symbolTableToDeclarationStatements(symbolTable: SymbolTable, context: NodeBuilderContext, bundled?: boolean): Statement[] {
|
||||
const serializePropertySymbolForClass = makeSerializePropertySymbol<ClassElement>(factory.createPropertyDeclaration, SyntaxKind.MethodDeclaration, /*useAcessors*/ true);
|
||||
const serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol<TypeElement>((mods, name, question, type) => factory.createPropertySignature(mods, name, question, type), SyntaxKind.MethodSignature, /*useAcessors*/ false);
|
||||
const serializePropertySymbolForClass = makeSerializePropertySymbol<ClassElement>(factory.createPropertyDeclaration, SyntaxKind.MethodDeclaration, /*useAccessors*/ true);
|
||||
const serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol<TypeElement>((mods, name, question, type) => factory.createPropertySignature(mods, name, question, type), SyntaxKind.MethodSignature, /*useAccessors*/ false);
|
||||
|
||||
// TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of
|
||||
// declaration mapping
|
||||
|
@ -8400,7 +8400,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const tracker: SymbolTracker = {
|
||||
...oldcontext.tracker.inner,
|
||||
trackSymbol: (sym, decl, meaning) => {
|
||||
const accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false);
|
||||
const accessibleResult = isSymbolAccessible(sym, decl, meaning, /*shouldComputeAliasesToMakeVisible*/ false);
|
||||
if (accessibleResult.accessibility === SymbolAccessibility.Accessible) {
|
||||
// Lookup the root symbol of the chain of refs we'll use to access it and serialize it
|
||||
const chain = lookupSymbolChainWorker(sym, context, meaning);
|
||||
|
@ -8463,7 +8463,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
factory.createNodeArray([...ns.body.statements, factory.createExportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*isTypeOnly*/ false,
|
||||
factory.createNamedExports(map(flatMap(excessExports, e => getNamesOfDeclaration(e)), id => factory.createExportSpecifier(/*isTypeOnly*/ false, /*alias*/ undefined, id))),
|
||||
factory.createNamedExports(map(flatMap(excessExports, e => getNamesOfDeclaration(e)), id => factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, id))),
|
||||
/*moduleSpecifier*/ undefined
|
||||
)])
|
||||
)
|
||||
|
@ -8801,7 +8801,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
}
|
||||
if (needsPostExportDefault) {
|
||||
addResult(factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), ModifierFlags.None);
|
||||
addResult(factory.createExportAssignment(/*modifiers*/ undefined, /*isExportEquals*/ false, factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), ModifierFlags.None);
|
||||
}
|
||||
else if (needsExportDeclaration) {
|
||||
addResult(factory.createExportDeclaration(
|
||||
|
@ -9225,7 +9225,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
factory.createIdentifier(localName)
|
||||
)])),
|
||||
factory.createStringLiteral(specifier),
|
||||
/*importClause*/ undefined
|
||||
/*assertClause*/ undefined
|
||||
), ModifierFlags.None);
|
||||
break;
|
||||
}
|
||||
|
@ -9306,7 +9306,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const specifier = bundled ? factory.createStringLiteral(generatedSpecifier) : (node as NamespaceImport).parent.parent.moduleSpecifier;
|
||||
addResult(factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, factory.createNamespaceImport(factory.createIdentifier(localName))),
|
||||
factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, factory.createNamespaceImport(factory.createIdentifier(localName))),
|
||||
specifier,
|
||||
(node as NamespaceImport).parent.parent.assertClause
|
||||
), ModifierFlags.None);
|
||||
|
@ -9327,7 +9327,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(
|
||||
/*isTypeOnly*/ false,
|
||||
/*importClause*/ undefined,
|
||||
/*name*/ undefined,
|
||||
factory.createNamedImports([
|
||||
factory.createImportSpecifier(
|
||||
/*isTypeOnly*/ false,
|
||||
|
@ -9697,7 +9697,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context))
|
||||
], NodeFlags.Const));
|
||||
addResult(statement, ModifierFlags.None);
|
||||
return factory.createExpressionWithTypeArguments(factory.createIdentifier(tempName), /*typeArgs*/ undefined);
|
||||
return factory.createExpressionWithTypeArguments(factory.createIdentifier(tempName), /*typeArguments*/ undefined);
|
||||
}
|
||||
|
||||
function trySerializeAsTypeReference(t: Type, flags: SymbolFlags) {
|
||||
|
@ -9724,7 +9724,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
return ref;
|
||||
}
|
||||
if (t.symbol) {
|
||||
return factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, SymbolFlags.Type), /*typeArgs*/ undefined);
|
||||
return factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, SymbolFlags.Type), /*typeArguments*/ undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10067,7 +10067,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const internalModuleReference = declaration.moduleReference as Identifier | QualifiedName;
|
||||
const firstIdentifier = getFirstIdentifier(internalModuleReference);
|
||||
const importSymbol = resolveName(declaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace,
|
||||
undefined, undefined, /*isUse*/ false);
|
||||
/*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
if (importSymbol && visited) {
|
||||
if (tryAddToSet(visited, getSymbolId(importSymbol))) {
|
||||
buildVisibleNodeList(importSymbol.declarations);
|
||||
|
@ -10979,7 +10979,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
symbol.links.bindingElement = e;
|
||||
members.set(symbol.escapedName, symbol);
|
||||
});
|
||||
const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo ? [stringIndexInfo] : emptyArray);
|
||||
const result = createAnonymousType(/*symbol*/ undefined, members, emptyArray, emptyArray, stringIndexInfo ? [stringIndexInfo] : emptyArray);
|
||||
result.objectFlags |= objectFlags;
|
||||
if (includePatternInType) {
|
||||
result.pattern = pattern;
|
||||
|
@ -11205,7 +11205,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|| isVariableDeclaration(declaration)
|
||||
|| isBindingElement(declaration)
|
||||
|| isJSDocPropertyLikeTag(declaration)) {
|
||||
type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true);
|
||||
type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
||||
}
|
||||
// getTypeOfSymbol dispatches some JS merges incorrectly because their symbol flags are not mutually exclusive.
|
||||
// Re-dispatch based on valueDeclaration.kind instead.
|
||||
|
@ -11278,7 +11278,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
getAnnotatedAccessorType(setter) ||
|
||||
getAnnotatedAccessorType(accessor) ||
|
||||
getter && getter.body && getReturnTypeFromBody(getter) ||
|
||||
accessor && accessor.initializer && getWidenedTypeForVariableLikeDeclaration(accessor, /*includeOptionality*/ true);
|
||||
accessor && accessor.initializer && getWidenedTypeForVariableLikeDeclaration(accessor, /*reportErrors*/ true);
|
||||
if (!type) {
|
||||
if (setter && !isPrivateWithinAmbient(setter)) {
|
||||
errorOrSuggestion(noImplicitAny, setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
||||
|
@ -11401,7 +11401,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
const targetSymbol = resolveAlias(symbol);
|
||||
const exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol)!, /*dontResolveAlias*/ true);
|
||||
const exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol)!, /*dontRecursivelyResolve*/ true);
|
||||
const declaredType = firstDefined(exportSymbol?.declarations, d => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : undefined);
|
||||
// It only makes sense to get the type of a value symbol. If the result of resolving
|
||||
// the alias is not a value, then it has no type. To get the type associated with a
|
||||
|
@ -12705,7 +12705,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const declaration = getClassLikeDeclarationOfSymbol(classType.symbol);
|
||||
const isAbstract = !!declaration && hasSyntacticModifier(declaration, ModifierFlags.Abstract);
|
||||
if (baseSignatures.length === 0) {
|
||||
return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? SignatureFlags.Abstract : SignatureFlags.None)];
|
||||
return [createSignature(/*declaration*/ undefined, classType.localTypeParameters, /*thisParameter*/ undefined, emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? SignatureFlags.Abstract : SignatureFlags.None)];
|
||||
}
|
||||
const baseTypeNode = getBaseTypeNodeOfClass(classType)!;
|
||||
const isJavaScript = isInJSFile(baseTypeNode);
|
||||
|
@ -13815,7 +13815,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
function getApparentTypeOfIntersectionType(type: IntersectionType) {
|
||||
return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, /*apparentType*/ true));
|
||||
return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, /*needApparentType*/ true));
|
||||
}
|
||||
|
||||
function getResolvedTypeParameterDefault(typeParameter: TypeParameter): Type | undefined {
|
||||
|
@ -14488,7 +14488,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const type = isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
|
||||
// Include parameter symbol instead of property symbol in the signature
|
||||
if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) {
|
||||
const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined, /*isUse*/ false);
|
||||
const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
paramSymbol = resolvedSymbol!;
|
||||
}
|
||||
if (i === 0 && paramSymbol.escapedName === InternalSymbolName.This) {
|
||||
|
@ -15548,7 +15548,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const indexed = getTypeFromTypeNode(typeArgs[0]);
|
||||
const target = getTypeFromTypeNode(typeArgs[1]);
|
||||
const indexInfo = indexed === stringType || indexed === numberType ? [createIndexInfo(indexed, target, /*isReadonly*/ false)] : emptyArray;
|
||||
return createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, indexInfo);
|
||||
return createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, indexInfo);
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
|
@ -15672,7 +15672,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
function getGlobalSymbol(name: __String, meaning: SymbolFlags, diagnostic: DiagnosticMessage | undefined): Symbol | undefined {
|
||||
// Don't track references for global symbols anyway, so value if `isReference` is arbitrary
|
||||
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
|
||||
return resolveName(/*location*/ undefined, name, meaning, diagnostic, name, /*isUse*/ false, /*excludeGlobals*/ false, /*getSpellingSuggestions*/ false);
|
||||
}
|
||||
|
||||
function getGlobalType(name: __String, arity: 0, reportErrors: true): ObjectType;
|
||||
|
@ -17375,20 +17375,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
else {
|
||||
let errorInfo: DiagnosticMessageChain | undefined;
|
||||
if (indexType.flags & TypeFlags.EnumLiteral) {
|
||||
errorInfo = chainDiagnosticMessages(/* details */ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
|
||||
errorInfo = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
|
||||
}
|
||||
else if (indexType.flags & TypeFlags.UniqueESSymbol) {
|
||||
const symbolName = getFullyQualifiedName((indexType as UniqueESSymbolType).symbol, accessExpression);
|
||||
errorInfo = chainDiagnosticMessages(/* details */ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName + "]", typeToString(objectType));
|
||||
errorInfo = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName + "]", typeToString(objectType));
|
||||
}
|
||||
else if (indexType.flags & TypeFlags.StringLiteral) {
|
||||
errorInfo = chainDiagnosticMessages(/* details */ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, (indexType as StringLiteralType).value, typeToString(objectType));
|
||||
errorInfo = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, (indexType as StringLiteralType).value, typeToString(objectType));
|
||||
}
|
||||
else if (indexType.flags & TypeFlags.NumberLiteral) {
|
||||
errorInfo = chainDiagnosticMessages(/* details */ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, (indexType as NumberLiteralType).value, typeToString(objectType));
|
||||
errorInfo = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Property_0_does_not_exist_on_type_1, (indexType as NumberLiteralType).value, typeToString(objectType));
|
||||
}
|
||||
else if (indexType.flags & (TypeFlags.Number | TypeFlags.String)) {
|
||||
errorInfo = chainDiagnosticMessages(/* details */ undefined, Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
|
||||
errorInfo = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
|
||||
}
|
||||
|
||||
errorInfo = chainDiagnosticMessages(
|
||||
|
@ -19372,7 +19372,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
return elaborated;
|
||||
}
|
||||
const resultObj: { errors?: Diagnostic[] } = errorOutputContainer || {};
|
||||
checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, /*message*/ undefined, containingMessageChain, resultObj);
|
||||
checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, /*headMessage*/ undefined, containingMessageChain, resultObj);
|
||||
if (resultObj.errors) {
|
||||
if (target.symbol && length(target.symbol.declarations)) {
|
||||
addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], createDiagnosticForNode(
|
||||
|
@ -19695,7 +19695,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const childrenPropName = childPropName === undefined ? "children" : unescapeLeadingUnderscores(childPropName);
|
||||
const childrenTargetType = getIndexedAccessType(target, getStringLiteralType(childrenPropName));
|
||||
const diagnostic = Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2;
|
||||
invalidTextDiagnostic = { ...diagnostic, key: "!!ALREADY FORMATTED!!", message: formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) };
|
||||
invalidTextDiagnostic = { ...diagnostic, key: "!!ALREADY FORMATTED!!", message: formatMessage(/*dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) };
|
||||
}
|
||||
return invalidTextDiagnostic;
|
||||
}
|
||||
|
@ -19785,7 +19785,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
target: Signature,
|
||||
ignoreReturnTypes: boolean): boolean {
|
||||
return compareSignaturesRelated(source, target, ignoreReturnTypes ? SignatureCheckMode.IgnoreReturnTypes : SignatureCheckMode.None, /*reportErrors*/ false,
|
||||
/*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== Ternary.False;
|
||||
/*errorReporter*/ undefined, /*incompatibleErrorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== Ternary.False;
|
||||
}
|
||||
|
||||
type ErrorReporter = (message: DiagnosticMessage, ...args: DiagnosticArguments) => void;
|
||||
|
@ -20316,7 +20316,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
reportError(...stack[0]);
|
||||
if (info) {
|
||||
// Actually do the last relation error
|
||||
reportRelationError(/*headMessage*/ undefined, ...info);
|
||||
reportRelationError(/*message*/ undefined, ...info);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -20411,7 +20411,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
if (info) {
|
||||
// Actually do the last relation error
|
||||
reportRelationError(/*headMessage*/ undefined, ...info);
|
||||
reportRelationError(/*message*/ undefined, ...info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21070,7 +21070,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
if (overflow) {
|
||||
return Ternary.False;
|
||||
}
|
||||
const id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
||||
const id = getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ false);
|
||||
const entry = relation.get(id);
|
||||
if (entry !== undefined) {
|
||||
if (reportErrors && entry & RelationComparisonResult.Failed && !(entry & RelationComparisonResult.Reported)) {
|
||||
|
@ -21456,7 +21456,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
// create a new chain for the constraint error
|
||||
resetErrorInfo(saveErrorInfo);
|
||||
}
|
||||
if (result = isRelatedTo(source, constraint, RecursionFlags.Target, reportErrors, /* headMessage */ undefined, intersectionState)) {
|
||||
if (result = isRelatedTo(source, constraint, RecursionFlags.Target, reportErrors, /*headMessage*/ undefined, intersectionState)) {
|
||||
return result;
|
||||
}
|
||||
// prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
|
||||
|
@ -21936,15 +21936,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
for (const type of matchingTypes) {
|
||||
result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*optionalsOnly*/ false, IntersectionState.None);
|
||||
if (result) {
|
||||
result &= signaturesRelatedTo(source, type, SignatureKind.Call, /*reportStructuralErrors*/ false, IntersectionState.None);
|
||||
result &= signaturesRelatedTo(source, type, SignatureKind.Call, /*reportErrors*/ false, IntersectionState.None);
|
||||
if (result) {
|
||||
result &= signaturesRelatedTo(source, type, SignatureKind.Construct, /*reportStructuralErrors*/ false, IntersectionState.None);
|
||||
result &= signaturesRelatedTo(source, type, SignatureKind.Construct, /*reportErrors*/ false, IntersectionState.None);
|
||||
if (result && !(isTupleType(source) && isTupleType(type))) {
|
||||
// Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the
|
||||
// element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems
|
||||
// with index type assignability as the types for the excluded discriminants are still included
|
||||
// in the index type.
|
||||
result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, IntersectionState.None);
|
||||
result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportErrors*/ false, IntersectionState.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23709,7 +23709,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const originalKeywordKind = identifierToKeywordKind(param.name);
|
||||
if ((isCallSignatureDeclaration(param.parent) || isMethodSignature(param.parent) || isFunctionTypeNode(param.parent)) &&
|
||||
param.parent.parameters.indexOf(param) > -1 &&
|
||||
(resolveName(param, param.name.escapedText, SymbolFlags.Type, undefined, param.name.escapedText, /*isUse*/ true) ||
|
||||
(resolveName(param, param.name.escapedText, SymbolFlags.Type, /*nameNotFoundMessage*/ undefined, param.name.escapedText, /*isUse*/ true) ||
|
||||
originalKeywordKind && isTypeNodeKind(originalKeywordKind))) {
|
||||
const newName = "arg" + param.parent.parameters.indexOf(param);
|
||||
const typeName = declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
|
||||
|
@ -23987,7 +23987,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
members.set(name, literalProp);
|
||||
});
|
||||
const indexInfos = type.flags & TypeFlags.String ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : emptyArray;
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfos);
|
||||
return createAnonymousType(/*symbol*/ undefined, members, emptyArray, emptyArray, indexInfos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28154,7 +28154,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const isNodeInTypeQuery = isInTypeQuery(node);
|
||||
// Stop at the first arrow function so that we can
|
||||
// tell whether 'this' needs to be captured.
|
||||
let container = getThisContainer(node, /* includeArrowFunctions */ true, /*includeClassComputedPropertyName*/ true);
|
||||
let container = getThisContainer(node, /*includeArrowFunctions*/ true, /*includeClassComputedPropertyName*/ true);
|
||||
let capturedByArrowFunction = false;
|
||||
let thisInComputedPropertyName = false;
|
||||
|
||||
|
@ -28165,7 +28165,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
while (true) {
|
||||
// Now skip arrow functions to get the "real" owner of 'this'.
|
||||
if (container.kind === SyntaxKind.ArrowFunction) {
|
||||
container = getThisContainer(container, /* includeArrowFunctions */ false, !thisInComputedPropertyName);
|
||||
container = getThisContainer(container, /*includeArrowFunctions*/ false, !thisInComputedPropertyName);
|
||||
capturedByArrowFunction = true;
|
||||
}
|
||||
|
||||
|
@ -28994,7 +28994,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
else if (isIdentifier(lhs.expression)) {
|
||||
const id = lhs.expression;
|
||||
const parentSymbol = resolveName(id, id.escapedText, SymbolFlags.Value, undefined, id.escapedText, /*isUse*/ true);
|
||||
const parentSymbol = resolveName(id, id.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, id.escapedText, /*isUse*/ true);
|
||||
if (parentSymbol) {
|
||||
const annotated = parentSymbol.valueDeclaration && getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
|
||||
if (annotated) {
|
||||
|
@ -29036,7 +29036,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
return false;
|
||||
}
|
||||
const name = ((declaration.left as AccessExpression).expression as Identifier).escapedText;
|
||||
const symbol = resolveName(declaration.left, name, SymbolFlags.Value, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true);
|
||||
const symbol = resolveName(declaration.left, name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true, /*excludeGlobals*/ true);
|
||||
return isThisInitializedDeclaration(symbol?.valueDeclaration);
|
||||
}
|
||||
|
||||
|
@ -30581,7 +30581,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
if (!resolvedNamespace || resolvedNamespace === unknownSymbol) {
|
||||
const namespaceName = getJsxNamespace(location);
|
||||
resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false);
|
||||
resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*nameNotFoundMessage*/ undefined, namespaceName, /*isUse*/ false);
|
||||
}
|
||||
|
||||
if (resolvedNamespace) {
|
||||
|
@ -30598,7 +30598,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
}
|
||||
// JSX global fallback
|
||||
const s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined));
|
||||
const s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, SymbolFlags.Namespace, /*diagnostic*/ undefined));
|
||||
if (s === unknownSymbol) {
|
||||
return undefined!; // TODO: GH#18217
|
||||
}
|
||||
|
@ -30732,7 +30732,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
function generateInitialErrorChain(): DiagnosticMessageChain {
|
||||
const componentName = getTextOfNode(openingLikeElement.tagName);
|
||||
return chainDiagnosticMessages(/* details */ undefined, Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
|
||||
return chainDiagnosticMessages(/*details*/ undefined, Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31090,7 +31090,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
function getThisParameterFromNodeContext(node: Node) {
|
||||
const thisContainer = getThisContainer(node, /* includeArrowFunctions */ false, /*includeClassComputedPropertyName*/ false);
|
||||
const thisContainer = getThisContainer(node, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
|
||||
return thisContainer && isFunctionLike(thisContainer) ? getThisParameter(thisContainer) : undefined;
|
||||
}
|
||||
|
||||
|
@ -31251,7 +31251,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
checkGrammarPrivateIdentifierExpression(privId);
|
||||
const symbol = getSymbolForPrivateIdentifierExpression(privId);
|
||||
if (symbol) {
|
||||
markPropertyAsReferenced(symbol, /* nodeForCheckWriteOnly: */ undefined, /* isThisAccess: */ false);
|
||||
markPropertyAsReferenced(symbol, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false);
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
|
@ -31897,7 +31897,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
function isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode | QualifiedName, type: Type, property: Symbol): boolean {
|
||||
return isPropertyAccessible(node,
|
||||
node.kind === SyntaxKind.PropertyAccessExpression && node.expression.kind === SyntaxKind.SuperKeyword,
|
||||
/* isWrite */ false,
|
||||
/*isWrite*/ false,
|
||||
type,
|
||||
property);
|
||||
// Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context.
|
||||
|
@ -31915,7 +31915,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
const prop = getPropertyOfType(type, propertyName);
|
||||
return !!prop && isPropertyAccessible(node, isSuper, /* isWrite */ false, type, prop);
|
||||
return !!prop && isPropertyAccessible(node, isSuper, /*isWrite*/ false, type, prop);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32808,7 +32808,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
function isPromiseResolveArityError(node: CallLikeExpression) {
|
||||
if (!isCallExpression(node) || !isIdentifier(node.expression)) return false;
|
||||
|
||||
const symbol = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, undefined, undefined, false);
|
||||
const symbol = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
const decl = symbol?.valueDeclaration;
|
||||
if (!decl || !isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !isNewExpression(decl.parent.parent) || !isIdentifier(decl.parent.parent.expression)) {
|
||||
return false;
|
||||
|
@ -33309,7 +33309,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
thisParameter,
|
||||
parameters,
|
||||
/*resolvedReturnType*/ getIntersectionType(candidates.map(getReturnTypeOfSignature)),
|
||||
/*typePredicate*/ undefined,
|
||||
/*resolvedTypePredicate*/ undefined,
|
||||
minArgumentCount,
|
||||
flags);
|
||||
}
|
||||
|
@ -33465,7 +33465,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
let relatedInformation: DiagnosticRelatedInformation | undefined;
|
||||
if (node.arguments.length === 1) {
|
||||
const text = getSourceFileOfNode(node).text;
|
||||
if (isLineBreak(text.charCodeAt(skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) {
|
||||
if (isLineBreak(text.charCodeAt(skipTrivia(text, node.expression.end, /*stopAfterLineBreak*/ true) - 1))) {
|
||||
relatedInformation = createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon);
|
||||
}
|
||||
}
|
||||
|
@ -33714,7 +33714,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
if (!hasSignatures) {
|
||||
errorInfo = chainDiagnosticMessages(
|
||||
/* detials */ undefined,
|
||||
/*details*/ undefined,
|
||||
isCall ?
|
||||
Diagnostics.No_constituent_of_type_0_is_callable :
|
||||
Diagnostics.No_constituent_of_type_0_is_constructable,
|
||||
|
@ -33763,7 +33763,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
|
||||
}
|
||||
if (isCallExpression(errorTarget.parent)) {
|
||||
const { start, length } = getDiagnosticSpanForCallNode(errorTarget.parent, /* doNotIncludeArguments */ true);
|
||||
const { start, length } = getDiagnosticSpanForCallNode(errorTarget.parent, /*doNotIncludeArguments*/ true);
|
||||
diagnostic.start = start;
|
||||
diagnostic.length = length;
|
||||
}
|
||||
|
@ -33889,7 +33889,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const typeSymbol = exports && getSymbol(exports, JsxNames.Element, SymbolFlags.Type);
|
||||
const returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, SymbolFlags.Type, node);
|
||||
const declaration = factory.createFunctionTypeNode(/*typeParameters*/ undefined,
|
||||
[factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))],
|
||||
[factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "props", /*questionToken*/ undefined, nodeBuilder.typeToTypeNode(result, node))],
|
||||
returnNode ? factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : factory.createKeywordTypeNode(SyntaxKind.AnyKeyword)
|
||||
);
|
||||
const parameterSymbol = createSymbol(SymbolFlags.FunctionScopedVariable, "props" as __String);
|
||||
|
@ -33900,7 +33900,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
/*thisParameter*/ undefined,
|
||||
[parameterSymbol],
|
||||
typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType,
|
||||
/*returnTypePredicate*/ undefined,
|
||||
/*resolvedTypePredicate*/ undefined,
|
||||
1,
|
||||
SignatureFlags.None
|
||||
);
|
||||
|
@ -34272,7 +34272,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
// resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal
|
||||
const moduleSymbol = resolveExternalModuleName(node, specifier);
|
||||
if (moduleSymbol) {
|
||||
const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
||||
const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontResolveAlias*/ true, /*suppressInteropError*/ false);
|
||||
if (esModuleSymbol) {
|
||||
return createPromiseReturnType(node,
|
||||
getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
||||
|
@ -34328,7 +34328,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
function isCommonJsRequire(node: Node): boolean {
|
||||
if (!isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
if (!isRequireCall(node, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34510,7 +34510,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
hasSignatures ||= resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0;
|
||||
hasApplicableSignature ||= callSignatures.length !== 0 || constructSignatures.length !== 0;
|
||||
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
||||
const result = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos) as ResolvedType & InstantiationExpressionType;
|
||||
const result = createAnonymousType(/*symbol*/ undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos) as ResolvedType & InstantiationExpressionType;
|
||||
result.objectFlags |= ObjectFlags.InstantiationExpressionType;
|
||||
result.node = node;
|
||||
return result;
|
||||
|
@ -34992,11 +34992,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
|
||||
function createClassAccessorDecoratorTargetType(thisType: Type, valueType: Type) {
|
||||
return tryCreateTypeReference(getGlobalClassAccessorDecoratorTargetType(/*reportError*/ true), [thisType, valueType]);
|
||||
return tryCreateTypeReference(getGlobalClassAccessorDecoratorTargetType(/*reportErrors*/ true), [thisType, valueType]);
|
||||
}
|
||||
|
||||
function createClassAccessorDecoratorResultType(thisType: Type, valueType: Type) {
|
||||
return tryCreateTypeReference(getGlobalClassAccessorDecoratorResultType(/*reportError*/ true), [thisType, valueType]);
|
||||
return tryCreateTypeReference(getGlobalClassAccessorDecoratorResultType(/*reportErrors*/ true), [thisType, valueType]);
|
||||
}
|
||||
|
||||
function createClassFieldDecoratorInitializerMutatorType(thisType: Type, valueType: Type) {
|
||||
|
@ -35727,7 +35727,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
return links.contextFreeType;
|
||||
}
|
||||
const returnType = getReturnTypeFromBody(node, checkMode);
|
||||
const returnOnlySignature = createSignature(undefined, undefined, undefined, emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
const returnOnlySignature = createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None);
|
||||
const returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], emptyArray, emptyArray);
|
||||
returnOnlyType.objectFlags |= ObjectFlags.NonInferrableType;
|
||||
return links.contextFreeType = returnOnlyType;
|
||||
|
@ -36937,7 +36937,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const propType = getTypeOfSymbol(prop);
|
||||
if (propType.symbol && propType.symbol.flags & SymbolFlags.Class) {
|
||||
const name = prop.escapedName;
|
||||
const symbol = resolveName(prop.valueDeclaration, name, SymbolFlags.Type, undefined, name, /*isUse*/ false);
|
||||
const symbol = resolveName(prop.valueDeclaration, name, SymbolFlags.Type, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false);
|
||||
if (symbol?.declarations && symbol.declarations.some(isJSDocTypedefTag)) {
|
||||
addDuplicateDeclarationErrorsForSymbols(symbol, Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name), prop);
|
||||
addDuplicateDeclarationErrorsForSymbols(prop, Diagnostics.Duplicate_identifier_0, unescapeLeadingUnderscores(name), symbol);
|
||||
|
@ -37618,7 +37618,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
// Optimize for the common case of a call to a function with a single non-generic call
|
||||
// signature where we can just fetch the return type without checking the arguments.
|
||||
if (isCallExpression(expr) && expr.expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
|
||||
if (isCallExpression(expr) && expr.expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !isSymbolOrSymbolForCall(expr)) {
|
||||
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
||||
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
|
||||
}
|
||||
|
@ -39791,7 +39791,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
|
||||
const rootName = getFirstIdentifier(typeName);
|
||||
const meaning = (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias;
|
||||
const rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
||||
const rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
||||
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) {
|
||||
if (canCollectSymbolAliasAccessabilityData
|
||||
&& symbolIsValue(rootSymbol)
|
||||
|
@ -40763,7 +40763,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const symbol = getSymbolOfDeclaration(node);
|
||||
if (symbol.flags & SymbolFlags.FunctionScopedVariable) {
|
||||
if (!isIdentifier(node.name)) return Debug.fail();
|
||||
const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
if (localDeclarationSymbol &&
|
||||
localDeclarationSymbol !== symbol &&
|
||||
localDeclarationSymbol.flags & SymbolFlags.BlockScopedVariable) {
|
||||
|
@ -41847,8 +41847,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
!allowAsyncIterables &&
|
||||
isForOfStatement(errorNode.parent) &&
|
||||
errorNode.parent.expression === errorNode &&
|
||||
getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
|
||||
isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)
|
||||
getGlobalAsyncIterableType(/*reportErrors*/ false) !== emptyGenericType &&
|
||||
isTypeAssignableTo(type, getGlobalAsyncIterableType(/*reportErrors*/ false)
|
||||
));
|
||||
return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
|
||||
}
|
||||
|
@ -42868,7 +42868,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
type,
|
||||
typeWithThis,
|
||||
param,
|
||||
/* memberIsParameterProperty */ true
|
||||
/*memberIsParameterProperty*/ true
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -42881,7 +42881,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
type,
|
||||
typeWithThis,
|
||||
member,
|
||||
/* memberIsParameterProperty */ false,
|
||||
/*memberIsParameterProperty*/ false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -43038,7 +43038,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
typeToString(typeWithThis),
|
||||
typeToString(baseWithThis)
|
||||
);
|
||||
if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, /*message*/ undefined, rootChain)) {
|
||||
if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, /*headMessage*/ undefined, rootChain)) {
|
||||
issuedMemberError = true;
|
||||
}
|
||||
}
|
||||
|
@ -43099,7 +43099,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
memberHasOverrideModifier,
|
||||
hasAbstractModifier(member),
|
||||
isStatic(member),
|
||||
/* memberIsParameterProperty */ false,
|
||||
/*memberIsParameterProperty*/ false,
|
||||
symbolName(memberSymbol),
|
||||
);
|
||||
}
|
||||
|
@ -45374,7 +45374,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const symbol = getIntrinsicTagSymbol(name.parent as JsxOpeningLikeElement);
|
||||
return symbol === unknownSymbol ? undefined : symbol;
|
||||
}
|
||||
const result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, getHostSignatureFromJSDoc(name));
|
||||
const result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, getHostSignatureFromJSDoc(name));
|
||||
if (!result && isJSDoc) {
|
||||
const container = findAncestor(name, or(isClassLike, isInterfaceDeclaration));
|
||||
if (container) {
|
||||
|
@ -45384,7 +45384,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
if (result && isJSDoc) {
|
||||
const container = getJSDocHost(name);
|
||||
if (container && isEnumMember(container) && container === result.valueDeclaration) {
|
||||
return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, getSourceFileOfNode(container)) || result;
|
||||
return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, getSourceFileOfNode(container)) || result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -45582,7 +45582,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
// 4). type A = import("./f/*gotToDefinitionHere*/oo")
|
||||
if ((isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
|
||||
((node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration) && (node.parent as ImportDeclaration).moduleSpecifier === node) ||
|
||||
((isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || isImportCall(node.parent)) ||
|
||||
((isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false)) || isImportCall(node.parent)) ||
|
||||
(isLiteralTypeNode(node.parent) && isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)
|
||||
) {
|
||||
return resolveExternalModuleName(node, node as LiteralExpression, ignoreErrors);
|
||||
|
@ -46351,7 +46351,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
}
|
||||
|
||||
return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
||||
return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46371,7 +46371,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
reference,
|
||||
reference.escapedText,
|
||||
SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias,
|
||||
/*nodeNotFoundMessage*/ undefined,
|
||||
/*nameNotFoundMessage*/ undefined,
|
||||
/*nameArg*/ undefined,
|
||||
/*isUse*/ true,
|
||||
/*excludeGlobals*/ undefined,
|
||||
|
@ -46767,7 +46767,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
autoArrayType = createArrayType(autoType);
|
||||
if (autoArrayType === emptyObjectType) {
|
||||
// autoArrayType is used as a marker, so even if global Array type is not defined, it needs to be a unique type
|
||||
autoArrayType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
autoArrayType = createAnonymousType(/*symbol*/ undefined, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
}
|
||||
|
||||
globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray" as __String, /*arity*/ 1) as GenericType || globalArrayType;
|
||||
|
@ -48114,7 +48114,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
// found matching label - verify that label usage is correct
|
||||
// continue can only target labels that are on iteration statements
|
||||
const isMisplacedContinueLabel = node.kind === SyntaxKind.ContinueStatement
|
||||
&& !isIterationStatement((current as LabeledStatement).statement, /*lookInLabeledStatement*/ true);
|
||||
&& !isIterationStatement((current as LabeledStatement).statement, /*lookInLabeledStatements*/ true);
|
||||
|
||||
if (isMisplacedContinueLabel) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
|
||||
|
@ -48130,7 +48130,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) {
|
||||
if (isIterationStatement(current, /*lookInLabeledStatements*/ false) && !node.label) {
|
||||
// unlabeled break or continue within iteration statement - ok
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1263,7 +1263,7 @@ function emitUsingBuildInfoWorker(
|
|||
declarationMapText,
|
||||
buildInfoPath,
|
||||
buildInfo,
|
||||
/*onlyOwnText*/ true
|
||||
/*oldFileOfCurrentEmit*/ true
|
||||
);
|
||||
const outputFiles: OutputFile[] = [];
|
||||
const prependNodes = createPrependNodes(config.projectReferences, getCommandLine, f => host.readFile(f), host);
|
||||
|
@ -1479,12 +1479,12 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
|||
}
|
||||
|
||||
function printBundle(bundle: Bundle): string {
|
||||
writeBundle(bundle, beginPrint(), /*sourceMapEmitter*/ undefined);
|
||||
writeBundle(bundle, beginPrint(), /*sourceMapGenerator*/ undefined);
|
||||
return endPrint();
|
||||
}
|
||||
|
||||
function printFile(sourceFile: SourceFile): string {
|
||||
writeFile(sourceFile, beginPrint(), /*sourceMapEmitter*/ undefined);
|
||||
writeFile(sourceFile, beginPrint(), /*sourceMapGenerator*/ undefined);
|
||||
return endPrint();
|
||||
}
|
||||
|
||||
|
@ -3122,7 +3122,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
|||
function emitParenthesizedExpression(node: ParenthesizedExpression) {
|
||||
const openParenPos = emitTokenWithComment(SyntaxKind.OpenParenToken, node.pos, writePunctuation, node);
|
||||
const indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
|
||||
emitExpression(node.expression, /*parenthesizerRules*/ undefined);
|
||||
emitExpression(node.expression, /*parenthesizerRule*/ undefined);
|
||||
writeLineSeparatorsAfter(node.expression, node);
|
||||
decreaseIndentIf(indented);
|
||||
emitTokenWithComment(SyntaxKind.CloseParenToken, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
|
||||
|
@ -3354,7 +3354,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
|||
}
|
||||
|
||||
function emitAsExpression(node: AsExpression) {
|
||||
emitExpression(node.expression, /*parenthesizerRules*/ undefined);
|
||||
emitExpression(node.expression, /*parenthesizerRule*/ undefined);
|
||||
if (node.type) {
|
||||
writeSpace();
|
||||
writeKeyword("as");
|
||||
|
@ -3369,7 +3369,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
|||
}
|
||||
|
||||
function emitSatisfiesExpression(node: SatisfiesExpression) {
|
||||
emitExpression(node.expression, /*parenthesizerRules*/ undefined);
|
||||
emitExpression(node.expression, /*parenthesizerRule*/ undefined);
|
||||
if (node.type) {
|
||||
writeSpace();
|
||||
writeKeyword("satisfies");
|
||||
|
@ -6013,9 +6013,9 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
|||
case SyntaxKind.SetAccessor:
|
||||
return generateNameForMethodOrAccessor(node as MethodDeclaration | AccessorDeclaration, privateName, prefix, suffix);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return makeTempVariableName(TempFlags.Auto, /*reserveInNestedScopes*/ true, privateName, prefix, suffix);
|
||||
return makeTempVariableName(TempFlags.Auto, /*reservedInNestedScopes*/ true, privateName, prefix, suffix);
|
||||
default:
|
||||
return makeTempVariableName(TempFlags.Auto, /*reserveInNestedScopes*/ false, privateName, prefix, suffix);
|
||||
return makeTempVariableName(TempFlags.Auto, /*reservedInNestedScopes*/ false, privateName, prefix, suffix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -664,7 +664,7 @@ export function createEmitHelperFactory(context: TransformationContext): EmitHel
|
|||
|
||||
function createClassPrivateFieldInHelper(state: Identifier, receiver: Expression) {
|
||||
context.requestEmitHelper(classPrivateFieldInHelper);
|
||||
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /* typeArguments*/ undefined, [state, receiver]);
|
||||
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /*typeArguments*/ undefined, [state, receiver]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ export function createParenthesizerRules(factory: NodeFactory): ParenthesizerRul
|
|||
const check = skipPartiallyEmittedExpressions(expression);
|
||||
let needsParens = isCommaSequence(check);
|
||||
if (!needsParens) {
|
||||
switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) {
|
||||
switch (getLeftmostExpression(check, /*stopAtCallExpressions*/ false).kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
needsParens = true;
|
||||
|
|
|
@ -1670,7 +1670,7 @@ export function createAccessorPropertySetRedirector(factory: NodeFactory, node:
|
|||
name,
|
||||
[factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*dotdotDotToken*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
"value"
|
||||
)],
|
||||
factory.createBlock([
|
||||
|
|
|
@ -1656,7 +1656,7 @@ function tryResolveJSModuleWorker(moduleName: string, initialDir: string, host:
|
|||
/*cache*/ undefined,
|
||||
Extensions.JavaScript,
|
||||
/*isConfigLookup*/ false,
|
||||
/*redirectedReferences*/ undefined);
|
||||
/*redirectedReference*/ undefined);
|
||||
}
|
||||
|
||||
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations {
|
||||
|
@ -2152,7 +2152,7 @@ function loadEntrypointsFromExportMap(
|
|||
}
|
||||
const resolvedTarget = combinePaths(scope.packageDirectory, target);
|
||||
const finalPath = getNormalizedAbsolutePath(resolvedTarget, state.host.getCurrentDirectory?.());
|
||||
const result = loadFileNameFromPackageJsonField(extensions, finalPath, /*recordOnlyFailures*/ false, state);
|
||||
const result = loadFileNameFromPackageJsonField(extensions, finalPath, /*onlyRecordFailures*/ false, state);
|
||||
if (result) {
|
||||
entrypoints = appendIfUnique(entrypoints, result, (a, b) => a.path === b.path);
|
||||
return true;
|
||||
|
|
|
@ -1675,7 +1675,7 @@ namespace Parser {
|
|||
}
|
||||
|
||||
// Set source file so that errors will be reported with this file name
|
||||
const sourceFile = createSourceFile(fileName, ScriptTarget.ES2015, ScriptKind.JSON, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, noop);
|
||||
const sourceFile = createSourceFile(fileName, ScriptTarget.ES2015, ScriptKind.JSON, /*isDeclarationFile*/ false, statements, endOfFileToken, sourceFlags, noop);
|
||||
|
||||
if (setParentNodes) {
|
||||
fixupParentReferences(sourceFile);
|
||||
|
@ -3501,7 +3501,7 @@ namespace Parser {
|
|||
entity = finishNode(
|
||||
factory.createQualifiedName(
|
||||
entity,
|
||||
parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false) as Identifier
|
||||
parseRightSideOfDot(allowReservedWords, /*allowPrivateIdentifiers*/ false) as Identifier
|
||||
),
|
||||
pos
|
||||
);
|
||||
|
@ -6088,7 +6088,7 @@ namespace Parser {
|
|||
}
|
||||
else {
|
||||
parseExpected(SyntaxKind.SlashToken);
|
||||
if (parseExpected(SyntaxKind.GreaterThanToken, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
|
||||
if (parseExpected(SyntaxKind.GreaterThanToken, /*diagnosticMessage*/ undefined, /*shouldAdvance*/ false)) {
|
||||
// manually advance the scanner in order to look for jsx text inside jsx
|
||||
if (inExpressionContext) {
|
||||
nextToken();
|
||||
|
@ -6138,7 +6138,7 @@ namespace Parser {
|
|||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
else {
|
||||
if (parseExpected(SyntaxKind.CloseBraceToken, /*message*/ undefined, /*shouldAdvance*/ false)) {
|
||||
if (parseExpected(SyntaxKind.CloseBraceToken, /*diagnosticMessage*/ undefined, /*shouldAdvance*/ false)) {
|
||||
scanJsxText();
|
||||
}
|
||||
}
|
||||
|
@ -6185,7 +6185,7 @@ namespace Parser {
|
|||
const pos = getNodePos();
|
||||
parseExpected(SyntaxKind.LessThanSlashToken);
|
||||
const tagName = parseJsxElementName();
|
||||
if (parseExpected(SyntaxKind.GreaterThanToken, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
|
||||
if (parseExpected(SyntaxKind.GreaterThanToken, /*diagnosticMessage*/ undefined, /*shouldAdvance*/ false)) {
|
||||
// manually advance the scanner in order to look for jsx text inside jsx
|
||||
if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) {
|
||||
nextToken();
|
||||
|
@ -6492,7 +6492,7 @@ namespace Parser {
|
|||
}
|
||||
break;
|
||||
case SyntaxKind.TemplateHead:
|
||||
return parseTemplateExpression(/* isTaggedTemplate */ false);
|
||||
return parseTemplateExpression(/*isTaggedTemplate*/ false);
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
return parsePrivateIdentifier();
|
||||
}
|
||||
|
@ -8476,7 +8476,7 @@ namespace Parser {
|
|||
|
||||
export namespace JSDocParser {
|
||||
export function parseJSDocTypeExpressionForTests(content: string, start: number | undefined, length: number | undefined): { jsDocTypeExpression: JSDocTypeExpression, diagnostics: Diagnostic[] } | undefined {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*syntaxCursor*/ undefined, ScriptKind.JS);
|
||||
scanner.setText(content, start, length);
|
||||
currentToken = scanner.scan();
|
||||
const jsDocTypeExpression = parseJSDocTypeExpression();
|
||||
|
@ -8510,7 +8510,7 @@ namespace Parser {
|
|||
const pos = getNodePos();
|
||||
const hasBrace = parseOptional(SyntaxKind.OpenBraceToken);
|
||||
const p2 = getNodePos();
|
||||
let entityName: EntityName | JSDocMemberName = parseEntityName(/* allowReservedWords*/ false);
|
||||
let entityName: EntityName | JSDocMemberName = parseEntityName(/*allowReservedWords*/ false);
|
||||
while (token() === SyntaxKind.PrivateIdentifier) {
|
||||
reScanHashToken(); // rescan #id as # id
|
||||
nextTokenJSDoc(); // then skip the #
|
||||
|
@ -8526,7 +8526,7 @@ namespace Parser {
|
|||
}
|
||||
|
||||
export function parseIsolatedJSDocComment(content: string, start: number | undefined, length: number | undefined): { jsDoc: JSDoc, diagnostics: Diagnostic[] } | undefined {
|
||||
initializeState("", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
initializeState("", content, ScriptTarget.Latest, /*syntaxCursor*/ undefined, ScriptKind.JS);
|
||||
const jsDoc = doInsideOfContext(NodeFlags.JSDoc, () => parseJSDocCommentWorker(start, length));
|
||||
|
||||
const sourceFile = { languageVariant: LanguageVariant.Standard, text: content } as SourceFile;
|
||||
|
|
|
@ -2134,7 +2134,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
|||
if (structureIsReused === StructureIsReused.Not) {
|
||||
// If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
|
||||
// the best we can do is fallback to the default logic.
|
||||
return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, /*resuedNames*/ undefined);
|
||||
return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, /*reusedNames*/ undefined);
|
||||
}
|
||||
|
||||
const oldSourceFile = !isString(containingFile) ? oldProgram && oldProgram.getSourceFile(containingFile.fileName) : undefined;
|
||||
|
@ -2541,7 +2541,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
|||
getEmitHost(writeFileCallback),
|
||||
/*targetSourceFile*/ undefined,
|
||||
/*transformers*/ noTransformers,
|
||||
/*emitOnlyDtsFiles*/ false,
|
||||
/*emitOnly*/ false,
|
||||
/*onlyBuildInfo*/ true
|
||||
);
|
||||
|
||||
|
@ -3276,7 +3276,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
|||
const r = /import|require/g;
|
||||
while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
|
||||
const node = getNodeAtPosition(file, r.lastIndex);
|
||||
if (shouldProcessRequires && isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
if (shouldProcessRequires && isRequireCall(node, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
||||
imports = append(imports, node.arguments[0]);
|
||||
}
|
||||
|
@ -3962,7 +3962,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
|||
if (host.getParsedCommandLine) {
|
||||
commandLine = host.getParsedCommandLine(refPath);
|
||||
if (!commandLine) {
|
||||
addFileToFilesByName(/*sourceFile*/ undefined, sourceFilePath, /*redirectedPath*/ undefined);
|
||||
addFileToFilesByName(/*file*/ undefined, sourceFilePath, /*redirectedPath*/ undefined);
|
||||
projectReferenceRedirects.set(sourceFilePath, false);
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -905,7 +905,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
|
|||
resolutions.forEach(watchFailedLookupLocationOfResolution);
|
||||
}
|
||||
else {
|
||||
resolutions.forEach(resolution => watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true));
|
||||
resolutions.forEach(resolution => watchAffectingLocationsOfResolution(resolution, /*addToResolutionsWithOnlyAffectingLocations*/ true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1743,7 +1743,7 @@ export function createScanner(languageVersion: ScriptTarget,
|
|||
tokenValue = scanString();
|
||||
return token = SyntaxKind.StringLiteral;
|
||||
case CharacterCodes.backtick:
|
||||
return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false);
|
||||
return token = scanTemplateAndSetTokenValue(/*isTaggedTemplate*/ false);
|
||||
case CharacterCodes.percent:
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
|
||||
return pos += 2, token = SyntaxKind.PercentEqualsToken;
|
||||
|
@ -2314,7 +2314,7 @@ export function createScanner(languageVersion: ScriptTarget,
|
|||
|
||||
function reScanTemplateHeadOrNoSubstitutionTemplate(): SyntaxKind {
|
||||
pos = tokenStart;
|
||||
return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true);
|
||||
return token = scanTemplateAndSetTokenValue(/*isTaggedTemplate*/ true);
|
||||
}
|
||||
|
||||
function reScanJsxToken(allowMultilineJsxText = true): JsxTokenSyntaxKind {
|
||||
|
|
|
@ -866,9 +866,9 @@ export function transformClassFields(context: TransformationContext): (x: Source
|
|||
filter(node.modifiers, (m): m is Modifier => isModifier(m) && !isStaticModifier(m) && !isAccessorModifier(m)),
|
||||
node.asteriskToken,
|
||||
functionName,
|
||||
/* typeParameters */ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/* type */ undefined,
|
||||
/*type*/ undefined,
|
||||
visitFunctionBody(node.body!, visitor, context)
|
||||
)
|
||||
)
|
||||
|
@ -1666,7 +1666,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
|
|||
info.brandCheckIdentifier,
|
||||
right,
|
||||
info.kind,
|
||||
/* f */ undefined
|
||||
/*f*/ undefined
|
||||
);
|
||||
case PrivateIdentifierKind.Field:
|
||||
return emitHelpers().createClassPrivateFieldSetHelper(
|
||||
|
@ -1750,7 +1750,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
|
|||
function visitExpressionWithTypeArgumentsInHeritageClause(node: ExpressionWithTypeArguments) {
|
||||
const facts = lexicalEnvironment?.data?.facts || ClassFacts.None;
|
||||
if (facts & ClassFacts.NeedsClassSuperReference) {
|
||||
const temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true);
|
||||
const temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true);
|
||||
getClassLexicalEnvironment().superClassReference = temp;
|
||||
return factory.updateExpressionWithTypeArguments(
|
||||
node,
|
||||
|
@ -2857,7 +2857,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
|
|||
const identifier =
|
||||
typeof name === "object" ? factory.getGeneratedNameForNode(name, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.ReservedInNestedScopes, prefix, suffix) :
|
||||
typeof name === "string" ? factory.createUniqueName(name, GeneratedIdentifierFlags.Optimistic, prefix, suffix) :
|
||||
factory.createTempVariable(/*recordTempVariable*/ undefined, /*reserveInNestedScopes*/ true, prefix, suffix);
|
||||
factory.createTempVariable(/*recordTempVariable*/ undefined, /*reservedInNestedScopes*/ true, prefix, suffix);
|
||||
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.BlockScopedBindingInLoop) {
|
||||
addBlockScopedVariable(identifier);
|
||||
|
|
|
@ -250,10 +250,10 @@ export function isInternalDeclaration(node: Node, currentSourceFile: SourceFile)
|
|||
// to handle
|
||||
// ... parameters, /** @internal */
|
||||
// public param: string
|
||||
getTrailingCommentRanges(text, skipTrivia(text, previousSibling.end + 1, /* stopAfterLineBreak */ false, /* stopAtComments */ true)),
|
||||
getTrailingCommentRanges(text, skipTrivia(text, previousSibling.end + 1, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true)),
|
||||
getLeadingCommentRanges(text, node.pos)
|
||||
)
|
||||
: getTrailingCommentRanges(text, skipTrivia(text, node.pos, /* stopAfterLineBreak */ false, /* stopAtComments */ true));
|
||||
: getTrailingCommentRanges(text, skipTrivia(text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true));
|
||||
return commentRanges && commentRanges.length && hasInternalAnnotation(last(commentRanges), currentSourceFile);
|
||||
}
|
||||
const leadingCommentRanges = parseTreeNode && getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
|
||||
|
@ -391,7 +391,7 @@ export function transformDeclarations(context: TransformationContext) {
|
|||
|
||||
function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
|
||||
if (symbol.flags & SymbolFlags.TypeParameter) return false;
|
||||
const issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true));
|
||||
const issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasToMarkVisible*/ true));
|
||||
recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
|
||||
return issuedDiagnostic;
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ export function transformDeclarations(context: TransformationContext) {
|
|||
return factory.updateBindingElement(
|
||||
elem,
|
||||
elem.dotDotDotToken,
|
||||
/* propertyName */ undefined,
|
||||
/*propertyName*/ undefined,
|
||||
elem.propertyName,
|
||||
shouldPrintWithInitializer(elem) ? elem.initializer : undefined
|
||||
);
|
||||
|
@ -1130,7 +1130,7 @@ export function transformDeclarations(context: TransformationContext) {
|
|||
if (isMethodDeclaration(input) || isMethodSignature(input)) {
|
||||
if (hasEffectiveModifier(input, ModifierFlags.Private)) {
|
||||
if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload
|
||||
return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
|
||||
return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1655,7 +1655,7 @@ export function transformDeclarations(context: TransformationContext) {
|
|||
elems.push(factory.createPropertyDeclaration(
|
||||
ensureModifiers(param),
|
||||
elem.name as Identifier,
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
ensureType(elem, /*type*/ undefined),
|
||||
/*initializer*/ undefined
|
||||
));
|
||||
|
@ -1673,7 +1673,7 @@ export function transformDeclarations(context: TransformationContext) {
|
|||
factory.createPropertyDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createPrivateIdentifier("#private"),
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined
|
||||
)
|
||||
|
|
|
@ -2543,7 +2543,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile
|
|||
visitor,
|
||||
context,
|
||||
FlattenLevel.All,
|
||||
/*value*/ undefined,
|
||||
/*rval*/ undefined,
|
||||
(ancestorFacts & HierarchyFacts.ExportedVariableStatement) !== 0
|
||||
);
|
||||
}
|
||||
|
|
|
@ -917,11 +917,11 @@ export function createSuperAccessVariableStatement(factory: NodeFactory, resolve
|
|||
getterAndSetter.push(factory.createPropertyAssignment(
|
||||
"get",
|
||||
factory.createArrowFunction(
|
||||
/* modifiers */ undefined,
|
||||
/* typeParameters */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/* parameters */[],
|
||||
/* type */ undefined,
|
||||
/* equalsGreaterThanToken */ undefined,
|
||||
/*type*/ undefined,
|
||||
/*equalsGreaterThanToken*/ undefined,
|
||||
setEmitFlags(
|
||||
factory.createPropertyAccessExpression(
|
||||
setEmitFlags(
|
||||
|
@ -939,20 +939,20 @@ export function createSuperAccessVariableStatement(factory: NodeFactory, resolve
|
|||
factory.createPropertyAssignment(
|
||||
"set",
|
||||
factory.createArrowFunction(
|
||||
/* modifiers */ undefined,
|
||||
/* typeParameters */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/* parameters */[
|
||||
factory.createParameterDeclaration(
|
||||
/* modifiers */ undefined,
|
||||
/* dotDotDotToken */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
"v",
|
||||
/* questionToken */ undefined,
|
||||
/* type */ undefined,
|
||||
/* initializer */ undefined
|
||||
/*questionToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined
|
||||
)
|
||||
],
|
||||
/* type */ undefined,
|
||||
/* equalsGreaterThanToken */ undefined,
|
||||
/*type*/ undefined,
|
||||
/*equalsGreaterThanToken*/ undefined,
|
||||
factory.createAssignment(
|
||||
setEmitFlags(
|
||||
factory.createPropertyAccessExpression(
|
||||
|
@ -978,22 +978,22 @@ export function createSuperAccessVariableStatement(factory: NodeFactory, resolve
|
|||
);
|
||||
});
|
||||
return factory.createVariableStatement(
|
||||
/* modifiers */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
factory.createVariableDeclarationList(
|
||||
[
|
||||
factory.createVariableDeclaration(
|
||||
factory.createUniqueName("_super", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel),
|
||||
/*exclamationToken*/ undefined,
|
||||
/* type */ undefined,
|
||||
/*type*/ undefined,
|
||||
factory.createCallExpression(
|
||||
factory.createPropertyAccessExpression(
|
||||
factory.createIdentifier("Object"),
|
||||
"create"
|
||||
),
|
||||
/* typeArguments */ undefined,
|
||||
/*typeArguments*/ undefined,
|
||||
[
|
||||
factory.createNull(),
|
||||
factory.createObjectLiteralExpression(accessors, /* multiline */ true)
|
||||
factory.createObjectLiteralExpression(accessors, /*multiLine*/ true)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1042,7 +1042,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
|
|||
? undefined
|
||||
: node.asteriskToken,
|
||||
visitNode(node.name, visitor, isPropertyName),
|
||||
visitNode(/*questionToken*/ undefined, visitor, isQuestionToken),
|
||||
visitNode(/*node*/ undefined, visitor, isQuestionToken),
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, parameterVisitor, context),
|
||||
/*type*/ undefined,
|
||||
|
@ -1283,7 +1283,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
|
|||
context,
|
||||
FlattenLevel.ObjectRest,
|
||||
factory.getGeneratedNameForNode(parameter),
|
||||
/*doNotRecordTempVariablesInLine*/ false,
|
||||
/*hoistTempVariables*/ false,
|
||||
/*skipInitializer*/ true,
|
||||
);
|
||||
if (some(declarations)) {
|
||||
|
|
|
@ -445,7 +445,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc
|
|||
return visitTaggedTemplateExpression(node as TaggedTemplateExpression);
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
return visitPreOrPostfixUnaryExpression(node as PrefixUnaryExpression | PostfixUnaryExpression, /*discard*/ false);
|
||||
return visitPreOrPostfixUnaryExpression(node as PrefixUnaryExpression | PostfixUnaryExpression, /*discarded*/ false);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return visitPropertyAccessExpression(node as PropertyAccessExpression);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
|
@ -577,7 +577,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc
|
|||
// as we descend.
|
||||
|
||||
for (const member of node.members) {
|
||||
if (isNamedClassElement(member) && nodeOrChildIsDecorated(/*legacyDecorators*/ false, member, node)) {
|
||||
if (isNamedClassElement(member) && nodeOrChildIsDecorated(/*useLegacyDecorators*/ false, member, node)) {
|
||||
if (hasStaticModifier(member)) {
|
||||
staticExtraInitializersName ??= factory.createUniqueName("_staticExtraInitializers", GeneratedIdentifierFlags.Optimistic);
|
||||
}
|
||||
|
@ -893,7 +893,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc
|
|||
// static { ... }
|
||||
// ...
|
||||
// }
|
||||
const leadingStaticBlockBody = factory.createBlock(leadingBlockStatements, /*multiline*/ true);
|
||||
const leadingStaticBlockBody = factory.createBlock(leadingBlockStatements, /*multiLine*/ true);
|
||||
const leadingStaticBlock = factory.createClassStaticBlockDeclaration(leadingStaticBlockBody);
|
||||
if (shouldTransformPrivateStaticElementsInClass) {
|
||||
// We use `InternalEmitFlags.TransformPrivateStaticElements` as a marker on a class static block
|
||||
|
@ -915,7 +915,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc
|
|||
// ...
|
||||
// static { ... }
|
||||
// }
|
||||
const trailingStaticBlockBody = factory.createBlock(trailingBlockStatements, /*multiline*/ true);
|
||||
const trailingStaticBlockBody = factory.createBlock(trailingBlockStatements, /*multiLine*/ true);
|
||||
const trailingStaticBlock = factory.createClassStaticBlockDeclaration(trailingStaticBlockBody);
|
||||
newMembers = [...newMembers, trailingStaticBlock];
|
||||
}
|
||||
|
@ -980,8 +980,8 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc
|
|||
}
|
||||
|
||||
function isDecoratedClassLike(node: ClassLikeDeclaration) {
|
||||
return classOrConstructorParameterIsDecorated(/*legacyDecorators*/ false, node) ||
|
||||
childIsDecorated(/*legacyDecorators*/ false, node);
|
||||
return classOrConstructorParameterIsDecorated(/*useLegacyDecorators*/ false, node) ||
|
||||
childIsDecorated(/*useLegacyDecorators*/ false, node);
|
||||
}
|
||||
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
|
|
|
@ -105,7 +105,7 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B
|
|||
if (currentFileState.filenameDeclaration) {
|
||||
return currentFileState.filenameDeclaration.name;
|
||||
}
|
||||
const declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName));
|
||||
const declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel), /*exclamationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName));
|
||||
currentFileState.filenameDeclaration = declaration as VariableDeclaration & { name: Identifier };
|
||||
return currentFileState.filenameDeclaration.name;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B
|
|||
for (const [importSource, importSpecifiersMap] of arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries())) {
|
||||
if (isExternalModule(node)) {
|
||||
// Add `import` statement
|
||||
const importStatement = factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), /*assertClause*/ undefined);
|
||||
const importStatement = factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports(arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), /*assertClause*/ undefined);
|
||||
setParentRecursive(importStatement, /*incremental*/ false);
|
||||
statements = insertStatementAfterCustomPrologue(statements.slice(), importStatement);
|
||||
}
|
||||
|
@ -177,8 +177,8 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B
|
|||
// Add `require` statement
|
||||
const requireStatement = factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
||||
factory.createVariableDeclaration(
|
||||
factory.createObjectBindingPattern(arrayFrom(importSpecifiersMap.values(), s => factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name))),
|
||||
/*exclaimationToken*/ undefined,
|
||||
factory.createObjectBindingPattern(arrayFrom(importSpecifiersMap.values(), s => factory.createBindingElement(/*dotDotDotToken*/ undefined, s.propertyName, s.name))),
|
||||
/*exclamationToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])
|
||||
)
|
||||
|
|
|
@ -149,7 +149,7 @@ export function transformLegacyDecorators(context: TransformationContext): (x: S
|
|||
}
|
||||
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
if (!(classOrConstructorParameterIsDecorated(/*legacyDecorators*/ true, node) || childIsDecorated(/*legacyDecorators*/ true, node))) {
|
||||
if (!(classOrConstructorParameterIsDecorated(/*useLegacyDecorators*/ true, node) || childIsDecorated(/*useLegacyDecorators*/ true, node))) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ export function transformLegacyDecorators(context: TransformationContext): (x: S
|
|||
* @param member The class member.
|
||||
*/
|
||||
function isDecoratedClassElement(member: ClassElement, isStaticElement: boolean, parent: ClassLikeDeclaration) {
|
||||
return nodeOrChildIsDecorated(/*legacyDecorators*/ true, member, parent)
|
||||
return nodeOrChildIsDecorated(/*useLegacyDecorators*/ true, member, parent)
|
||||
&& isStaticElement === isStatic(member);
|
||||
}
|
||||
|
||||
|
|
|
@ -899,7 +899,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
|||
return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
|
||||
/*condition*/ factory.createIdentifier("__syncRequire"),
|
||||
/*questionToken*/ undefined,
|
||||
/*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
|
||||
/*whenTrue*/ createImportCallExpressionCommonJS(temp, /*isInlineable*/ true),
|
||||
/*colonToken*/ undefined,
|
||||
/*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)
|
||||
));
|
||||
|
@ -1319,7 +1319,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
|||
setOriginalNode(
|
||||
setTextRange(
|
||||
factory.createExpressionStatement(
|
||||
createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)
|
||||
createExportExpression(factory.getExportName(specifier), exportedValue, /*location*/ undefined, /*liveBinding*/ true)
|
||||
),
|
||||
specifier),
|
||||
specifier
|
||||
|
@ -1701,7 +1701,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
|||
|
||||
case SyntaxKind.NamedImports:
|
||||
for (const importBinding of namedBindings.elements) {
|
||||
statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true);
|
||||
statements = appendExportsOfDeclaration(statements, importBinding, /*liveBinding*/ true);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1816,7 +1816,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
|||
const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(idText(name));
|
||||
if (exportSpecifiers) {
|
||||
for (const exportSpecifier of exportSpecifiers) {
|
||||
statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /* allowComments */ undefined, liveBinding);
|
||||
statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /*allowComments*/ undefined, liveBinding);
|
||||
}
|
||||
}
|
||||
return statements;
|
||||
|
@ -1877,7 +1877,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
|||
* @param allowComments An optional value indicating whether to emit comments for the statement.
|
||||
*/
|
||||
function createExportStatement(name: Identifier, value: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean) {
|
||||
const statement = setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location);
|
||||
const statement = setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /*location*/ undefined, liveBinding)), location);
|
||||
startOnNewLine(statement);
|
||||
if (!allowComments) {
|
||||
setEmitFlags(statement, EmitFlags.NoComments);
|
||||
|
|
|
@ -478,7 +478,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc
|
|||
exportedNamesStorageRef,
|
||||
/*exclamationToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
factory.createObjectLiteralExpression(exportedNames, /*multiline*/ true)
|
||||
factory.createObjectLiteralExpression(exportedNames, /*multiLine*/ true)
|
||||
)
|
||||
])
|
||||
)
|
||||
|
@ -561,7 +561,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc
|
|||
[exports]
|
||||
)
|
||||
)
|
||||
], /*multiline*/ true)
|
||||
], /*multiLine*/ true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -643,7 +643,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc
|
|||
factory.createCallExpression(
|
||||
exportFunction,
|
||||
/*typeArguments*/ undefined,
|
||||
[factory.createObjectLiteralExpression(properties, /*multiline*/ true)]
|
||||
[factory.createObjectLiteralExpression(properties, /*multiLine*/ true)]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -800,7 +800,7 @@ export function transformTypeScript(context: TransformationContext) {
|
|||
|
||||
function getClassFacts(node: ClassDeclaration) {
|
||||
let facts = ClassFacts.None;
|
||||
if (some(getProperties(node, /*requireInitialized*/ true, /*isStatic*/ true))) facts |= ClassFacts.HasStaticInitializedProperties;
|
||||
if (some(getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true))) facts |= ClassFacts.HasStaticInitializedProperties;
|
||||
const extendsClauseElement = getEffectiveBaseTypeNode(node);
|
||||
if (extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== SyntaxKind.NullKeyword) facts |= ClassFacts.IsDerivedClass;
|
||||
if (classOrConstructorParameterIsDecorated(legacyDecorators, node)) facts |= ClassFacts.HasClassOrConstructorParameterDecorators;
|
||||
|
|
|
@ -1119,7 +1119,7 @@ function createBuildOrUpdateInvalidedProject<T extends BuilderProgram>(
|
|||
/*reportSummary*/ undefined,
|
||||
(name, text, writeByteOrderMark, _onError, _sourceFiles, data) => outputFiles.push({ name, text, writeByteOrderMark, data }),
|
||||
cancellationToken,
|
||||
/*emitOnlyDts*/ false,
|
||||
/*emitOnlyDtsFiles*/ false,
|
||||
customTransformers || state.host.getCustomTransformers?.(project)
|
||||
);
|
||||
// Don't emit .d.ts if there are decl file errors
|
||||
|
|
|
@ -2151,7 +2151,7 @@ export function createDiagnosticForRange(sourceFile: SourceFile, range: TextRang
|
|||
|
||||
/** @internal */
|
||||
export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan {
|
||||
const scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos);
|
||||
const scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError*/ undefined, pos);
|
||||
scanner.scan();
|
||||
const start = scanner.getTokenStart();
|
||||
return createTextSpanFromBounds(start, scanner.getTokenEnd());
|
||||
|
@ -2159,7 +2159,7 @@ export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): T
|
|||
|
||||
/** @internal */
|
||||
export function scanTokenAtPosition(sourceFile: SourceFile, pos: number) {
|
||||
const scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos);
|
||||
const scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError*/ undefined, pos);
|
||||
scanner.scan();
|
||||
return scanner.getToken();
|
||||
}
|
||||
|
@ -3657,7 +3657,7 @@ export function isSameEntityName(name: Expression, initializer: Expression): boo
|
|||
|
||||
/** @internal */
|
||||
export function getRightMostAssignedExpression(node: Expression): Expression {
|
||||
while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) {
|
||||
while (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) {
|
||||
node = node.right;
|
||||
}
|
||||
return node;
|
||||
|
@ -3936,7 +3936,7 @@ export function tryGetImportFromModuleSpecifier(node: StringLiteralLike): AnyVal
|
|||
case SyntaxKind.ExternalModuleReference:
|
||||
return (node.parent as ExternalModuleReference).parent as AnyValidImportOrReExport;
|
||||
case SyntaxKind.CallExpression:
|
||||
return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent as RequireOrImportCall : undefined;
|
||||
return isImportCall(node.parent) || isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) ? node.parent as RequireOrImportCall : undefined;
|
||||
case SyntaxKind.LiteralType:
|
||||
Debug.assert(isStringLiteral(node));
|
||||
return tryCast(node.parent.parent, isImportTypeNode) as ValidImportTypeNode | undefined;
|
||||
|
@ -6751,7 +6751,7 @@ export function getEffectiveModifierFlags(node: Node): ModifierFlags {
|
|||
|
||||
/** @internal */
|
||||
export function getEffectiveModifierFlagsAlwaysIncludeJSDoc(node: Node): ModifierFlags {
|
||||
return getModifierFlagsWorker(node, /*includeJSDOc*/ true, /*alwaysIncludeJSDOc*/ true);
|
||||
return getModifierFlagsWorker(node, /*includeJSDoc*/ true, /*alwaysIncludeJSDoc*/ true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -264,7 +264,7 @@ export function getWatchErrorSummaryDiagnosticMessage(errorCount: number) {
|
|||
function prettyPathForFileError(error: ReportFileInError, cwd: string) {
|
||||
const line = formatColorAndReset(":" + error.line, ForegroundColorEscapeSequences.Grey);
|
||||
if (pathIsAbsolute(error.fileName) && pathIsAbsolute(cwd)) {
|
||||
return getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
|
||||
return getRelativePathFromDirectory(cwd, error.fileName, /*ignoreCase*/ false) + line;
|
||||
}
|
||||
|
||||
return error.fileName + line;
|
||||
|
|
|
@ -485,8 +485,8 @@ function printEasyHelp(sys: System, simpleOptions: readonly CommandLineOption[])
|
|||
|
||||
output = [
|
||||
...output,
|
||||
...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.COMMAND_LINE_FLAGS), cliCommands, /*subCategory*/ false, /* beforeOptionsDescription */ undefined, /* afterOptionsDescription*/ undefined),
|
||||
...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.COMMON_COMPILER_OPTIONS), configOpts, /*subCategory*/ false, /* beforeOptionsDescription */ undefined, formatMessage(/*_dummy*/ undefined, Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc"))
|
||||
...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.COMMAND_LINE_FLAGS), cliCommands, /*subCategory*/ false, /*beforeOptionsDescription*/ undefined, /*afterOptionsDescription*/ undefined),
|
||||
...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.COMMON_COMPILER_OPTIONS), configOpts, /*subCategory*/ false, /*beforeOptionsDescription*/ undefined, formatMessage(/*dummy*/ undefined, Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc"))
|
||||
];
|
||||
|
||||
for (const line of output) {
|
||||
|
@ -504,9 +504,9 @@ function printEasyHelp(sys: System, simpleOptions: readonly CommandLineOption[])
|
|||
|
||||
function printAllHelp(sys: System, compilerOptions: readonly CommandLineOption[], buildOptions: readonly CommandLineOption[], watchOptions: readonly CommandLineOption[]) {
|
||||
let output: string[] = [...getHeader(sys,`${getDiagnosticText(Diagnostics.tsc_Colon_The_TypeScript_Compiler)} - ${getDiagnosticText(Diagnostics.Version_0, version)}`)];
|
||||
output = [...output, ...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.ALL_COMPILER_OPTIONS), compilerOptions, /*subCategory*/ true, /* beforeOptionsDescription */ undefined, formatMessage(/*_dummy*/ undefined, Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc"))];
|
||||
output = [...output, ...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.ALL_COMPILER_OPTIONS), compilerOptions, /*subCategory*/ true, /*beforeOptionsDescription*/ undefined, formatMessage(/*dummy*/ undefined, Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc"))];
|
||||
output = [...output, ...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.WATCH_OPTIONS), watchOptions, /*subCategory*/ false, getDiagnosticText(Diagnostics.Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon))];
|
||||
output = [...output, ...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.BUILD_OPTIONS), buildOptions, /*subCategory*/ false, formatMessage(/*_dummy*/ undefined, Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds"))];
|
||||
output = [...output, ...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.BUILD_OPTIONS), buildOptions, /*subCategory*/ false, formatMessage(/*dummy*/ undefined, Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds"))];
|
||||
for (const line of output) {
|
||||
sys.write(line);
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ function printAllHelp(sys: System, compilerOptions: readonly CommandLineOption[]
|
|||
|
||||
function printBuildHelp(sys: System, buildOptions: readonly CommandLineOption[]) {
|
||||
let output: string[] = [...getHeader(sys,`${getDiagnosticText(Diagnostics.tsc_Colon_The_TypeScript_Compiler)} - ${getDiagnosticText(Diagnostics.Version_0, version)}`)];
|
||||
output = [...output, ...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.BUILD_OPTIONS), buildOptions, /*subCategory*/ false, formatMessage(/*_dummy*/ undefined, Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds"))];
|
||||
output = [...output, ...generateSectionOptionsOutput(sys, getDiagnosticText(Diagnostics.BUILD_OPTIONS), buildOptions, /*subCategory*/ false, formatMessage(/*dummy*/ undefined, Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds"))];
|
||||
for (const line of output) {
|
||||
sys.write(line);
|
||||
}
|
||||
|
@ -890,7 +890,7 @@ function performCompilation(
|
|||
config: ParsedCommandLine
|
||||
) {
|
||||
const { fileNames, options, projectReferences } = config;
|
||||
const host = createCompilerHostWorker(options, /*setParentPos*/ undefined, sys);
|
||||
const host = createCompilerHostWorker(options, /*setParentNodes*/ undefined, sys);
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
|
||||
changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
|
@ -910,7 +910,7 @@ function performCompilation(
|
|||
s => sys.write(s + sys.newLine),
|
||||
createReportErrorSummary(sys, options)
|
||||
);
|
||||
reportStatistics(sys, program, /*builder*/ undefined);
|
||||
reportStatistics(sys, program, /*solutionPerformance*/ undefined);
|
||||
cb(program);
|
||||
return sys.exit(exitStatus);
|
||||
}
|
||||
|
@ -934,7 +934,7 @@ function performIncrementalCompilation(
|
|||
reportDiagnostic,
|
||||
reportErrorSummary: createReportErrorSummary(sys, options),
|
||||
afterProgramEmitAndDiagnostics: builderProgram => {
|
||||
reportStatistics(sys, builderProgram.getProgram(), /*builder*/ undefined);
|
||||
reportStatistics(sys, builderProgram.getProgram(), /*solutionPerformance*/ undefined);
|
||||
cb(builderProgram);
|
||||
}
|
||||
});
|
||||
|
@ -979,7 +979,7 @@ function updateWatchCompilationHost(
|
|||
const emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate!; // TODO: GH#18217
|
||||
watchCompilerHost.afterProgramCreate = builderProgram => {
|
||||
emitFilesUsingBuilder(builderProgram);
|
||||
reportStatistics(sys, builderProgram.getProgram(), /*builder*/ undefined);
|
||||
reportStatistics(sys, builderProgram.getProgram(), /*solutionPerformance*/ undefined);
|
||||
cb(builderProgram);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -356,7 +356,7 @@ export class TestState {
|
|||
ts.forEach(referencedFiles, referenceFile => {
|
||||
// Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path
|
||||
const referenceFilePath = this.basePath + "/" + referenceFile.fileName;
|
||||
this.addMatchedInputFile(referenceFilePath, /* extensions */ undefined);
|
||||
this.addMatchedInputFile(referenceFilePath, /*extensions*/ undefined);
|
||||
});
|
||||
|
||||
const exts = ts.flatten(ts.getSupportedExtensions(compilationOptions));
|
||||
|
@ -2651,14 +2651,14 @@ export class TestState {
|
|||
languageVersion: ts.ScriptTarget.Latest,
|
||||
impliedNodeFormat: ts.getImpliedNodeFormatForFile(
|
||||
ts.toPath(this.activeFile.fileName, this.languageServiceAdapterHost.sys.getCurrentDirectory(), ts.hostGetCanonicalFileName(this.languageServiceAdapterHost)),
|
||||
/*cache*/ undefined,
|
||||
/*packageJsonInfoCache*/ undefined,
|
||||
this.languageServiceAdapterHost,
|
||||
this.languageService.getProgram()?.getCompilerOptions() || {}
|
||||
),
|
||||
setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.languageService.getProgram()?.getCompilerOptions() || {}),
|
||||
};
|
||||
const referenceSourceFile = ts.createLanguageServiceSourceFile(
|
||||
this.activeFile.fileName, createScriptSnapShot(content), options, /*version:*/ "0", /*setNodeParents:*/ false);
|
||||
this.activeFile.fileName, createScriptSnapShot(content), options, /*version:*/ "0", /*setNodeParents*/ false);
|
||||
const referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics;
|
||||
|
||||
Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics);
|
||||
|
@ -2827,7 +2827,7 @@ export class TestState {
|
|||
public verifyCurrentLineContent(text: string) {
|
||||
const actual = this.getCurrentLineContent();
|
||||
if (actual !== text) {
|
||||
throw new Error("verifyCurrentLineContent\n" + displayExpectedAndActualString(text, actual, /* quoted */ true));
|
||||
throw new Error("verifyCurrentLineContent\n" + displayExpectedAndActualString(text, actual, /*quoted*/ true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2852,7 +2852,7 @@ export class TestState {
|
|||
public verifyTextAtCaretIs(text: string) {
|
||||
const actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length);
|
||||
if (actual !== text) {
|
||||
throw new Error("verifyTextAtCaretIs\n" + displayExpectedAndActualString(text, actual, /* quoted */ true));
|
||||
throw new Error("verifyTextAtCaretIs\n" + displayExpectedAndActualString(text, actual, /*quoted*/ true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2864,7 +2864,7 @@ export class TestState {
|
|||
|
||||
const actual = this.getFileContent(this.activeFile.fileName).substring(span.start, ts.textSpanEnd(span));
|
||||
if (actual !== text) {
|
||||
this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + displayExpectedAndActualString(text, actual, /* quoted */ true));
|
||||
this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + displayExpectedAndActualString(text, actual, /*quoted*/ true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2978,7 +2978,7 @@ export class TestState {
|
|||
if (this.testType === FourSlashTestType.Server) {
|
||||
const actual = (this.languageService as ts.server.SessionClient).getProjectInfo(
|
||||
this.activeFile.fileName,
|
||||
/* needFileNameList */ true
|
||||
/*needFileNameList*/ true
|
||||
);
|
||||
assert.equal(
|
||||
expected.join(","),
|
||||
|
@ -3288,7 +3288,7 @@ export class TestState {
|
|||
}
|
||||
}
|
||||
else {
|
||||
this.verifyRangeIs(newRangeContent!, /*includeWhitespace*/ true);
|
||||
this.verifyRangeIs(newRangeContent!, /*includeWhiteSpace*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ export class VerifyNegatable {
|
|||
|
||||
constructor(protected state: FourSlash.TestState, private negative = false) {
|
||||
if (!negative) {
|
||||
this.not = new VerifyNegatable(state, true);
|
||||
this.not = new VerifyNegatable(state, /*negative*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -918,7 +918,7 @@ export namespace Compiler {
|
|||
jsCode += "\r\n";
|
||||
}
|
||||
if (!result.diagnostics.length && !ts.endsWith(file.file, ts.Extension.Json)) {
|
||||
const fileParseResult = ts.createSourceFile(file.file, file.text, ts.getEmitScriptTarget(options), /*parentNodes*/ false, ts.endsWith(file.file, "x") ? ts.ScriptKind.JSX : ts.ScriptKind.JS);
|
||||
const fileParseResult = ts.createSourceFile(file.file, file.text, ts.getEmitScriptTarget(options), /*setParentNodes*/ false, ts.endsWith(file.file, "x") ? ts.ScriptKind.JSX : ts.ScriptKind.JS);
|
||||
if (ts.length(fileParseResult.parseDiagnostics)) {
|
||||
jsCode += getErrorBaseline([file.asTestFile()], fileParseResult.parseDiagnostics);
|
||||
return;
|
||||
|
|
|
@ -11,7 +11,7 @@ import * as vfs from "./_namespaces/vfs";
|
|||
import * as vpath from "./_namespaces/vpath";
|
||||
|
||||
export function makeDefaultProxy(info: ts.server.PluginCreateInfo): ts.LanguageService {
|
||||
const proxy = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null
|
||||
const proxy = Object.create(/*o*/ null); // eslint-disable-line no-null/no-null
|
||||
const langSvc: any = info.languageService;
|
||||
for (const k of Object.keys(langSvc)) {
|
||||
// eslint-disable-next-line local/only-arrow-functions
|
||||
|
@ -332,7 +332,7 @@ export class NativeLanguageServiceAdapter implements LanguageServiceAdapter {
|
|||
getHost(): LanguageServiceAdapterHost { return this.host; }
|
||||
getLanguageService(): ts.LanguageService { return ts.createLanguageService(this.host); }
|
||||
getClassifier(): ts.Classifier { return ts.createClassifier(); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents, /* readImportFiles */ true, ts.hasJSFileExtension(fileName)); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents, /*readImportFiles*/ true, ts.hasJSFileExtension(fileName)); }
|
||||
}
|
||||
|
||||
/// Shim adapter
|
||||
|
|
|
@ -64,7 +64,7 @@ export function memoize<T extends ts.AnyFunction>(f: T, memoKey: (...anything: a
|
|||
} as any);
|
||||
}
|
||||
|
||||
export const canonicalizeForHarness = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux
|
||||
export const canonicalizeForHarness = ts.createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ false); // This is done so tests work on windows _and_ linux
|
||||
|
||||
export function assertInvariants(node: ts.Node | undefined, parent: ts.Node | undefined) {
|
||||
const queue: [ts.Node | undefined, ts.Node | undefined][] = [[node, parent]];
|
||||
|
|
|
@ -155,7 +155,7 @@ export function newStyleLogIntoOldStyleLog(log: IoLog, host: ts.System | Harness
|
|||
return log;
|
||||
}
|
||||
|
||||
const canonicalizeForHarness = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux
|
||||
const canonicalizeForHarness = ts.createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ false); // This is done so tests work on windows _and_ linux
|
||||
function sanitizeTestFilePath(name: string) {
|
||||
const path = ts.toPath(ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/"), "", canonicalizeForHarness);
|
||||
if (ts.startsWith(path, "/")) {
|
||||
|
|
|
@ -2350,7 +2350,7 @@ export class AutoImportProviderProject extends Project {
|
|||
// allow processing JS from node_modules, go back to the implementation
|
||||
// package and load the JS.
|
||||
if (packageJson && compilerOptions.allowJs && compilerOptions.maxNodeModuleJsDepth) {
|
||||
const entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache, /*allowJs*/ true);
|
||||
const entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache, /*resolveJs*/ true);
|
||||
rootNames = concatenate(rootNames, entrypoints);
|
||||
dependenciesAdded += entrypoints?.length ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -540,7 +540,7 @@ export class ScriptInfo {
|
|||
}
|
||||
const existingRoot = p.getRootFilesMap().get(this.path);
|
||||
// detach is unnecessary since we'll clean the list of containing projects anyways
|
||||
p.removeFile(this, /*fileExists*/ false, /*detachFromProjects*/ false);
|
||||
p.removeFile(this, /*fileExists*/ false, /*detachFromProject*/ false);
|
||||
p.onFileAddedOrRemoved(this.isSymlink());
|
||||
// If the info was for the external or configured project's root,
|
||||
// add missing file as the root
|
||||
|
|
|
@ -2133,7 +2133,7 @@ export class Session<TMessage = string> implements EventSender {
|
|||
else {
|
||||
return useDisplayParts ? quickInfo : {
|
||||
...quickInfo,
|
||||
tags: this.mapJSDocTagInfo(quickInfo.tags, project, /*useDisplayParts*/ false) as JSDocTagInfo[]
|
||||
tags: this.mapJSDocTagInfo(quickInfo.tags, project, /*richResponse*/ false) as JSDocTagInfo[]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -2577,7 +2577,7 @@ export class Session<TMessage = string> implements EventSender {
|
|||
|
||||
// Mutates `outputs`
|
||||
function addItemsForProject(project: Project) {
|
||||
const projectItems = project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*filename*/ undefined, /*excludeDts*/ project.isNonTsProject());
|
||||
const projectItems = project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject());
|
||||
const unseenItems = filter(projectItems, item => tryAddSeenItem(item) && !getMappedLocationForProject(documentSpanLocation(item), project));
|
||||
if (unseenItems.length) {
|
||||
outputs.push({ project, navigateToItems: unseenItems });
|
||||
|
|
|
@ -213,7 +213,7 @@ export function createClassifier(): Classifier {
|
|||
const lastTemplateStackToken = lastOrUndefined(templateStack);
|
||||
|
||||
if (lastTemplateStackToken === SyntaxKind.TemplateHead) {
|
||||
token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false);
|
||||
token = scanner.reScanTemplateToken(/*isTaggedTemplate*/ false);
|
||||
|
||||
// Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us.
|
||||
if (token === SyntaxKind.TemplateTail) {
|
||||
|
|
|
@ -123,7 +123,7 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, po
|
|||
isObjectLiteralExpression(firstDeclaration.parent.right)
|
||||
) {
|
||||
const prototypes = firstDeclaration.parent.right;
|
||||
createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements);
|
||||
createClassElement(prototypes.symbol, /*modifiers*/ undefined, memberElements);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -204,7 +204,7 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, po
|
|||
changes.delete(sourceFile, nodeToDelete);
|
||||
|
||||
if (!assignmentExpr) {
|
||||
members.push(factory.createPropertyDeclaration(modifiers, symbol.name, /*questionToken*/ undefined,
|
||||
members.push(factory.createPropertyDeclaration(modifiers, symbol.name, /*questionOrExclamationToken*/ undefined,
|
||||
/*type*/ undefined, /*initializer*/ undefined));
|
||||
return;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, po
|
|||
// Don't try to declare members in JavaScript files
|
||||
if (isSourceFileJS(sourceFile)) return;
|
||||
if (!isPropertyAccessExpression(memberDeclaration)) return;
|
||||
const prop = factory.createPropertyDeclaration(modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr);
|
||||
const prop = factory.createPropertyDeclaration(modifiers, memberDeclaration.name, /*questionOrExclamationToken*/ undefined, /*type*/ undefined, assignmentExpr);
|
||||
copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile);
|
||||
members.push(prop);
|
||||
return;
|
||||
|
|
|
@ -497,7 +497,7 @@ function transformFinally(node: PromiseReturningCallExpression<"finally">, onFin
|
|||
|
||||
// Transform the callback argument into an array of inlined statements. We pass whether we have an outer continuation here
|
||||
// as that indicates whether `return` is valid.
|
||||
const inlinedCallback = transformCallbackArgument(onFinally, hasContinuation, /*continuationArgName*/ undefined, /*argName*/ undefined, node, transformer);
|
||||
const inlinedCallback = transformCallbackArgument(onFinally, hasContinuation, /*continuationArgName*/ undefined, /*inputArgName*/ undefined, node, transformer);
|
||||
if (hasFailed()) return silentFail(); // shortcut out of more work
|
||||
|
||||
const tryBlock = factory.createBlock(inlinedLeftHandSide);
|
||||
|
|
|
@ -112,7 +112,7 @@ function fixImportOfModuleExports(importingFile: SourceFile, exportingFile: Sour
|
|||
changes.replaceNode(importingFile, importNode, makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference));
|
||||
break;
|
||||
case SyntaxKind.CallExpression:
|
||||
if (isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) {
|
||||
if (isRequireCall(importNode, /*requireStringLiteralLikeArgument*/ false)) {
|
||||
changes.replaceNode(importingFile, importNode, factory.createPropertyAccessExpression(getSynthesizedDeepClone(importNode), "default"));
|
||||
}
|
||||
break;
|
||||
|
@ -213,9 +213,9 @@ function convertStatement(
|
|||
const { expression } = statement as ExpressionStatement;
|
||||
switch (expression.kind) {
|
||||
case SyntaxKind.CallExpression: {
|
||||
if (isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
if (isRequireCall(expression, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
// For side-effecting require() call, just make a side-effecting import.
|
||||
changes.replaceNode(sourceFile, statement, makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference));
|
||||
changes.replaceNode(sourceFile, statement, makeImport(/*defaultImport*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -250,11 +250,11 @@ function convertVariableStatement(
|
|||
foundImport = true;
|
||||
return convertedImports([]);
|
||||
}
|
||||
else if (isRequireCall(initializer, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
else if (isRequireCall(initializer, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
foundImport = true;
|
||||
return convertSingleImport(name, initializer.arguments[0], checker, identifiers, target, quotePreference);
|
||||
}
|
||||
else if (isPropertyAccessExpression(initializer) && isRequireCall(initializer.expression, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
else if (isPropertyAccessExpression(initializer) && isRequireCall(initializer.expression, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
foundImport = true;
|
||||
return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers, quotePreference);
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ function convertAssignment(
|
|||
}
|
||||
else {
|
||||
const replacement = isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right, useSitesToUnqualify)
|
||||
: isRequireCall(right, /*checkArgumentIsStringLiteralLike*/ true) ? convertReExportAll(right.arguments[0], checker)
|
||||
: isRequireCall(right, /*requireStringLiteralLikeArgument*/ true) ? convertReExportAll(right.arguments[0], checker)
|
||||
: undefined;
|
||||
if (replacement) {
|
||||
changes.replaceNodeWithNodes(sourceFile, assignment.parent, replacement[0]);
|
||||
|
@ -396,7 +396,7 @@ function convertReExportAll(reExported: StringLiteralLike, checker: TypeChecker)
|
|||
exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true];
|
||||
}
|
||||
function reExportStar(moduleSpecifier: string): ExportDeclaration {
|
||||
return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier);
|
||||
return makeExportDeclaration(/*exportSpecifiers*/ undefined, moduleSpecifier);
|
||||
}
|
||||
function reExportDefault(moduleSpecifier: string): ExportDeclaration {
|
||||
return makeExportDeclaration([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, "default")], moduleSpecifier);
|
||||
|
@ -492,7 +492,7 @@ function convertSingleImport(
|
|||
? undefined
|
||||
: makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text));
|
||||
if (importSpecifiers) {
|
||||
return convertedImports([makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]);
|
||||
return convertedImports([makeImport(/*defaultImport*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]);
|
||||
}
|
||||
}
|
||||
// falls through -- object destructuring has an interesting pattern and must be a variable declaration
|
||||
|
@ -647,7 +647,7 @@ function classExpressionToDeclaration(name: string | undefined, additionalModifi
|
|||
function makeSingleImport(localName: string, propertyName: string, moduleSpecifier: StringLiteralLike, quotePreference: QuotePreference): ImportDeclaration {
|
||||
return propertyName === "default"
|
||||
? makeImport(factory.createIdentifier(localName), /*namedImports*/ undefined, moduleSpecifier, quotePreference)
|
||||
: makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier, quotePreference);
|
||||
: makeImport(/*defaultImport*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier, quotePreference);
|
||||
}
|
||||
|
||||
function makeImportSpecifier(propertyName: string | undefined, name: string): ImportSpecifier {
|
||||
|
|
|
@ -309,7 +309,7 @@ function getInfo(sourceFile: SourceFile, tokenPos: number, errorCode: number, ch
|
|||
const param = signature.parameters[argIndex].valueDeclaration;
|
||||
if (!(param && isParameter(param) && isIdentifier(param.name))) return undefined;
|
||||
|
||||
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
|
||||
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false));
|
||||
if (!length(properties)) return undefined;
|
||||
return { kind: InfoKind.ObjectLiteral, token: param.name, properties, parentDeclaration: parent };
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ function getInfo(sourceFile: SourceFile, tokenPos: number, errorCode: number, ch
|
|||
|
||||
if (isIdentifier(token) && hasInitializer(parent) && parent.initializer && isObjectLiteralExpression(parent.initializer)) {
|
||||
const targetType = checker.getContextualType(token) || checker.getTypeAtLocation(token);
|
||||
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), targetType, /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
|
||||
const properties = arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), targetType, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false));
|
||||
if (!length(properties)) return undefined;
|
||||
|
||||
return { kind: InfoKind.ObjectLiteral, token, properties, parentDeclaration: parent.initializer };
|
||||
|
@ -425,7 +425,7 @@ function addMissingMemberInJs(changeTracker: textChanges.ChangeTracker, sourceFi
|
|||
const property = factory.createPropertyDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
tokenName,
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined);
|
||||
|
||||
|
@ -489,7 +489,7 @@ function addPropertyDeclaration(changeTracker: textChanges.ChangeTracker, source
|
|||
const modifiers = modifierFlags ? factory.createNodeArray(factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
|
||||
|
||||
const property = isClassLike(node)
|
||||
? factory.createPropertyDeclaration(modifiers, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined)
|
||||
? factory.createPropertyDeclaration(modifiers, tokenName, /*questionOrExclamationToken*/ undefined, typeNode, /*initializer*/ undefined)
|
||||
: factory.createPropertySignature(/*modifiers*/ undefined, tokenName, /*questionToken*/ undefined, typeNode);
|
||||
|
||||
const lastProp = getNodeToInsertPropertyAfter(node);
|
||||
|
|
|
@ -39,6 +39,6 @@ function getImportTypeNode(sourceFile: SourceFile, pos: number): ImportTypeNode
|
|||
}
|
||||
|
||||
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importType: ImportTypeNode) {
|
||||
const newTypeNode = factory.updateImportTypeNode(importType, importType.argument, importType.assertions, importType.qualifier, importType.typeArguments, /* isTypeOf */ true);
|
||||
const newTypeNode = factory.updateImportTypeNode(importType, importType.argument, importType.assertions, importType.qualifier, importType.typeArguments, /*isTypeOf*/ true);
|
||||
changes.replaceNode(sourceFile, importType, newTypeNode);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ registerCodeFix({
|
|||
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
||||
getCodeActions(context) {
|
||||
const { sourceFile, preferences, span } = context;
|
||||
const changeToExpression = textChanges.ChangeTracker.with(context, t => doChange(t, preferences, sourceFile, span.start, /* useHtmlEntity */ false));
|
||||
const changeToHtmlEntity = textChanges.ChangeTracker.with(context, t => doChange(t, preferences, sourceFile, span.start, /* useHtmlEntity */ true));
|
||||
const changeToExpression = textChanges.ChangeTracker.with(context, t => doChange(t, preferences, sourceFile, span.start, /*useHtmlEntity*/ false));
|
||||
const changeToHtmlEntity = textChanges.ChangeTracker.with(context, t => doChange(t, preferences, sourceFile, span.start, /*useHtmlEntity*/ true));
|
||||
|
||||
return [
|
||||
createCodeFixAction(fixIdExpression, changeToExpression, Diagnostics.Wrap_invalid_character_in_an_expression_container, fixIdExpression, Diagnostics.Wrap_all_invalid_characters_in_an_expression_container),
|
||||
|
|
|
@ -125,7 +125,7 @@ export function createMissingMemberNodes(
|
|||
const classMembers = classDeclaration.symbol.members!;
|
||||
for (const symbol of possiblyMissingSymbols) {
|
||||
if (!classMembers.has(symbol.escapedName)) {
|
||||
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined);
|
||||
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /*body*/ undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ function createMethodImplementingSignatures(
|
|||
}
|
||||
const maxNonRestArgs = maxArgsSignature.parameters.length - (signatureHasRestParameter(maxArgsSignature) ? 1 : 0);
|
||||
const maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(symbol => symbol.name);
|
||||
const parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
|
||||
const parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /*types*/ undefined, minArgumentCount, /*inJs*/ false);
|
||||
|
||||
if (someSigHasRestParameter) {
|
||||
const restParameter = factory.createParameterDeclaration(
|
||||
|
@ -789,7 +789,7 @@ export function createStubbedBody(text: string, quotePreference: QuotePreference
|
|||
/*typeArguments*/ undefined,
|
||||
// TODO Handle auto quote preference.
|
||||
[factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === QuotePreference.Single)]))],
|
||||
/*multiline*/ true);
|
||||
/*multiLine*/ true);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -231,7 +231,7 @@ function createImportAdderWorker(sourceFile: SourceFile, program: Program, useAu
|
|||
const symbolName = getNameForExportedSymbol(exportedSymbol, getEmitScriptTarget(compilerOptions));
|
||||
const checker = program.getTypeChecker();
|
||||
const symbol = checker.getMergedSymbol(skipAlias(exportedSymbol, checker));
|
||||
const exportInfo = getAllExportInfoForSymbol(sourceFile, symbol, symbolName, moduleSymbol, /*isJsxTagName*/ false, program, host, preferences, cancellationToken);
|
||||
const exportInfo = getAllExportInfoForSymbol(sourceFile, symbol, symbolName, moduleSymbol, /*preferCapitalized*/ false, program, host, preferences, cancellationToken);
|
||||
const useRequire = shouldUseRequire(sourceFile, program);
|
||||
const fix = getImportFixForSymbol(sourceFile, Debug.checkDefined(exportInfo), program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
||||
if (fix) {
|
||||
|
|
|
@ -440,7 +440,7 @@ function tryReplaceImportTypeNodeWithAutoImport(
|
|||
): boolean {
|
||||
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
||||
if (importableReference && changes.tryInsertTypeAnnotation(sourceFile, declaration, importableReference.typeNode)) {
|
||||
forEach(importableReference.symbols, s => importAdder.addImportFromExportedSymbol(s, /*usageIsTypeOnly*/ true));
|
||||
forEach(importableReference.symbols, s => importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -488,7 +488,7 @@ function annotateJSDocParameters(changes: textChanges.ChangeTracker, sourceFile:
|
|||
}
|
||||
else {
|
||||
const paramTags = map(inferences, ({ name, typeNode, isOptional }) =>
|
||||
factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined));
|
||||
factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, factory.createJSDocTypeExpression(typeNode), /*isNameFirst*/ false, /*comment*/ undefined));
|
||||
changes.addJSDocTags(sourceFile, signature, paramTags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ interface Info {
|
|||
|
||||
function getInfo(sourceFile: SourceFile, program: Program, pos: number): Info | undefined {
|
||||
const { parent } = getTokenAtPosition(sourceFile, pos);
|
||||
if (!isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
if (!isRequireCall(parent, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
Debug.failBadSyntaxKind(parent);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ registerCodeFix({
|
|||
break;
|
||||
case fixRemoveBracesFromArrowFunctionBody:
|
||||
if (!isArrowFunction(info.declaration)) return undefined;
|
||||
removeBlockBodyBrace(changes, diag.file, info.declaration, info.expression, info.commentSource, /* withParen */ false);
|
||||
removeBlockBodyBrace(changes, diag.file, info.declaration, info.expression, info.commentSource, /*withParen*/ false);
|
||||
break;
|
||||
case fixIdWrapTheBlockWithParen:
|
||||
if (!isArrowFunction(info.declaration)) return undefined;
|
||||
|
@ -217,18 +217,18 @@ function getInfo(checker: TypeChecker, sourceFile: SourceFile, position: number,
|
|||
case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
|
||||
case Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code:
|
||||
if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node)) return undefined;
|
||||
return getFixInfo(checker, declaration, checker.getTypeFromTypeNode(declaration.type), /* isFunctionType */ false);
|
||||
return getFixInfo(checker, declaration, checker.getTypeFromTypeNode(declaration.type), /*isFunctionType*/ false);
|
||||
case Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code:
|
||||
if (!declaration || !isCallExpression(declaration.parent) || !declaration.body) return undefined;
|
||||
const pos = declaration.parent.arguments.indexOf(declaration as Expression);
|
||||
const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
|
||||
if (!type) return undefined;
|
||||
return getFixInfo(checker, declaration, type, /* isFunctionType */ true);
|
||||
return getFixInfo(checker, declaration, type, /*isFunctionType*/ true);
|
||||
case Diagnostics.Type_0_is_not_assignable_to_type_1.code:
|
||||
if (!isDeclarationName(node) || !isVariableLike(node.parent) && !isJsxAttribute(node.parent)) return undefined;
|
||||
const initializer = getVariableLikeInitializer(node.parent);
|
||||
if (!initializer || !isFunctionLikeDeclaration(initializer) || !initializer.body) return undefined;
|
||||
return getFixInfo(checker, initializer, checker.getTypeAtLocation(node.parent), /* isFunctionType */ true);
|
||||
return getFixInfo(checker, initializer, checker.getTypeAtLocation(node.parent), /*isFunctionType*/ true);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ function getActionForfixAddReturnStatement(context: CodeFixContext, expression:
|
|||
}
|
||||
|
||||
function getActionForFixRemoveBracesFromArrowFunctionBody(context: CodeFixContext, declaration: ArrowFunction, expression: Expression, commentSource: Node) {
|
||||
const changes = textChanges.ChangeTracker.with(context, t => removeBlockBodyBrace(t, context.sourceFile, declaration, expression, commentSource, /* withParen */ false));
|
||||
const changes = textChanges.ChangeTracker.with(context, t => removeBlockBodyBrace(t, context.sourceFile, declaration, expression, commentSource, /*withParen*/ false));
|
||||
return createCodeFixAction(fixId, changes, Diagnostics.Remove_braces_from_arrow_function_body, fixRemoveBracesFromArrowFunctionBody, Diagnostics.Remove_braces_from_all_arrow_function_bodies_with_relevant_issues);
|
||||
}
|
||||
|
||||
|
|
|
@ -1529,11 +1529,11 @@ function getEntryForMemberCompletion(
|
|||
// if it has one, so that the cursor ends up in the body once the completion is inserted.
|
||||
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
|
||||
const emptyStmt = factory.createEmptyStatement();
|
||||
body = factory.createBlock([emptyStmt], /* multiline */ true);
|
||||
body = factory.createBlock([emptyStmt], /*multiLine*/ true);
|
||||
setSnippetElement(emptyStmt, { kind: SnippetKind.TabStop, order: 0 });
|
||||
}
|
||||
else {
|
||||
body = factory.createBlock([], /* multiline */ true);
|
||||
body = factory.createBlock([], /*multiLine*/ true);
|
||||
}
|
||||
|
||||
let modifiers = ModifierFlags.None;
|
||||
|
@ -1762,11 +1762,11 @@ function createObjectLiteralMethod(
|
|||
let body;
|
||||
if (preferences.includeCompletionsWithSnippetText) {
|
||||
const emptyStmt = factory.createEmptyStatement();
|
||||
body = factory.createBlock([emptyStmt], /* multiline */ true);
|
||||
body = factory.createBlock([emptyStmt], /*multiLine*/ true);
|
||||
setSnippetElement(emptyStmt, { kind: SnippetKind.TabStop, order: 0 });
|
||||
}
|
||||
else {
|
||||
body = factory.createBlock([], /* multiline */ true);
|
||||
body = factory.createBlock([], /*multiLine*/ true);
|
||||
}
|
||||
|
||||
const parameters = typeNode.parameters.map(typedParam =>
|
||||
|
@ -3099,7 +3099,7 @@ function getCompletionData(
|
|||
if (inCheckedFile) {
|
||||
for (const symbol of type.getApparentProperties()) {
|
||||
if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) {
|
||||
addPropertySymbol(symbol, /* insertAwait */ false, insertQuestionDot);
|
||||
addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3117,7 +3117,7 @@ function getCompletionData(
|
|||
if (promiseType) {
|
||||
for (const symbol of promiseType.getApparentProperties()) {
|
||||
if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) {
|
||||
addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot);
|
||||
addPropertySymbol(symbol, /*insertAwait*/ true, insertQuestionDot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3822,7 +3822,7 @@ function getCompletionData(
|
|||
const typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
|
||||
if (!typeForObject) return GlobalsSearch.Fail;
|
||||
typeMembers = typeChecker.getPropertiesOfType(typeForObject).filter(propertySymbol => {
|
||||
return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject, propertySymbol);
|
||||
return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*isWrite*/ false, typeForObject, propertySymbol);
|
||||
});
|
||||
existingMembers = objectLikeContainer.elements;
|
||||
}
|
||||
|
|
|
@ -2313,7 +2313,7 @@ export namespace Core {
|
|||
}
|
||||
|
||||
function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
let searchSpaceNode: Node = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false, /*includeClassComputedPropertyName*/ false);
|
||||
let searchSpaceNode: Node = getThisContainer(thisOrSuperKeyword, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
|
||||
|
||||
// Whether 'this' occurs in a static context within a class.
|
||||
let staticFlag = ModifierFlags.Static;
|
||||
|
@ -2355,7 +2355,7 @@ export namespace Core {
|
|||
if (!isThis(node)) {
|
||||
return false;
|
||||
}
|
||||
const container = getThisContainer(node, /* includeArrowFunctions */ false, /*includeClassComputedPropertyName*/ false);
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
|
||||
if (!canHaveSymbol(container)) return false;
|
||||
switch (searchSpaceNode.kind) {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
|
|
|
@ -267,7 +267,7 @@ export function getFormattingScanner<T>(text: string, languageVariant: LanguageV
|
|||
case ScanAction.RescanTemplateToken:
|
||||
if (token === SyntaxKind.CloseBraceToken) {
|
||||
lastScanAction = ScanAction.RescanTemplateToken;
|
||||
return scanner.reScanTemplateToken(/* isTaggedTemplate */ false);
|
||||
return scanner.reScanTemplateToken(/*isTaggedTemplate*/ false);
|
||||
}
|
||||
break;
|
||||
case ScanAction.RescanJsxIdentifier:
|
||||
|
@ -275,7 +275,7 @@ export function getFormattingScanner<T>(text: string, languageVariant: LanguageV
|
|||
return scanner.scanJsxIdentifier();
|
||||
case ScanAction.RescanJsxText:
|
||||
lastScanAction = ScanAction.RescanJsxText;
|
||||
return scanner.reScanJsxToken(/* allowMultilineJsxText */ false);
|
||||
return scanner.reScanJsxToken(/*allowMultilineJsxText*/ false);
|
||||
case ScanAction.RescanJsxAttributeValue:
|
||||
lastScanAction = ScanAction.RescanJsxAttributeValue;
|
||||
return scanner.reScanJsxAttributeValue();
|
||||
|
|
|
@ -223,7 +223,7 @@ function getImportersForExport(
|
|||
}
|
||||
else if (direct.exportClause.kind === SyntaxKind.NamespaceExport) {
|
||||
// `export * as foo from "foo"` add to indirect uses
|
||||
addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true);
|
||||
addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /*addTransitiveDependencies*/ true);
|
||||
}
|
||||
else {
|
||||
// This is `export { foo } from "foo"` and creates an alias symbol, so recursive search will get handle re-exports.
|
||||
|
@ -234,7 +234,7 @@ function getImportersForExport(
|
|||
case SyntaxKind.ImportType:
|
||||
// Only check for typeof import('xyz')
|
||||
if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
|
||||
addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
|
||||
addIndirectUser(direct.getSourceFile(), /*addTransitiveDependencies*/ true);
|
||||
}
|
||||
directImports.push(direct);
|
||||
break;
|
||||
|
@ -248,7 +248,7 @@ function getImportersForExport(
|
|||
|
||||
function handleImportCall(importCall: ImportCall) {
|
||||
const top = findAncestor(importCall, isAmbientModuleDeclaration) || importCall.getSourceFile();
|
||||
addIndirectUser(top, /** addTransitiveDependencies */ !!isExported(importCall, /** stopAtAmbientModule */ true));
|
||||
addIndirectUser(top, /** addTransitiveDependencies */ !!isExported(importCall, /*stopAtAmbientModule*/ true));
|
||||
}
|
||||
|
||||
function isExported(node: Node, stopAtAmbientModule = false) {
|
||||
|
@ -267,7 +267,7 @@ function getImportersForExport(
|
|||
const sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration);
|
||||
Debug.assert(sourceFileLike.kind === SyntaxKind.SourceFile || sourceFileLike.kind === SyntaxKind.ModuleDeclaration);
|
||||
if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) {
|
||||
addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true);
|
||||
addIndirectUser(sourceFileLike, /*addTransitiveDependencies*/ true);
|
||||
}
|
||||
else {
|
||||
addIndirectUser(sourceFileLike);
|
||||
|
@ -290,7 +290,7 @@ function getImportersForExport(
|
|||
if (directImports) {
|
||||
for (const directImport of directImports) {
|
||||
if (!isImportTypeNode(directImport)) {
|
||||
addIndirectUser(getSourceFileLikeForImportDeclaration(directImport), /** addTransitiveDependencies */ true);
|
||||
addIndirectUser(getSourceFileLikeForImportDeclaration(directImport), /*addTransitiveDependencies*/ true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -658,7 +658,7 @@ function tryMergeEs5Class(a: NavigationBarNode, b: NavigationBarNode, bIndex: nu
|
|||
|
||||
if (ctorFunction !== undefined) {
|
||||
const ctorNode = setTextRange(
|
||||
factory.createConstructorDeclaration(/* modifiers */ undefined, [], /* body */ undefined),
|
||||
factory.createConstructorDeclaration(/*modifiers*/ undefined, [], /*body*/ undefined),
|
||||
ctorFunction);
|
||||
const ctor = emptyNavigationBarNode(ctorNode);
|
||||
ctor.indent = a.indent + 1;
|
||||
|
@ -676,10 +676,10 @@ function tryMergeEs5Class(a: NavigationBarNode, b: NavigationBarNode, bIndex: nu
|
|||
}
|
||||
|
||||
lastANode = a.node = setTextRange(factory.createClassDeclaration(
|
||||
/* modifiers */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
a.name as Identifier || factory.createIdentifier("__class__"),
|
||||
/* typeParameters */ undefined,
|
||||
/* heritageClauses */ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*heritageClauses*/ undefined,
|
||||
[]
|
||||
), a.node);
|
||||
}
|
||||
|
@ -703,10 +703,10 @@ function tryMergeEs5Class(a: NavigationBarNode, b: NavigationBarNode, bIndex: nu
|
|||
else {
|
||||
if (!a.additionalNodes) a.additionalNodes = [];
|
||||
a.additionalNodes.push(setTextRange(factory.createClassDeclaration(
|
||||
/* modifiers */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
a.name as Identifier || factory.createIdentifier("__class__"),
|
||||
/* typeParameters */ undefined,
|
||||
/* heritageClauses */ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*heritageClauses*/ undefined,
|
||||
[]
|
||||
), b.node));
|
||||
}
|
||||
|
|
|
@ -184,8 +184,8 @@ function matchTextChunk(candidate: string, chunk: TextChunk, stringToWordSpans:
|
|||
// But we would match 'FooAttribute' (since 'Attribute' starts with 'a').
|
||||
const wordSpans = getWordSpans(candidate, stringToWordSpans);
|
||||
for (const span of wordSpans) {
|
||||
if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) {
|
||||
return createPatternMatch(PatternMatchKind.substring, /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false));
|
||||
if (partStartsWith(candidate, span, chunk.text, /*ignoreCase*/ true)) {
|
||||
return createPatternMatch(PatternMatchKind.substring, /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase*/ false));
|
||||
}
|
||||
}
|
||||
// c) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries?
|
||||
|
@ -195,7 +195,7 @@ function matchTextChunk(candidate: string, chunk: TextChunk, stringToWordSpans:
|
|||
// filter the list based on a substring that starts on a capital letter and also with a lowercase one.
|
||||
// (Pattern: fogbar, Candidate: quuxfogbarFogBar).
|
||||
if (chunk.text.length < candidate.length && isUpperCaseLetter(candidate.charCodeAt(index))) {
|
||||
return createPatternMatch(PatternMatchKind.substring, /*isCaseSensitive:*/ false);
|
||||
return createPatternMatch(PatternMatchKind.substring, /*isCaseSensitive*/ false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -203,13 +203,13 @@ function matchTextChunk(candidate: string, chunk: TextChunk, stringToWordSpans:
|
|||
// candidate in a case *sensitive* manner. If so, return that there was a substring
|
||||
// match.
|
||||
if (candidate.indexOf(chunk.text) > 0) {
|
||||
return createPatternMatch(PatternMatchKind.substring, /*isCaseSensitive:*/ true);
|
||||
return createPatternMatch(PatternMatchKind.substring, /*isCaseSensitive*/ true);
|
||||
}
|
||||
// e) If the part was not entirely lowercase, then attempt a camel cased match as well.
|
||||
if (chunk.characterSpans.length > 0) {
|
||||
const candidateParts = getWordSpans(candidate, stringToWordSpans);
|
||||
const isCaseSensitive = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false) ? true
|
||||
: tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true) ? false : undefined;
|
||||
const isCaseSensitive = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase*/ false) ? true
|
||||
: tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase*/ true) ? false : undefined;
|
||||
if (isCaseSensitive !== undefined) {
|
||||
return createPatternMatch(PatternMatchKind.camelCase, isCaseSensitive);
|
||||
}
|
||||
|
@ -479,12 +479,12 @@ function createTextChunk(text: string): TextChunk {
|
|||
|
||||
/** @internal */
|
||||
export function breakIntoCharacterSpans(identifier: string): TextSpan[] {
|
||||
return breakIntoSpans(identifier, /*word:*/ false);
|
||||
return breakIntoSpans(identifier, /*word*/ false);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function breakIntoWordSpans(identifier: string): TextSpan[] {
|
||||
return breakIntoSpans(identifier, /*word:*/ true);
|
||||
return breakIntoSpans(identifier, /*word*/ true);
|
||||
}
|
||||
|
||||
function breakIntoSpans(identifier: string, word: boolean): TextSpan[] {
|
||||
|
|
|
@ -380,7 +380,7 @@ export function preProcessFile(sourceText: string, readImportFiles = true, detec
|
|||
case SyntaxKind.CloseBraceToken:
|
||||
if (length(stack)) {
|
||||
if (lastOrUndefined(stack) === SyntaxKind.TemplateHead) {
|
||||
if (scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === SyntaxKind.TemplateTail) {
|
||||
if (scanner.reScanTemplateToken(/*isTaggedTemplate*/ false) === SyntaxKind.TemplateTail) {
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,15 +100,15 @@ function getRefactorEditsToRemoveFunctionBraces(context: RefactorContext, action
|
|||
|
||||
if (actionName === addBracesAction.name) {
|
||||
const returnStatement = factory.createReturnStatement(expression);
|
||||
body = factory.createBlock([returnStatement], /* multiLine */ true);
|
||||
copyLeadingComments(expression!, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ true);
|
||||
body = factory.createBlock([returnStatement], /*multiLine*/ true);
|
||||
copyLeadingComments(expression!, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ true);
|
||||
}
|
||||
else if (actionName === removeBracesAction.name && returnStatement) {
|
||||
const actualExpression = expression || factory.createVoidZero();
|
||||
body = needsParentheses(actualExpression) ? factory.createParenthesizedExpression(actualExpression) : actualExpression;
|
||||
copyTrailingAsLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
||||
copyLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
||||
copyTrailingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
||||
copyTrailingAsLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ false);
|
||||
copyLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ false);
|
||||
copyTrailingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ false);
|
||||
}
|
||||
else {
|
||||
Debug.fail("invalid action");
|
||||
|
|
|
@ -240,8 +240,8 @@ function convertToBlock(body: ConciseBody): Block {
|
|||
const file = body.getSourceFile();
|
||||
setTextRange(returnStatement, body);
|
||||
suppressLeadingAndTrailingTrivia(returnStatement);
|
||||
copyTrailingAsLeadingComments(body, returnStatement, file, /* commentKind */ undefined, /* hasTrailingNewLine */ true);
|
||||
return factory.createBlock([returnStatement], /* multiLine */ true);
|
||||
copyTrailingAsLeadingComments(body, returnStatement, file, /*commentKind*/ undefined, /*hasTrailingNewLine*/ true);
|
||||
return factory.createBlock([returnStatement], /*multiLine*/ true);
|
||||
}
|
||||
else {
|
||||
return body;
|
||||
|
@ -262,7 +262,7 @@ function getVariableInfo(func: FunctionExpression | ArrowFunction): VariableInfo
|
|||
function getEditInfoForConvertToAnonymousFunction(context: RefactorContext, func: FunctionExpression | ArrowFunction): FileTextChanges[] {
|
||||
const { file } = context;
|
||||
const body = convertToBlock(func.body);
|
||||
const newNode = factory.createFunctionExpression(func.modifiers, func.asteriskToken, /* name */ undefined, func.typeParameters, func.parameters, func.type, body);
|
||||
const newNode = factory.createFunctionExpression(func.modifiers, func.asteriskToken, /*name*/ undefined, func.typeParameters, func.parameters, func.type, body);
|
||||
return textChanges.ChangeTracker.with(context, t => t.replaceNode(file, func, newNode));
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ function changeDefaultToNamedImport(importingSourceFile: SourceFile, ref: Identi
|
|||
// `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";`
|
||||
changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) });
|
||||
const quotePreference = isStringLiteral(clause.parent.moduleSpecifier) ? quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : QuotePreference.Double;
|
||||
const newImport = makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference);
|
||||
const newImport = makeImport(/*defaultImport*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference);
|
||||
changes.insertNodeAfter(importingSourceFile, clause.parent, newImport);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -170,7 +170,7 @@ function treeToArray(current: Expression) {
|
|||
// "foo" + /* comment */ "bar"
|
||||
const copyTrailingOperatorComments = (operators: Token<BinaryOperator>[], file: SourceFile) => (index: number, targetNode: Node) => {
|
||||
if (index < operators.length) {
|
||||
copyTrailingComments(operators[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
||||
copyTrailingComments(operators[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ false);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -180,7 +180,7 @@ const copyCommentFromMultiNode = (nodes: readonly Expression[], file: SourceFile
|
|||
(indexes: number[], targetNode: Node) => {
|
||||
while (indexes.length > 0) {
|
||||
const index = indexes.shift()!;
|
||||
copyTrailingComments(nodes[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
||||
copyTrailingComments(nodes[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ false);
|
||||
copyOperatorComments(index, targetNode);
|
||||
}
|
||||
};
|
||||
|
@ -275,8 +275,8 @@ function nodesToTemplate({ nodes, operators }: { nodes: readonly Expression[], o
|
|||
// "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar"
|
||||
function copyExpressionComments(node: ParenthesizedExpression | TemplateSpan) {
|
||||
const file = node.getSourceFile();
|
||||
copyTrailingComments(node, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
||||
copyTrailingAsLeadingComments(node.expression, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
||||
copyTrailingComments(node, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ false);
|
||||
copyTrailingAsLeadingComments(node.expression, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /*hasTrailingNewLine*/ false);
|
||||
}
|
||||
|
||||
function getExpressionFromParenthesesOrExpression(node: Expression) {
|
||||
|
|
|
@ -633,7 +633,7 @@ export function getRangeToExtract(sourceFile: SourceFile, span: TextSpan, invoke
|
|||
visit(nodeToCheck);
|
||||
|
||||
if (rangeFacts & RangeFacts.UsesThis) {
|
||||
const container = getThisContainer(nodeToCheck, /** includeArrowFunctions */ false, /*includeClassComputedPropertyName*/ false);
|
||||
const container = getThisContainer(nodeToCheck, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
|
||||
if (
|
||||
container.kind === SyntaxKind.FunctionDeclaration ||
|
||||
(container.kind === SyntaxKind.MethodDeclaration && container.parent.kind === SyntaxKind.ObjectLiteralExpression) ||
|
||||
|
@ -1317,7 +1317,7 @@ function extractFunctionInScope(
|
|||
const renameRange = isReadonlyArray(range.range) ? first(range.range) : range.range;
|
||||
|
||||
const renameFilename = renameRange.getSourceFile().fileName;
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, functionNameText, /*isDeclaredBeforeUse*/ false);
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, functionNameText, /*preferLastLocation*/ false);
|
||||
return { renameFilename, renameLocation, edits };
|
||||
|
||||
function getTypeDeepCloneUnionUndefined(typeNode: TypeNode | undefined): TypeNode | undefined {
|
||||
|
@ -1380,7 +1380,7 @@ function extractConstantInScope(
|
|||
const newVariable = factory.createPropertyDeclaration(
|
||||
modifiers,
|
||||
localNameText,
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
variableType,
|
||||
initializer);
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ function extractConstantInScope(
|
|||
const edits = changeTracker.getChanges();
|
||||
|
||||
const renameFilename = node.getSourceFile().fileName;
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true);
|
||||
const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*preferLastLocation*/ true);
|
||||
return { renameFilename, renameLocation, edits };
|
||||
|
||||
function transformFunctionInitializerAndType(variableType: TypeNode | undefined, initializer: Expression): { variableType: TypeNode | undefined, initializer: Expression } {
|
||||
|
@ -1513,10 +1513,10 @@ function extractConstantInScope(
|
|||
if ((!firstParameter || (isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) {
|
||||
const thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node);
|
||||
parameters.splice(0, 0, factory.createParameterDeclaration(
|
||||
/* modifiers */ undefined,
|
||||
/* dotDotDotToken */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
"this",
|
||||
/* questionToken */ undefined,
|
||||
/*questionToken*/ undefined,
|
||||
checker.typeToTypeNode(thisType, scope, NodeBuilderFlags.NoTruncation)
|
||||
));
|
||||
}
|
||||
|
@ -1588,7 +1588,7 @@ function transformFunctionBody(body: Node, exposedVariableDeclarations: readonly
|
|||
const hasWritesOrVariableDeclarations = writes !== undefined || exposedVariableDeclarations.length > 0;
|
||||
if (isBlock(body) && !hasWritesOrVariableDeclarations && substitutions.size === 0) {
|
||||
// already block, no declarations or writes to propagate back, no substitutions - can use node as is
|
||||
return { body: factory.createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined };
|
||||
return { body: factory.createBlock(body.statements, /*multiLine*/ true), returnValueProperty: undefined };
|
||||
}
|
||||
let returnValueProperty: string | undefined;
|
||||
let ignoreReturns = false;
|
||||
|
|
|
@ -217,7 +217,7 @@ function collectTypeParameters(checker: TypeChecker, selection: TypeNode, enclos
|
|||
if (isTypeReferenceNode(node)) {
|
||||
if (isIdentifier(node.typeName)) {
|
||||
const typeName = node.typeName;
|
||||
const symbol = checker.resolveName(typeName.text, typeName, SymbolFlags.TypeParameter, /* excludeGlobals */ true);
|
||||
const symbol = checker.resolveName(typeName.text, typeName, SymbolFlags.TypeParameter, /*excludeGlobals*/ true);
|
||||
for (const decl of symbol?.declarations || emptyArray) {
|
||||
if (isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) {
|
||||
// skip extraction if the type node is in the range of the type parameter declaration.
|
||||
|
@ -248,7 +248,7 @@ function collectTypeParameters(checker: TypeChecker, selection: TypeNode, enclos
|
|||
}
|
||||
else if (isTypeQueryNode(node)) {
|
||||
if (isIdentifier(node.exprName)) {
|
||||
const symbol = checker.resolveName(node.exprName.text, node.exprName, SymbolFlags.Value, /* excludeGlobals */ false);
|
||||
const symbol = checker.resolveName(node.exprName.text, node.exprName, SymbolFlags.Value, /*excludeGlobals*/ false);
|
||||
if (symbol?.valueDeclaration && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -272,28 +272,28 @@ function doTypeAliasChange(changes: textChanges.ChangeTracker, file: SourceFile,
|
|||
const { enclosingNode, selection, typeParameters } = info;
|
||||
|
||||
const newTypeNode = factory.createTypeAliasDeclaration(
|
||||
/* modifiers */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
name,
|
||||
typeParameters.map(id => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, /* defaultType */ undefined)),
|
||||
typeParameters.map(id => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, /*defaultType*/ undefined)),
|
||||
selection
|
||||
);
|
||||
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true);
|
||||
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map(id => factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined))), { leadingTriviaOption: textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: textChanges.TrailingTriviaOption.ExcludeWhitespace });
|
||||
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), /*blankLineBetween*/ true);
|
||||
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map(id => factory.createTypeReferenceNode(id.name, /*typeArguments*/ undefined))), { leadingTriviaOption: textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: textChanges.TrailingTriviaOption.ExcludeWhitespace });
|
||||
}
|
||||
|
||||
function doInterfaceChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, info: InterfaceInfo) {
|
||||
const { enclosingNode, selection, typeParameters, typeElements } = info;
|
||||
|
||||
const newTypeNode = factory.createInterfaceDeclaration(
|
||||
/* modifiers */ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
name,
|
||||
typeParameters,
|
||||
/* heritageClauses */ undefined,
|
||||
/*heritageClauses*/ undefined,
|
||||
typeElements
|
||||
);
|
||||
setTextRange(newTypeNode, typeElements[0]?.parent);
|
||||
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true);
|
||||
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map(id => factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined))), { leadingTriviaOption: textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: textChanges.TrailingTriviaOption.ExcludeWhitespace });
|
||||
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), /*blankLineBetween*/ true);
|
||||
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map(id => factory.createTypeReferenceNode(id.name, /*typeArguments*/ undefined))), { leadingTriviaOption: textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: textChanges.TrailingTriviaOption.ExcludeWhitespace });
|
||||
}
|
||||
|
||||
function doTypedefChange(changes: textChanges.ChangeTracker, context: RefactorContext, file: SourceFile, name: string, info: ExtractInfo) {
|
||||
|
@ -318,7 +318,7 @@ function doTypedefChange(changes: textChanges.ChangeTracker, context: RefactorCo
|
|||
templates.push(template);
|
||||
});
|
||||
|
||||
const jsDoc = factory.createJSDocComment(/* comment */ undefined, factory.createNodeArray(concatenate<JSDocTag>(templates, [node])));
|
||||
const jsDoc = factory.createJSDocComment(/*comment*/ undefined, factory.createNodeArray(concatenate<JSDocTag>(templates, [node])));
|
||||
if (isJSDoc(enclosingNode)) {
|
||||
const pos = enclosingNode.getStart(file);
|
||||
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext?.options);
|
||||
|
@ -327,9 +327,9 @@ function doTypedefChange(changes: textChanges.ChangeTracker, context: RefactorCo
|
|||
});
|
||||
}
|
||||
else {
|
||||
changes.insertNodeBefore(file, enclosingNode, jsDoc, /* blankLineBetween */ true);
|
||||
changes.insertNodeBefore(file, enclosingNode, jsDoc, /*blankLineBetween*/ true);
|
||||
}
|
||||
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map(id => factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined))));
|
||||
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map(id => factory.createTypeReferenceNode(id.name, /*typeArguments*/ undefined))));
|
||||
}
|
||||
|
||||
function getEnclosingNode(node: Node, isJS: boolean) {
|
||||
|
|
|
@ -248,7 +248,7 @@ function isPureImport(node: Node): boolean {
|
|||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return !hasSyntacticModifier(node, ModifierFlags.Export);
|
||||
case SyntaxKind.VariableStatement:
|
||||
return (node as VariableStatement).declarationList.declarations.every(d => !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true));
|
||||
return (node as VariableStatement).declarationList.declarations.every(d => !!d.initializer && isRequireCall(d.initializer, /*requireStringLiteralLikeArgument*/ true));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ function forEachImportInStatement(statement: Statement, cb: (importNode: Support
|
|||
}
|
||||
else if (isVariableStatement(statement)) {
|
||||
for (const decl of statement.declarationList.declarations) {
|
||||
if (decl.initializer && isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
if (decl.initializer && isRequireCall(decl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
cb(decl as SupportedImport);
|
||||
}
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ function isInImport(decl: Declaration) {
|
|||
}
|
||||
function isVariableDeclarationInImport(decl: VariableDeclaration) {
|
||||
return isSourceFile(decl.parent.parent.parent) &&
|
||||
!!decl.initializer && isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true);
|
||||
!!decl.initializer && isRequireCall(decl.initializer, /*requireStringLiteralLikeArgument*/ true);
|
||||
}
|
||||
|
||||
function filterImport(i: SupportedImport, moduleSpecifier: StringLiteralLike, keep: (name: Identifier) => boolean): SupportedImportStatement | undefined {
|
||||
|
|
|
@ -1757,7 +1757,7 @@ export function createLanguageService(
|
|||
result,
|
||||
parseConfigHost,
|
||||
getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory),
|
||||
/*optionsToExtend*/ undefined,
|
||||
/*existingOptions*/ undefined,
|
||||
getNormalizedAbsolutePath(configFileName, currentDirectory),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1279,7 +1279,7 @@ class CoreServicesShimObject extends ShimBase implements CoreServicesShim {
|
|||
`getPreProcessedFileInfo('${fileName}')`,
|
||||
() => {
|
||||
// for now treat files as JavaScript
|
||||
const result = preProcessFile(getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true);
|
||||
const result = preProcessFile(getSnapshotText(sourceTextSnapshot), /*readImportFiles*/ true, /*detectJavaScriptImports*/ true);
|
||||
return {
|
||||
referencedFiles: this.convertFileReferences(result.referencedFiles),
|
||||
importedFiles: this.convertFileReferences(result.importedFiles),
|
||||
|
@ -1342,7 +1342,7 @@ class CoreServicesShimObject extends ShimBase implements CoreServicesShim {
|
|||
}
|
||||
|
||||
public discoverTypings(discoverTypingsJson: string): string {
|
||||
const getCanonicalFileName = createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ false);
|
||||
return this.forwardJSONCall("discoverTypings()", () => {
|
||||
const info = JSON.parse(discoverTypingsJson) as DiscoverTypingsInfo;
|
||||
if (this.safeList === undefined) {
|
||||
|
@ -1381,7 +1381,7 @@ export class TypeScriptServicesFactory implements ShimFactory {
|
|||
this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory());
|
||||
}
|
||||
const hostAdapter = new LanguageServiceShimHostAdapter(host);
|
||||
const languageService = createLanguageService(hostAdapter, this.documentRegistry, /*syntaxOnly*/ false);
|
||||
const languageService = createLanguageService(hostAdapter, this.documentRegistry, /*syntaxOnlyOrLanguageServiceMode*/ false);
|
||||
return new LanguageServiceShimObject(this, host, languageService);
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
@ -244,7 +244,7 @@ function convertStringLiteralCompletions(
|
|||
preferences,
|
||||
options,
|
||||
/*formatContext*/ undefined,
|
||||
/*isTypeOnlyLocation */ undefined,
|
||||
/*isTypeOnlyLocation*/ undefined,
|
||||
/*propertyAccessToConvert*/ undefined,
|
||||
/*jsxIdentifierExpected*/ undefined,
|
||||
/*isJsxInitializer*/ undefined,
|
||||
|
|
|
@ -111,7 +111,7 @@ export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Pr
|
|||
node.declarationList.flags & NodeFlags.Const &&
|
||||
node.declarationList.declarations.length === 1) {
|
||||
const init = node.declarationList.declarations[0].initializer;
|
||||
if (init && isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) {
|
||||
if (init && isRequireCall(init, /*requireStringLiteralLikeArgument*/ true)) {
|
||||
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
||||
}
|
||||
}
|
||||
|
@ -139,10 +139,10 @@ function containsTopLevelCommonjs(sourceFile: SourceFile): boolean {
|
|||
switch (statement.kind) {
|
||||
case SyntaxKind.VariableStatement:
|
||||
return (statement as VariableStatement).declarationList.declarations.some(decl =>
|
||||
!!decl.initializer && isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true));
|
||||
!!decl.initializer && isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*requireStringLiteralLikeArgument*/ true));
|
||||
case SyntaxKind.ExpressionStatement: {
|
||||
const { expression } = statement as ExpressionStatement;
|
||||
if (!isBinaryExpression(expression)) return isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true);
|
||||
if (!isBinaryExpression(expression)) return isRequireCall(expression, /*requireStringLiteralLikeArgument*/ true);
|
||||
const kind = getAssignmentDeclarationKind(expression);
|
||||
return kind === AssignmentDeclarationKind.ExportsProperty || kind === AssignmentDeclarationKind.ModuleExports;
|
||||
}
|
||||
|
|
|
@ -1723,7 +1723,7 @@ namespace deleteDeclaration {
|
|||
const nextToken = getTokenAtPosition(sourceFile, importClause.name!.end);
|
||||
if (nextToken && nextToken.kind === SyntaxKind.CommaToken) {
|
||||
// shift first non-whitespace position after comma to the start position of the node
|
||||
const end = skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true);
|
||||
const end = skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
|
||||
changes.deleteRange(sourceFile, { pos: start, end });
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -21,7 +21,7 @@ export function transform<T extends Node>(source: T | T[], transformers: Transfo
|
|||
const diagnostics: DiagnosticWithLocation[] = [];
|
||||
compilerOptions = fixupCompilerOptions(compilerOptions!, diagnostics); // TODO: GH#18217
|
||||
const nodes = isArray(source) ? source : [source];
|
||||
const result = transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, factory, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true);
|
||||
const result = transformNodes(/*resolver*/ undefined, /*host*/ undefined, factory, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true);
|
||||
result.diagnostics = concatenate(result.diagnostics, diagnostics);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ export function transpileModule(input: string, transpileOptions: TranspileOption
|
|||
input,
|
||||
{
|
||||
languageVersion: getEmitScriptTarget(options),
|
||||
impliedNodeFormat: getImpliedNodeFormatForFile(toPath(inputFileName, "", compilerHost.getCanonicalFileName), /*cache*/ undefined, compilerHost, options),
|
||||
impliedNodeFormat: getImpliedNodeFormatForFile(toPath(inputFileName, "", compilerHost.getCanonicalFileName), /*packageJsonInfoCache*/ undefined, compilerHost, options),
|
||||
setExternalModuleIndicator: getSetExternalModuleIndicator(options)
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1572,7 +1572,7 @@ function getTokenAtPositionWorker(sourceFile: SourceFile, position: number, allo
|
|||
return Comparison.LessThan;
|
||||
}
|
||||
|
||||
const start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
|
||||
const start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDocComment*/ true);
|
||||
if (start > position) {
|
||||
return Comparison.GreaterThan;
|
||||
}
|
||||
|
@ -1611,7 +1611,7 @@ function getTokenAtPositionWorker(sourceFile: SourceFile, position: number, allo
|
|||
if (end < position) {
|
||||
return false;
|
||||
}
|
||||
start ??= allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
|
||||
start ??= allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDocComment*/ true);
|
||||
if (start > position) {
|
||||
// If this child begins after position, then all subsequent children will as well.
|
||||
return false;
|
||||
|
@ -3002,7 +3002,7 @@ export function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, e
|
|||
export function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.None): SymbolDisplayPart[] {
|
||||
flags |= TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.WriteTypeArgumentsOfSignature | TypeFormatFlags.OmitParameterModifiers;
|
||||
return mapToDisplayParts(writer => {
|
||||
typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer);
|
||||
typechecker.writeSignature(signature, enclosingDeclaration, flags, /*kind*/ undefined, writer);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3940,8 +3940,8 @@ export function getNamesForExportedSymbol(symbol: Symbol, scriptTarget: ScriptTa
|
|||
if (needsNameFromDeclaration(symbol)) {
|
||||
const fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
|
||||
if (fromDeclaration) return fromDeclaration;
|
||||
const fileNameCase = codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
|
||||
const capitalized = codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
|
||||
const fileNameCase = codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*forceCapitalize*/ false);
|
||||
const capitalized = codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*forceCapitalize*/ true);
|
||||
if (fileNameCase === capitalized) return fileNameCase;
|
||||
return [fileNameCase, capitalized];
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ function withDelete(text: ts.IScriptSnapshot, start: number, length: number): {
|
|||
}
|
||||
|
||||
function createTree(text: ts.IScriptSnapshot, version: string) {
|
||||
return ts.createLanguageServiceSourceFile(/*fileName:*/ "", text, ts.ScriptTarget.Latest, version, /*setNodeParents:*/ true);
|
||||
return ts.createLanguageServiceSourceFile(/*fileName:*/ "", text, ts.ScriptTarget.Latest, version, /*setNodeParents*/ true);
|
||||
}
|
||||
|
||||
function assertSameDiagnostics(file1: ts.SourceFile, file2: ts.SourceFile) {
|
||||
|
|
|
@ -433,7 +433,7 @@ oh.no
|
|||
describe("getStart", () => {
|
||||
it("runs when node with JSDoc but no parent pointers", () => {
|
||||
const root = ts.createSourceFile("foo.ts", "/** */var a = true;", ts.ScriptTarget.ES5, /*setParentNodes*/ false);
|
||||
root.statements[0].getStart(root, /*includeJsdocComment*/ true);
|
||||
root.statements[0].getStart(root, /*includeJsDocComment*/ true);
|
||||
});
|
||||
});
|
||||
describe("parseIsolatedJSDocComment", () => {
|
||||
|
|
|
@ -99,7 +99,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
|
||||
describe("No duplicate ref directives when emiting .d.ts->.d.ts", () => {
|
||||
it("without statements", () => {
|
||||
const host = new fakes.CompilerHost(new vfs.FileSystem(true, {
|
||||
const host = new fakes.CompilerHost(new vfs.FileSystem(/*ignoreCase*/ true, {
|
||||
files: {
|
||||
"/test.d.ts": `/// <reference types="node" />\n/// <reference path="./src/test.d.ts />\n`
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
assert.equal(output.split(/\r?\n/g).length, 3);
|
||||
});
|
||||
it("with statements", () => {
|
||||
const host = new fakes.CompilerHost(new vfs.FileSystem(true, {
|
||||
const host = new fakes.CompilerHost(new vfs.FileSystem(/*ignoreCase*/ true, {
|
||||
files: {
|
||||
"/test.d.ts": `/// <reference types="node" />\n/// <reference path="./src/test.d.ts />\nvar a: number;\n`
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
[ts.factory.createPropertyDeclaration(
|
||||
ts.factory.createNodeArray([ts.factory.createToken(ts.SyntaxKind.PublicKeyword)]),
|
||||
ts.factory.createIdentifier("prop"),
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
/*initializer*/ undefined
|
||||
)]
|
||||
|
@ -254,7 +254,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
ts.EmitHint.Unspecified,
|
||||
ts.setEmitFlags(ts.factory.createTupleTypeNode([
|
||||
ts.factory.createFunctionTypeNode(
|
||||
/*typeArguments*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
[ts.factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
|
@ -272,7 +272,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)
|
||||
),
|
||||
ts.factory.createFunctionTypeNode(
|
||||
/*typeArguments*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
[ts.factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
ts.factory.createToken(ts.SyntaxKind.DotDotDotToken),
|
||||
|
@ -281,7 +281,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)
|
||||
),
|
||||
ts.factory.createFunctionTypeNode(
|
||||
/*typeArguments*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
[ts.factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
|
@ -291,7 +291,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)
|
||||
),
|
||||
ts.factory.createFunctionTypeNode(
|
||||
/*typeArguments*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
[ts.factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
|
@ -302,7 +302,7 @@ describe("unittests:: PrinterAPI", () => {
|
|||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)
|
||||
),
|
||||
ts.factory.createFunctionTypeNode(
|
||||
/*typeArguments*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
[ts.factory.createParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
|
|
|
@ -9,7 +9,7 @@ function testExtractRangeFailed(caption: string, s: string, expectedErrors: stri
|
|||
if (!selectionRange) {
|
||||
throw new Error(`Test ${s} does not specify selection range`);
|
||||
}
|
||||
const result = ts.refactor.extractSymbol.getRangeToExtract(file, ts.createTextSpanFromRange(selectionRange), /*userRequested*/ false);
|
||||
const result = ts.refactor.extractSymbol.getRangeToExtract(file, ts.createTextSpanFromRange(selectionRange), /*invoked*/ false);
|
||||
assert(result.targetRange === undefined, "failure expected");
|
||||
const sortedErrors = result.errors.map(e => e.messageText as string).sort();
|
||||
assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors");
|
||||
|
|
|
@ -180,7 +180,7 @@ var a = 4; // comment 7
|
|||
});
|
||||
}
|
||||
function createTestVariableDeclaration(name: string) {
|
||||
return ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createObjectLiteralExpression([ts.factory.createPropertyAssignment("p1", ts.factory.createNumericLiteral(1))], /*multiline*/ true));
|
||||
return ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createObjectLiteralExpression([ts.factory.createPropertyAssignment("p1", ts.factory.createNumericLiteral(1))], /*multiLine*/ true));
|
||||
}
|
||||
function createTestClass() {
|
||||
return ts.factory.createClassDeclaration(
|
||||
|
@ -201,7 +201,7 @@ var a = 4; // comment 7
|
|||
ts.factory.createPropertyDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
"property1",
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),
|
||||
/*initializer*/ undefined
|
||||
)
|
||||
|
@ -553,8 +553,7 @@ import {
|
|||
x
|
||||
} from "bar"`;
|
||||
runSingleFileTest("insertNodeInListAfter12", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, undefined, ts.factory.createIdentifier("a")));
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.factory.createIdentifier("a")));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
@ -563,8 +562,7 @@ import {
|
|||
x // this is x
|
||||
} from "bar"`;
|
||||
runSingleFileTest("insertNodeInListAfter13", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, undefined, ts.factory.createIdentifier("a")));
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.factory.createIdentifier("a")));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
@ -594,8 +592,7 @@ import {
|
|||
x
|
||||
} from "bar"`;
|
||||
runSingleFileTest("insertNodeInListAfter16", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, undefined, ts.factory.createIdentifier("a")));
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.factory.createIdentifier("a")));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
@ -605,8 +602,7 @@ import {
|
|||
x // this is x
|
||||
} from "bar"`;
|
||||
runSingleFileTest("insertNodeInListAfter17", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, undefined, ts.factory.createIdentifier("a")));
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.factory.createIdentifier("a")));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
@ -615,15 +611,13 @@ import {
|
|||
x0, x
|
||||
} from "bar"`;
|
||||
runSingleFileTest("insertNodeInListAfter18", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, undefined, ts.factory.createIdentifier("a")));
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.factory.createIdentifier("a")));
|
||||
});
|
||||
}
|
||||
{
|
||||
const runTest = (name: string, text: string) => runSingleFileTest(name, /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
for (const specifier of ["x3", "x4", "x5"]) {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x2", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, undefined, ts.factory.createIdentifier(specifier)));
|
||||
changeTracker.insertNodeInListAfter(sourceFile, findChild("x2", sourceFile), ts.factory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.factory.createIdentifier(specifier)));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -642,8 +636,7 @@ class A {
|
|||
const newNodes = [];
|
||||
for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) {
|
||||
newNodes.push(
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
ts.factory.createPropertyDeclaration(undefined, i + "", undefined, undefined, undefined));
|
||||
ts.factory.createPropertyDeclaration(/*modifiers*/ undefined, i + "", /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
|
||||
}
|
||||
const insertAfter = findChild("x", sourceFile);
|
||||
for (const newNode of newNodes) {
|
||||
|
@ -658,8 +651,7 @@ class A {
|
|||
}
|
||||
`;
|
||||
runSingleFileTest("insertNodeAfterInClass1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), ts.factory.createPropertyDeclaration(undefined, "a", undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), undefined));
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), ts.factory.createPropertyDeclaration(/*modifiers*/ undefined, "a", /*questionOrExclamationToken*/ undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), /*initializer*/ undefined));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
@ -669,8 +661,7 @@ class A {
|
|||
}
|
||||
`;
|
||||
runSingleFileTest("insertNodeAfterInClass2", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
|
||||
// eslint-disable-next-line local/boolean-trivia
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), ts.factory.createPropertyDeclaration(undefined, "a", undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), undefined));
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), ts.factory.createPropertyDeclaration(/*modifiers*/ undefined, "a", /*questionOrExclamationToken*/ undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), /*initializer*/ undefined));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
@ -705,7 +696,7 @@ class A {
|
|||
const newNode = ts.factory.createPropertyDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(1)),
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
||||
/*initializer*/ undefined);
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode);
|
||||
|
@ -722,7 +713,7 @@ class A {
|
|||
const newNode = ts.factory.createPropertyDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(1)),
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
||||
/*initializer*/ undefined);
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode);
|
||||
|
@ -738,7 +729,7 @@ interface A {
|
|||
const newNode = ts.factory.createPropertyDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(1)),
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
||||
/*initializer*/ undefined);
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode);
|
||||
|
@ -754,7 +745,7 @@ interface A {
|
|||
const newNode = ts.factory.createPropertyDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(1)),
|
||||
/*questionToken*/ undefined,
|
||||
/*questionOrExclamationToken*/ undefined,
|
||||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
||||
/*initializer*/ undefined);
|
||||
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode);
|
||||
|
|
|
@ -347,7 +347,7 @@ describe("unittests:: TransformAPI", () => {
|
|||
function visitNode(sf: ts.SourceFile) {
|
||||
// produce `class Foo { @Bar baz() {} }`;
|
||||
const classDecl = ts.factory.createClassDeclaration(/*modifiers*/ undefined, "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [
|
||||
ts.factory.createMethodDeclaration([ts.factory.createDecorator(ts.factory.createIdentifier("Bar"))], /**/ undefined, "baz", /**/ undefined, /**/ undefined, [], /**/ undefined, ts.factory.createBlock([]))
|
||||
ts.factory.createMethodDeclaration([ts.factory.createDecorator(ts.factory.createIdentifier("Bar"))], /*asteriskToken*/ undefined, "baz", /*questionToken*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.factory.createBlock([]))
|
||||
]);
|
||||
return ts.factory.updateSourceFile(sf, [classDecl]);
|
||||
}
|
||||
|
@ -396,10 +396,10 @@ describe("unittests:: TransformAPI", () => {
|
|||
});
|
||||
|
||||
function baselineDeclarationTransform(text: string, opts: ts.TranspileOptions) {
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*caseSensitive*/ true, { documents: [new documents.TextDocument("/.src/index.ts", text)] });
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ true, { documents: [new documents.TextDocument("/.src/index.ts", text)] });
|
||||
const host = new fakes.CompilerHost(fs, opts.compilerOptions);
|
||||
const program = ts.createProgram(["/.src/index.ts"], opts.compilerOptions!, host);
|
||||
program.emit(program.getSourceFile("/.src/index.ts"), (p, s, bom) => host.writeFile(p, s, bom), /*cancellationToken*/ undefined, /*onlyDts*/ true, opts.transformers);
|
||||
program.emit(program.getSourceFile("/.src/index.ts"), (p, s, bom) => host.writeFile(p, s, bom), /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ true, opts.transformers);
|
||||
return fs.readFileSync("/.src/index.d.ts").toString();
|
||||
}
|
||||
|
||||
|
@ -545,7 +545,7 @@ module MyModule {
|
|||
|
||||
// https://github.com/Microsoft/TypeScript/issues/24709
|
||||
testBaseline("issue24709", () => {
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*caseSensitive*/ true);
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ true);
|
||||
const transformed = ts.transform(ts.createSourceFile("source.ts", "class X { echo(x: string) { return x; } }", ts.ScriptTarget.ES3), [transformSourceFile]);
|
||||
const transformedSourceFile = transformed.transformed[0];
|
||||
transformed.dispose();
|
||||
|
@ -613,7 +613,7 @@ module MyModule {
|
|||
};
|
||||
function rootTransform<T extends ts.Node>(node: T): ts.Node {
|
||||
if (ts.isClassLike(node)) {
|
||||
const newMembers = [ts.factory.createPropertyDeclaration([ts.factory.createModifier(ts.SyntaxKind.StaticKeyword)], "newField", /* questionOrExclamationToken */ undefined, /* type */ undefined, ts.factory.createStringLiteral("x"))];
|
||||
const newMembers = [ts.factory.createPropertyDeclaration([ts.factory.createModifier(ts.SyntaxKind.StaticKeyword)], "newField", /*questionOrExclamationToken*/ undefined, /*type*/ undefined, ts.factory.createStringLiteral("x"))];
|
||||
ts.setSyntheticLeadingComments(newMembers[0], [{ kind: ts.SyntaxKind.MultiLineCommentTrivia, text: "comment", pos: -1, end: -1, hasTrailingNewLine: true }]);
|
||||
return ts.isClassDeclaration(node) ?
|
||||
ts.factory.updateClassDeclaration(
|
||||
|
|
|
@ -19,7 +19,7 @@ describe("unittests:: tsbuild - graph-ordering", () => {
|
|||
];
|
||||
|
||||
before(() => {
|
||||
const fs = new vfs.FileSystem(false);
|
||||
const fs = new vfs.FileSystem(/*ignoreCase*/ false);
|
||||
host = fakes.SolutionBuilderHost.create(fs);
|
||||
writeProjects(fs, ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"], deps);
|
||||
});
|
||||
|
|
|
@ -145,7 +145,7 @@ describe("unittests:: tsc:: builder cancellationToken", () => {
|
|||
parsedConfig.options,
|
||||
host,
|
||||
builderProgram,
|
||||
/* configFileParsingDiagnostics*/ undefined,
|
||||
/*configFileParsingDiagnostics*/ undefined,
|
||||
/*projectReferences*/ undefined,
|
||||
);
|
||||
updatePrograms();
|
||||
|
@ -174,7 +174,7 @@ describe("unittests:: tsc:: builder cancellationToken", () => {
|
|||
parsedConfig.options,
|
||||
host,
|
||||
/*oldProgram*/ undefined,
|
||||
/* configFileParsingDiagnostics*/ undefined,
|
||||
/*configFileParsingDiagnostics*/ undefined,
|
||||
/*projectReferences*/ undefined,
|
||||
);
|
||||
updatePrograms();
|
||||
|
|
|
@ -674,7 +674,7 @@ export function baselineBuildInfo(
|
|||
generateBuildInfoProgramBaseline(sys, buildInfoPath, buildInfo);
|
||||
|
||||
if (!ts.outFile(options)) return;
|
||||
const { jsFilePath, declarationFilePath } = ts.getOutputPathsForBundle(options, /*forceDts*/ false);
|
||||
const { jsFilePath, declarationFilePath } = ts.getOutputPathsForBundle(options, /*forceDtsPaths*/ false);
|
||||
const bundle = buildInfo.bundle;
|
||||
if (!bundle || (!ts.length(bundle.js && bundle.js.sections) && !ts.length(bundle.dts && bundle.dts.sections))) return;
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ describe("unittests:: tsc-watch:: watchAPI:: when watchHost uses createSemanticD
|
|||
const diagnostics = ts.sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics());
|
||||
diagnostics.forEach(reportDiagnostic);
|
||||
// Buildinfo should still have affectedFilesPendingEmit since we are only emitting dts files
|
||||
program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDts*/ true);
|
||||
program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ true);
|
||||
reportWatchStatus(
|
||||
ts.createCompilerDiagnostic(ts.getWatchErrorSummaryDiagnosticMessage(diagnostics.length), diagnostics.length),
|
||||
sys.newLine,
|
||||
|
|
|
@ -29,7 +29,7 @@ describe("unittests:: tsserver:: cancellationToken", () => {
|
|||
isCancellationRequested: () => false,
|
||||
setRequest: requestId => {
|
||||
if (expectedRequestId === undefined) {
|
||||
assert.isTrue(false, "unexpected call");
|
||||
assert.fail("unexpected call");
|
||||
}
|
||||
assert.equal(requestId, expectedRequestId);
|
||||
},
|
||||
|
|
|
@ -851,13 +851,13 @@ describe("unittests:: tsserver:: compileOnSave:: EmitFile test", () => {
|
|||
|
||||
describe("compile on save emit with and without richResponse", () => {
|
||||
it("without rich Response", () => {
|
||||
verify(/*richRepsonse*/ undefined);
|
||||
verify(/*richResponse*/ undefined);
|
||||
});
|
||||
it("with rich Response set to false", () => {
|
||||
verify(/*richRepsonse*/ false);
|
||||
verify(/*richResponse*/ false);
|
||||
});
|
||||
it("with rich Repsonse", () => {
|
||||
verify(/*richRepsonse*/ true);
|
||||
verify(/*richResponse*/ true);
|
||||
});
|
||||
|
||||
function verify(richResponse: boolean | undefined) {
|
||||
|
|
|
@ -1530,7 +1530,7 @@ const b: B = new B();`
|
|||
});
|
||||
}
|
||||
|
||||
/* eslint-disable local/boolean-trivia */
|
||||
/* eslint-disable local/argument-trivia */
|
||||
|
||||
// Pre-loaded = A file from project B is already open when FAR is invoked
|
||||
// dRPL = Project A has disableReferencedProjectLoad
|
||||
|
@ -1557,6 +1557,6 @@ const b: B = new B();`
|
|||
baselineDisableReferencedProjectLoad(false, false, false, true); // Loaded | Via redirect | index.ts, helper.ts |
|
||||
baselineDisableReferencedProjectLoad(false, false, false, false); // Loaded | Via redirect | index.ts, helper.ts |
|
||||
|
||||
/* eslint-enable local/boolean-trivia */
|
||||
/* eslint-enable local/argument-trivia */
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ describe("unittests :: internalApi :: typeParameterIsPossiblyReferenced", () =>
|
|||
`;
|
||||
const host = new fakes.CompilerHost(vfs.createFromFileSystem(
|
||||
Harness.IO,
|
||||
/*ignoreCases*/ true,
|
||||
/*ignoreCase*/ true,
|
||||
{
|
||||
documents: [
|
||||
new documents.TextDocument("/file.ts", content)
|
||||
|
|
Загрузка…
Ссылка в новой задаче