Compare commits

..

4 commits

Author SHA1 Message Date
Daniel Rosenwasser e01927271e Undo CRLF -> LF change. 2021-11-16 12:34:00 -07:00
Daniel Rosenwasser 5bcffa11d8
Merge branch 'main' into codeFixesHaveFunctionNames 2021-11-16 11:32:31 -07:00
Daniel Rosenwasser c9f6b0750a Remove double space. 2021-11-08 10:54:50 -08:00
Daniel Rosenwasser f6a993f394 Add function names for code fixes. 2021-11-08 09:44:56 +00:00
95 changed files with 190 additions and 1331 deletions

12
package-lock.json generated
View file

@ -676,9 +676,9 @@
"dev": true
},
"@types/node": {
"version": "16.11.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz",
"integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==",
"version": "16.11.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.7.tgz",
"integrity": "sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw==",
"dev": true
},
"@types/node-fetch": {
@ -6997,9 +6997,9 @@
}
},
"source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"version": "0.5.20",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.20.tgz",
"integrity": "sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",

View file

@ -5657,8 +5657,8 @@ namespace ts {
const expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
const parameters = (some(expandedParams, p => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & CheckFlags.RestParameter)) ? signature.parameters : expandedParams).map(parameter => symbolToParameterDeclaration(parameter, context, kind === SyntaxKind.Constructor, options?.privateSymbolVisitor, options?.bundledImports));
const thisParameter = tryGetThisParameterDeclaration(signature, context);
if (thisParameter) {
if (signature.thisParameter) {
const thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
parameters.unshift(thisParameter);
}
@ -5713,25 +5713,6 @@ namespace ts {
return node;
}
function tryGetThisParameterDeclaration(signature: Signature, context: NodeBuilderContext) {
if (signature.thisParameter) {
return symbolToParameterDeclaration(signature.thisParameter, context);
}
if (signature.declaration) {
const thisTag = getJSDocThisTag(signature.declaration);
if (thisTag && thisTag.typeExpression) {
return factory.createParameterDeclaration(
/* decorators */ undefined,
/* modifiers */ undefined,
/* dotDotDotToken */ undefined,
"this",
/* questionToken */ undefined,
typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context)
);
}
}
}
function typeParameterToDeclarationWithConstraint(type: TypeParameter, context: NodeBuilderContext, constraintNode: TypeNode | undefined): TypeParameterDeclaration {
const savedContextFlags = context.flags;
context.flags &= ~NodeBuilderFlags.WriteTypeParametersInQualifiedName; // Avoids potential infinite loop when building for a claimspace with a generic
@ -6223,8 +6204,12 @@ namespace ts {
firstChar = symbolName.charCodeAt(0);
}
let expression: Expression | undefined;
if (isSingleOrDoubleQuote(firstChar) && !(symbol.flags & SymbolFlags.EnumMember)) {
expression = factory.createStringLiteral(stripQuotes(symbolName).replace(/\\./g, s => s.substring(1)), firstChar === CharacterCodes.singleQuote);
if (isSingleOrDoubleQuote(firstChar)) {
expression = factory.createStringLiteral(
symbolName
.substring(1, symbolName.length - 1)
.replace(/\\./g, s => s.substring(1)),
firstChar === CharacterCodes.singleQuote);
}
else if (("" + +symbolName) === symbolName) {
expression = factory.createNumericLiteral(+symbolName);
@ -40422,8 +40407,9 @@ namespace ts {
const enclosingFile = getSourceFileOfNode(node);
const links = getNodeLinks(enclosingFile);
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
links.deferredNodes ||= new Set();
links.deferredNodes.add(node);
links.deferredNodes = links.deferredNodes || new Map();
const id = getNodeId(node);
links.deferredNodes.set(id, node);
}
}

View file

@ -23,6 +23,34 @@ namespace ts {
export const emptyMap: ReadonlyESMap<never, never> = new Map<never, never>();
export const emptySet: ReadonlySet<never> = new Set<never>();
/**
* Create a new map.
* @deprecated Use `new Map()` instead.
*/
export function createMap<K, V>(): ESMap<K, V>;
export function createMap<T>(): ESMap<string, T>;
export function createMap<K, V>(): ESMap<K, V> {
return new Map<K, V>();
}
/**
* Create a new map from a template object is provided, the map will copy entries from it.
* @deprecated Use `new Map(getEntries(template))` instead.
*/
export function createMapFromTemplate<T>(template: MapLike<T>): ESMap<string, T> {
const map: ESMap<string, T> = new Map<string, T>();
// Copies keys/values from template. Note that for..in will not throw if
// template is undefined, and instead will just exit the loop.
for (const key in template) {
if (hasOwnProperty.call(template, key)) {
map.set(key, template[key]);
}
}
return map;
}
export function length(array: readonly any[] | undefined): number {
return array ? array.length : 0;
}

View file

@ -171,6 +171,12 @@ namespace ts {
return value;
}
/**
* @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
* a value is defined at the statement level.
*/
export const assertDefined = checkDefined;
export function assertEachIsDefined<T extends Node>(value: NodeArray<T>, message?: string, stackCrawlMark?: AnyFunction): asserts value is NodeArray<T>;
export function assertEachIsDefined<T>(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction): asserts value is readonly NonNullable<T>[];
export function assertEachIsDefined<T>(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction) {
@ -184,6 +190,12 @@ namespace ts {
return value;
}
/**
* @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
* the elements of an array are defined at the statement level.
*/
export const assertEachDefined = checkEachDefined;
export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never {
const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member);
return fail(`${message} ${detail}`, stackCrawlMark || assertNever);

View file

@ -6387,7 +6387,7 @@ namespace ts {
sourceMapText = mapTextOrStripInternal as string;
}
const node = oldFileOfCurrentEmit ?
parseOldFileOfCurrentEmit(Debug.checkDefined(bundleFileInfo)) :
parseOldFileOfCurrentEmit(Debug.assertDefined(bundleFileInfo)) :
parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
node.fileName = fileName;
node.sourceMapPath = sourceMapPath;
@ -6587,13 +6587,13 @@ namespace ts {
};
node.javascriptPath = declarationTextOrJavascriptPath;
node.javascriptMapPath = javascriptMapPath;
node.declarationPath = Debug.checkDefined(javascriptMapTextOrDeclarationPath);
node.declarationPath = Debug.assertDefined(javascriptMapTextOrDeclarationPath);
node.declarationMapPath = declarationMapPath;
node.buildInfoPath = declarationMapTextOrBuildInfoPath;
Object.defineProperties(node, {
javascriptText: { get() { return definedTextGetter(declarationTextOrJavascriptPath); } },
javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, // TODO:: if there is inline sourceMap in jsFile, use that
declarationText: { get() { return definedTextGetter(Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
declarationText: { get() { return definedTextGetter(Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
declarationMapText: { get() { return textGetter(declarationMapPath); } }, // TODO:: if there is inline sourceMap in dtsFile, use that
buildInfo: { get() { return getAndCacheBuildInfo(() => textGetter(declarationMapTextOrBuildInfoPath)); } }
});

View file

@ -818,25 +818,6 @@ namespace ts {
}
}
/** @internal */
export const plainJSErrors: Set<number> = new Set([
Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
Diagnostics.A_module_cannot_have_multiple_default_exports.code,
Diagnostics.Another_export_default_is_here.code,
Diagnostics.The_first_export_default_is_here.code,
Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module.code,
Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode.code,
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here.code,
Diagnostics.constructor_is_a_reserved_word.code,
Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode.code,
Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode.code,
Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
Diagnostics.Invalid_use_of_0_in_strict_mode.code,
Diagnostics.A_label_is_not_allowed_here.code,
Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
]);
/**
* Determine if source file needs to be re-created even if its text hasn't changed
*/
@ -1596,7 +1577,6 @@ namespace ts {
newSourceFile.originalFileName = oldSourceFile.originalFileName;
newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
newSourceFile.fileName = oldSourceFile.fileName;
newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
const packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
if (packageName !== undefined) {
@ -2024,24 +2004,15 @@ namespace ts {
Debug.assert(!!sourceFile.bindDiagnostics);
const isJs = sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX;
const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
const isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
const isCheckJs = isCheckJsEnabledForFile(sourceFile, options);
const isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
// By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
// - plain JS: .js files with no // ts-check and checkJs: undefined
// - check JS: .js files with either // ts-check or checkJs: true
// - external: files that are added by plugins
// By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
let bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
const checkDiagnostics = includeBindAndCheckDiagnostics && !isPlainJs ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
if (isPlainJs) {
bindDiagnostics = filter(bindDiagnostics, d => plainJSErrors.has(d.code));
}
// skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
|| sourceFile.scriptKind === ScriptKind.External || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
const bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
const checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
});
}
@ -3189,7 +3160,7 @@ namespace ts {
}
function verifyCompilerOptions() {
const isNightly = stringContains(version, "-dev") || stringContains(version, "-insiders");
const isNightly = stringContains(version, "-dev");
if (!isNightly) {
if (getEmitModuleKind(options) === ModuleKind.Node12) {
createOptionValueDiagnostic("module", Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");

View file

@ -619,7 +619,7 @@ namespace ts {
) {
if (resolution.refCount) {
resolution.refCount++;
Debug.assertIsDefined(resolution.files);
Debug.assertDefined(resolution.files);
}
else {
resolution.refCount = 1;
@ -696,7 +696,7 @@ namespace ts {
filePath: Path,
getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>,
) {
unorderedRemoveItem(Debug.checkDefined(resolution.files), filePath);
unorderedRemoveItem(Debug.assertDefined(resolution.files), filePath);
resolution.refCount!--;
if (resolution.refCount) {
return;
@ -798,7 +798,7 @@ namespace ts {
for (const resolution of resolutions) {
if (resolution.isInvalidated || !canInvalidate(resolution)) continue;
resolution.isInvalidated = invalidated = true;
for (const containingFilePath of Debug.checkDefined(resolution.files)) {
for (const containingFilePath of Debug.assertDefined(resolution.files)) {
(filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new Set())).add(containingFilePath);
// When its a file with inferred types resolution, invalidate type reference directive resolution
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);

View file

@ -282,7 +282,7 @@ namespace ts {
function visitYieldExpression(node: YieldExpression) {
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
if (node.asteriskToken) {
const expression = visitNode(Debug.checkDefined(node.expression), visitor, isExpression);
const expression = visitNode(Debug.assertDefined(node.expression), visitor, isExpression);
return setOriginalNode(
setTextRange(

View file

@ -48,11 +48,11 @@ namespace ts {
return existing.name;
}
if (!currentFileState.utilizedImplicitRuntimeImports) {
currentFileState.utilizedImplicitRuntimeImports = new Map();
currentFileState.utilizedImplicitRuntimeImports = createMap();
}
let specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
if (!specifierSourceImports) {
specifierSourceImports = new Map();
specifierSourceImports = createMap();
currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
}
const generatedName = factory.createUniqueName(`_${name}`, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.AllowNameSubstitution);

View file

@ -1609,7 +1609,7 @@ namespace ts {
export interface TypePredicateNode extends TypeNode {
readonly kind: SyntaxKind.TypePredicate;
readonly parent: SignatureDeclaration | JSDocTypeExpression;
readonly assertsModifier?: AssertsKeyword;
readonly assertsModifier?: AssertsToken;
readonly parameterName: Identifier | ThisTypeNode;
readonly type?: TypeNode;
}
@ -1702,7 +1702,7 @@ namespace ts {
export interface MappedTypeNode extends TypeNode, Declaration {
readonly kind: SyntaxKind.MappedType;
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken;
readonly typeParameter: TypeParameterDeclaration;
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
@ -2756,7 +2756,7 @@ namespace ts {
export interface ForOfStatement extends IterationStatement {
readonly kind: SyntaxKind.ForOfStatement;
readonly awaitModifier?: AwaitKeyword;
readonly awaitModifier?: AwaitKeywordToken;
readonly initializer: ForInitializer;
readonly expression: Expression;
}
@ -5107,7 +5107,7 @@ namespace ts {
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
deferredNodes?: Set<Node>; // Set of nodes whose checking has been deferred
deferredNodes?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
isExhaustive?: boolean; // Is node an exhaustive switch statement

View file

@ -20,6 +20,21 @@ namespace ts {
return undefined;
}
/**
* Create a new escaped identifier map.
* @deprecated Use `new Map<__String, T>()` instead.
*/
export function createUnderscoreEscapedMap<T>(): UnderscoreEscapedMap<T> {
return new Map<__String, T>();
}
/**
* @deprecated Use `!!map?.size` instead
*/
export function hasEntries(map: ReadonlyCollection<any> | undefined): map is ReadonlyCollection<any> {
return !!map && !!map.size;
}
export function createSymbolTable(symbols?: readonly Symbol[]): SymbolTable {
const result = new Map<__String, Symbol>();
if (symbols) {
@ -6979,6 +6994,18 @@ namespace ts {
return { min, max };
}
/** @deprecated Use `ReadonlySet<TNode>` instead. */
export type ReadonlyNodeSet<TNode extends Node> = ReadonlySet<TNode>;
/** @deprecated Use `Set<TNode>` instead. */
export type NodeSet<TNode extends Node> = Set<TNode>;
/** @deprecated Use `ReadonlyMap<TNode, TValue>` instead. */
export type ReadonlyNodeMap<TNode extends Node, TValue> = ReadonlyESMap<TNode, TValue>;
/** @deprecated Use `Map<TNode, TValue>` instead. */
export type NodeMap<TNode extends Node, TValue> = ESMap<TNode, TValue>;
export function rangeOfNode(node: Node): TextRange {
return { pos: getTokenPosOfNode(node), end: node.end };
}

View file

@ -637,8 +637,7 @@ namespace FourSlash {
ts.forEachKey(this.inputFiles, fileName => {
if (!ts.isAnySupportedFileExtension(fileName)
|| Harness.getConfigNameFromFileName(fileName)
// Can't get a Program in Server tests
|| this.testType !== FourSlashTestType.Server && !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
|| !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
|| ts.getBaseFileName(fileName) === "package.json") return;
const errors = this.getDiagnostics(fileName).filter(e => e.category !== ts.DiagnosticCategory.Suggestion);
if (errors.length) {

View file

@ -1944,15 +1944,15 @@ namespace ts.server {
for (const resolution of resolutions) {
if (!resolution.resolvedFileName) continue;
const { resolvedFileName, originalPath } = resolution;
if (originalPath) {
symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
}
if (!program.getSourceFile(resolvedFileName) && (!originalPath || !program.getSourceFile(originalPath))) {
rootNames = append(rootNames, resolvedFileName);
// Avoid creating a large project that would significantly slow down time to editor interactivity
if (dependencySelection === PackageJsonAutoImportPreference.Auto && rootNames.length > this.maxDependencies) {
return ts.emptyArray;
}
if (originalPath) {
symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
}
}
}
}

View file

@ -2112,7 +2112,7 @@ namespace ts.server {
private getFullNavigateToItems(args: protocol.NavtoRequestArgs): CombineOutputResult<NavigateToItem> {
const { currentFileOnly, searchValue, maxResultCount, projectFileName } = args;
if (currentFileOnly) {
Debug.assertIsDefined(args.file);
Debug.assertDefined(args.file);
const { file, project } = this.getFileAndProject(args as protocol.FileRequestArgs);
return [{ project, result: project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file) }];
}

View file

@ -4,7 +4,7 @@ namespace ts.codefix {
const errorCodes = [Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first.code];
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
return [createCodeFixAction(fixId, changes, Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)];
},

View file

@ -5,7 +5,7 @@ namespace ts.codefix {
Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code,
Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code,
],
getCodeActions: context => {
getCodeActions: function getCodeActionsToAddEmptyExportDeclaration(context) {
const { sourceFile } = context;
const changes = textChanges.ChangeTracker.with(context, changes => {
const exportDeclaration = factory.createExportDeclaration(

View file

@ -11,7 +11,7 @@ namespace ts.codefix {
registerCodeFix({
fixIds: [fixId],
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToAddMissingAsync(context) {
const { sourceFile, errorCode, cancellationToken, program, span } = context;
const diagnostic = find(program.getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
const directSpan = diagnostic && diagnostic.relatedInformation && find(diagnostic.relatedInformation, r => r.code === Diagnostics.Did_you_mean_to_mark_this_function_as_async.code) as TextSpan | undefined;

View file

@ -30,7 +30,7 @@ namespace ts.codefix {
registerCodeFix({
fixIds: [fixId],
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToAddMissingAwait(context) {
const { sourceFile, errorCode, span, cancellationToken, program } = context;
const expression = getAwaitErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program);
if (!expression) {

View file

@ -8,7 +8,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsToAddMissingConst(context) {
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start, context.program));
if (changes.length > 0) {
return [createCodeFixAction(fixId, changes, Diagnostics.Add_const_to_unresolved_variable, fixId, Diagnostics.Add_const_to_all_unresolved_variables)];

View file

@ -7,7 +7,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsToAddMissingDeclareOnProperty(context) {
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
if (changes.length > 0) {
return [createCodeFixAction(fixId, changes, Diagnostics.Prefix_with_declare, fixId, Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)];

View file

@ -4,7 +4,7 @@ namespace ts.codefix {
const errorCodes = [Diagnostics._0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0.code];
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsToAddMissingInvocationForDecorator(context) {
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
return [createCodeFixAction(fixId, changes, Diagnostics.Call_decorator_expression, fixId, Diagnostics.Add_to_all_uncalled_decorators)];
},

View file

@ -4,7 +4,7 @@ namespace ts.codefix {
const errorCodes = [Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1.code];
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsToAddNameToNamelessParameter(context) {
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
return [createCodeFixAction(fixId, changes, Diagnostics.Add_parameter_name, fixId, Diagnostics.Add_names_to_all_parameters_without_names)];
},

View file

@ -5,7 +5,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
const { sourceFile, span, program } = context;
const range = getConstTokenRange(sourceFile, span.start, program);
if (range === undefined) return;

View file

@ -5,7 +5,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToConvertLiteralTypeToMappedType(context) {
const { sourceFile, span } = context;
const info = getInfo(sourceFile, span.start);
if (!info) {

View file

@ -1,14 +1,13 @@
/* @internal */
namespace ts.codefix {
const fixIdAddMissingTypeof = "fixConvertToMappedObjectType";
const fixId = fixIdAddMissingTypeof;
const fixId = "fixConvertToMappedObjectType";
const errorCodes = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
type FixableDeclaration = InterfaceDeclaration | TypeAliasDeclaration;
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
const { sourceFile, span } = context;
const info = getInfo(sourceFile, span.start);
if (!info) return undefined;

View file

@ -4,14 +4,14 @@ namespace ts.codefix {
const fixId = "convertToTypeOnlyExport";
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToConvertToTypeOnlyExport(context) {
const changes = textChanges.ChangeTracker.with(context, t => fixSingleExportDeclaration(t, getExportSpecifierForDiagnosticSpan(context.span, context.sourceFile), context));
if (changes.length) {
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_to_type_only_export, fixId, Diagnostics.Convert_all_re_exported_types_to_type_only_exports)];
}
},
fixIds: [fixId],
getAllCodeActions: context => {
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyExport(context) {
const fixedExportDeclarations = new Map<number, true>();
return codeFixAll(context, errorCodes, (changes, diag) => {
const exportSpecifier = getExportSpecifierForDiagnosticSpan(diag, context.sourceFile);

View file

@ -4,7 +4,7 @@ namespace ts.codefix {
const fixId = "convertToTypeOnlyImport";
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
const changes = textChanges.ChangeTracker.with(context, t => {
const importDeclaration = getImportDeclarationForDiagnosticSpan(context.span, context.sourceFile);
fixSingleImportDeclaration(t, importDeclaration, context);
@ -14,7 +14,7 @@ namespace ts.codefix {
}
},
fixIds: [fixId],
getAllCodeActions: context => {
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
return codeFixAll(context, errorCodes, (changes, diag) => {
const importDeclaration = getImportDeclarationForDiagnosticSpan(diag, context.sourceFile);
fixSingleImportDeclaration(changes, importDeclaration, context);

View file

@ -9,7 +9,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions(context) {
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
const { sourceFile, program, span, host, formatContext } = context;
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {

View file

@ -6,7 +6,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
const { sourceFile, span } = context;
const importType = getImportTypeNode(sourceFile, span.start);
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, importType));

View file

@ -15,7 +15,7 @@ namespace ts.codefix {
return [createCodeFixAction(fixId, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId, Diagnostics.Add_all_missing_async_modifiers)];
},
fixIds: [fixId],
getAllCodeActions: context => {
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
const seen = new Map<number, true>();
return codeFixAll(context, errorCodes, (changes, diag) => {
const nodes = getNodes(diag.file, diag.start);

View file

@ -10,7 +10,7 @@ namespace ts.codefix {
];
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
const { host, sourceFile, span: { start } } = context;
const packageName = tryGetImportedPackageName(sourceFile, start);
if (packageName === undefined) return undefined;

View file

@ -7,14 +7,14 @@ namespace ts.codefix {
const fixId = "fixClassDoesntImplementInheritedAbstractMember";
registerCodeFix({
errorCodes,
getCodeActions(context) {
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
const { sourceFile, span } = context;
const changes = textChanges.ChangeTracker.with(context, t =>
addMissingMembers(getClass(sourceFile, span.start), sourceFile, context, t, context.preferences));
return changes.length === 0 ? undefined : [createCodeFixAction(fixId, changes, Diagnostics.Implement_inherited_abstract_class, fixId, Diagnostics.Implement_all_inherited_abstract_classes)];
},
fixIds: [fixId],
getAllCodeActions: context => {
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
const seenClassDeclarations = new Map<number, true>();
return codeFixAll(context, errorCodes, (changes, diag) => {
const classDeclaration = getClass(diag.file, diag.start);

View file

@ -6,7 +6,7 @@ namespace ts.codefix {
];
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsToEnableExperimentalDecorators(context) {
const { configFile } = context.program.getCompilerOptions();
if (configFile === undefined) {
return undefined;

View file

@ -4,7 +4,7 @@ namespace ts.codefix {
const errorCodes = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
const { configFile } = context.program.getCompilerOptions();
if (configFile === undefined) {
return undefined;

View file

@ -26,9 +26,9 @@ namespace ts.codefix {
if (!isFunctionDeclaration(fn) && !isFunctionExpression(fn)) return undefined;
if (!isSourceFile(getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
const fnKeyword = Debug.checkDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
const fnKeyword = Debug.assertDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
const { name } = fn;
const body = Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression
const body = Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression
if (isFunctionExpression(fn)) {
if (name && FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) {
// Function expression references itself. To fix we would have to extract it to a const.

View file

@ -8,7 +8,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
const { sourceFile, span } = context;
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, namedTupleMember));

View file

@ -5,7 +5,7 @@ namespace ts.codefix {
Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
],
getCodeActions: context => {
getCodeActions: function getCodeActionsToFixModuleAndTarget(context) {
const compilerOptions = context.program.getCompilerOptions();
const { configFile } = compilerOptions;
if (configFile === undefined) {

View file

@ -85,7 +85,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
const { errorCode, span } = context;
const info = errorCodeFixIdMap[errorCode];

View file

@ -15,7 +15,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
fixIds: [fixId],
getCodeActions: context => {
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
const { sourceFile, program, span } = context;
const checker = program.getTypeChecker();
const info = getInfo(sourceFile, program.getTypeChecker(), span.start);

View file

@ -7,7 +7,7 @@ namespace ts.codefix {
const errorCodes = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
const propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
if (!propertyDeclaration) return;

View file

@ -7,7 +7,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: (context) => {
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span));
if (changes.length > 0) {
return [createCodeFixAction(fixId, changes, Diagnostics.Remove_unnecessary_await, fixId, Diagnostics.Remove_all_unnecessary_uses_of_await)];

View file

@ -36,7 +36,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
getCodeActions: context => {
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
const { program, sourceFile, span: { start }, errorCode } = context;
const info = getInfo(program.getTypeChecker(), sourceFile, start, errorCode);
if (!info) return undefined;

View file

@ -5,7 +5,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
fixIds: [fixId],
getCodeActions: context => {
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
const changes = textChanges.ChangeTracker.with(context, t => {
return splitTypeOnlyImport(t, getImportDeclaration(context.sourceFile, context.span), context);
});

View file

@ -7,7 +7,7 @@ namespace ts.codefix {
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span));
if (changes.length > 0) {
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, Diagnostics.Convert_all_to_bigint_numeric_literals)];

View file

@ -4,7 +4,7 @@ namespace ts.codefix {
const errorCodes = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
registerCodeFix({
errorCodes,
getCodeActions: context => {
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
const { sourceFile, span } = context;
const node = findNodeToFix(sourceFile, span.start);
if (!node) return undefined;

View file

@ -198,17 +198,14 @@ namespace ts.GoToDefinition {
return undefined;
}
const symbol = getSymbol(node, typeChecker);
const symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) return undefined;
const typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
const returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
const fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
// If a function returns 'void' or some other type with no definition, just return the function definition.
const typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
return typeDefinitions.length ? typeDefinitions
: !(symbol.flags & SymbolFlags.Value) && symbol.flags & SymbolFlags.Type ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node)
: undefined;
return fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
}
function definitionFromType(type: Type, checker: TypeChecker, node: Node): readonly DefinitionInfo[] {

View file

@ -326,7 +326,7 @@ namespace ts.projectSystem {
};
function updateFile(path: string, newText: string) {
Debug.assertIsDefined(files.find(f => f.path === path));
Debug.assertDefined(files.find(f => f.path === path));
session.executeCommandSeq<protocol.ApplyChangedToOpenFilesRequest>({
command: protocol.CommandTypes.ApplyChangedToOpenFiles,
arguments: {
@ -339,7 +339,7 @@ namespace ts.projectSystem {
}
function findAllReferences(file: string, line: number, offset: number) {
Debug.assertIsDefined(files.find(f => f.path === file));
Debug.assertDefined(files.find(f => f.path === file));
session.executeCommandSeq<protocol.ReferencesRequest>({
command: protocol.CommandTypes.References,
arguments: {

View file

@ -897,7 +897,7 @@ declare namespace ts {
export interface TypePredicateNode extends TypeNode {
readonly kind: SyntaxKind.TypePredicate;
readonly parent: SignatureDeclaration | JSDocTypeExpression;
readonly assertsModifier?: AssertsKeyword;
readonly assertsModifier?: AssertsToken;
readonly parameterName: Identifier | ThisTypeNode;
readonly type?: TypeNode;
}
@ -968,7 +968,7 @@ declare namespace ts {
}
export interface MappedTypeNode extends TypeNode, Declaration {
readonly kind: SyntaxKind.MappedType;
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken;
readonly typeParameter: TypeParameterDeclaration;
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
@ -1465,7 +1465,7 @@ declare namespace ts {
}
export interface ForOfStatement extends IterationStatement {
readonly kind: SyntaxKind.ForOfStatement;
readonly awaitModifier?: AwaitKeyword;
readonly awaitModifier?: AwaitKeywordToken;
readonly initializer: ForInitializer;
readonly expression: Expression;
}

View file

@ -897,7 +897,7 @@ declare namespace ts {
export interface TypePredicateNode extends TypeNode {
readonly kind: SyntaxKind.TypePredicate;
readonly parent: SignatureDeclaration | JSDocTypeExpression;
readonly assertsModifier?: AssertsKeyword;
readonly assertsModifier?: AssertsToken;
readonly parameterName: Identifier | ThisTypeNode;
readonly type?: TypeNode;
}
@ -968,7 +968,7 @@ declare namespace ts {
}
export interface MappedTypeNode extends TypeNode, Declaration {
readonly kind: SyntaxKind.MappedType;
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken;
readonly typeParameter: TypeParameterDeclaration;
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
@ -1465,7 +1465,7 @@ declare namespace ts {
}
export interface ForOfStatement extends IterationStatement {
readonly kind: SyntaxKind.ForOfStatement;
readonly awaitModifier?: AwaitKeyword;
readonly awaitModifier?: AwaitKeywordToken;
readonly initializer: ForInitializer;
readonly expression: Expression;
}

View file

@ -1,46 +0,0 @@
/a.js(18,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
==== /a.js (1 errors) ====
class A {
/**
* Constructor
*
* @param {object} [foo={}]
*/
constructor(foo = {}) {
const key = "bar";
/**
* @type object
*/
this.foo = foo;
/**
* @type object
*/
const arguments = this.arguments;
~~~~~~~~~
!!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
/**
* @type object
*/
this.bar = arguments.bar;
/**
* @type object
*/
this.baz = arguments[key];
/**
* @type object
*/
this.options = arguments;
}
get arguments() {
return { bar: {} };
}
}

View file

@ -1,44 +0,0 @@
/a.js(16,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
==== /a.js (1 errors) ====
class A {
/**
* @param {object} [foo={}]
*/
m(foo = {}) {
const key = "bar";
/**
* @type object
*/
this.foo = foo;
/**
* @type object
*/
const arguments = this.arguments;
~~~~~~~~~
!!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
/**
* @type object
*/
this.bar = arguments.bar;
/**
* @type object
*/
this.baz = arguments[key];
/**
* @type object
*/
this.options = arguments;
}
get arguments() {
return { bar: {} };
}
}

View file

@ -3,6 +3,6 @@ enum E {
>E : Symbol(E, Decl(enumWithUnicodeEscape1.ts, 0, 0))
'gold \u2730'
>'gold \u2730' : Symbol(E['gold \u2730'], Decl(enumWithUnicodeEscape1.ts, 0, 8))
>'gold \u2730' : Symbol(E['gold u2730'], Decl(enumWithUnicodeEscape1.ts, 0, 8))
}

View file

@ -1,18 +1,12 @@
tests/cases/compiler/export.js(1,13): error TS2451: Cannot redeclare block-scoped variable 'foo'.
tests/cases/compiler/export.js(1,13): error TS8008: Type aliases can only be used in TypeScript files.
tests/cases/compiler/export.js(6,14): error TS2451: Cannot redeclare block-scoped variable 'foo'.
==== tests/cases/compiler/export.js (3 errors) ====
==== tests/cases/compiler/export.js (1 errors) ====
export type foo = 5;
~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'foo'.
~~~
!!! error TS8008: Type aliases can only be used in TypeScript files.
/**
* @typedef {{
* }}
*/
export const foo = 5;
~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'foo'.
export const foo = 5;

View file

@ -1,97 +0,0 @@
tests/cases/conformance/salsa/plainJSBinderErrors.js(1,1): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/salsa/plainJSBinderErrors.js(2,1): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/salsa/plainJSBinderErrors.js(3,7): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
tests/cases/conformance/salsa/plainJSBinderErrors.js(4,7): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(6,11): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here.
tests/cases/conformance/salsa/plainJSBinderErrors.js(9,11): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(12,5): error TS18012: '#constructor' is a reserved word.
tests/cases/conformance/salsa/plainJSBinderErrors.js(15,20): error TS1102: 'delete' cannot be called on an identifier in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(18,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(19,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(22,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'eval'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(23,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(26,27): error TS1121: Octal literals are not allowed in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(27,9): error TS1101: 'with' statements are not allowed in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(33,13): error TS1344: 'A label is not allowed here.
tests/cases/conformance/salsa/plainJSBinderErrors.js(39,7): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode.
tests/cases/conformance/salsa/plainJSBinderErrors.js(40,7): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode.
==== tests/cases/conformance/salsa/plainJSBinderErrors.js (17 errors) ====
export default 12
~~~~~~~~~~~~~~~~~
!!! error TS2528: A module cannot have multiple default exports.
!!! related TS2753 tests/cases/conformance/salsa/plainJSBinderErrors.js:2:1: Another export default is here.
export default 13
~~~~~~~~~~~~~~~~~
!!! error TS2528: A module cannot have multiple default exports.
!!! related TS2752 tests/cases/conformance/salsa/plainJSBinderErrors.js:1:1: The first export default is here.
const await = 1
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
const yield = 2
~~~~~
!!! error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
async function f() {
const await = 3
~~~~~
!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here.
}
function* g() {
const yield = 4
~~~~~
!!! error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
}
class C {
#constructor = 5
~~~~~~~~~~~~
!!! error TS18012: '#constructor' is a reserved word.
deleted() {
function container(f) {
delete f
~
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
}
var g = 6
delete g
~
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
delete container
~~~~~~~~~
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
}
evalArguments() {
const eval = 7
~~~~
!!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'eval'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
const arguments = 8
~~~~~~~~~
!!! error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
}
withOctal() {
const redundant = 010
~~~
!!! error TS1121: Octal literals are not allowed in strict mode.
with (redundant) {
~~~~
!!! error TS1101: 'with' statements are not allowed in strict mode.
return toFixed()
}
}
label() {
for(;;) {
label: var x = 1
~~~~~
!!! error TS1344: 'A label is not allowed here.
break label
}
return x
}
}
const eval = 9
~~~~
!!! error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode.
const arguments = 10
~~~~~~~~~
!!! error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode.

View file

@ -1,84 +0,0 @@
//// [plainJSBinderErrors.js]
export default 12
export default 13
const await = 1
const yield = 2
async function f() {
const await = 3
}
function* g() {
const yield = 4
}
class C {
#constructor = 5
deleted() {
function container(f) {
delete f
}
var g = 6
delete g
delete container
}
evalArguments() {
const eval = 7
const arguments = 8
}
withOctal() {
const redundant = 010
with (redundant) {
return toFixed()
}
}
label() {
for(;;) {
label: var x = 1
break label
}
return x
}
}
const eval = 9
const arguments = 10
//// [plainJSBinderErrors.js]
export default 12;
export default 13;
const await = 1;
const yield = 2;
async function f() {
const await = 3;
}
function* g() {
const yield = 4;
}
class C {
#constructor = 5;
deleted() {
function container(f) {
delete f;
}
var g = 6;
delete g;
delete container;
}
evalArguments() {
const eval = 7;
const arguments = 8;
}
withOctal() {
const redundant = 010;
with (redundant) {
return toFixed();
}
}
label() {
for (;;) {
label: var x = 1;
break label;
}
return x;
}
}
const eval = 9;
const arguments = 10;

View file

@ -1,86 +0,0 @@
=== tests/cases/conformance/salsa/plainJSBinderErrors.js ===
export default 12
export default 13
const await = 1
>await : Symbol(await, Decl(plainJSBinderErrors.js, 2, 5))
const yield = 2
>yield : Symbol(yield, Decl(plainJSBinderErrors.js, 3, 5))
async function f() {
>f : Symbol(f, Decl(plainJSBinderErrors.js, 3, 15))
const await = 3
>await : Symbol(await, Decl(plainJSBinderErrors.js, 5, 9))
}
function* g() {
>g : Symbol(g, Decl(plainJSBinderErrors.js, 6, 1))
const yield = 4
>yield : Symbol(yield, Decl(plainJSBinderErrors.js, 8, 9))
}
class C {
>C : Symbol(C, Decl(plainJSBinderErrors.js, 9, 1))
#constructor = 5
>#constructor : Symbol(C.#constructor, Decl(plainJSBinderErrors.js, 10, 9))
deleted() {
>deleted : Symbol(C.deleted, Decl(plainJSBinderErrors.js, 11, 20))
function container(f) {
>container : Symbol(container, Decl(plainJSBinderErrors.js, 12, 15))
>f : Symbol(f, Decl(plainJSBinderErrors.js, 13, 27))
delete f
>f : Symbol(f, Decl(plainJSBinderErrors.js, 13, 27))
}
var g = 6
>g : Symbol(g, Decl(plainJSBinderErrors.js, 16, 11))
delete g
>g : Symbol(g, Decl(plainJSBinderErrors.js, 16, 11))
delete container
>container : Symbol(container, Decl(plainJSBinderErrors.js, 12, 15))
}
evalArguments() {
>evalArguments : Symbol(C.evalArguments, Decl(plainJSBinderErrors.js, 19, 5))
const eval = 7
>eval : Symbol(eval, Decl(plainJSBinderErrors.js, 21, 13))
const arguments = 8
>arguments : Symbol(arguments, Decl(plainJSBinderErrors.js, 22, 13))
}
withOctal() {
>withOctal : Symbol(C.withOctal, Decl(plainJSBinderErrors.js, 23, 5))
const redundant = 010
>redundant : Symbol(redundant, Decl(plainJSBinderErrors.js, 25, 13))
with (redundant) {
>redundant : Symbol(redundant, Decl(plainJSBinderErrors.js, 25, 13))
return toFixed()
}
}
label() {
>label : Symbol(C.label, Decl(plainJSBinderErrors.js, 29, 5))
for(;;) {
label: var x = 1
>x : Symbol(x, Decl(plainJSBinderErrors.js, 32, 22))
break label
}
return x
>x : Symbol(x, Decl(plainJSBinderErrors.js, 32, 22))
}
}
const eval = 9
>eval : Symbol(eval, Decl(plainJSBinderErrors.js, 38, 5))
const arguments = 10
>arguments : Symbol(arguments, Decl(plainJSBinderErrors.js, 39, 5))

View file

@ -1,105 +0,0 @@
=== tests/cases/conformance/salsa/plainJSBinderErrors.js ===
export default 12
export default 13
const await = 1
>await : 1
>1 : 1
const yield = 2
>yield : 2
>2 : 2
async function f() {
>f : () => Promise<void>
const await = 3
>await : 3
>3 : 3
}
function* g() {
>g : () => Generator<never, void, unknown>
const yield = 4
>yield : 4
>4 : 4
}
class C {
>C : C
#constructor = 5
>#constructor : number
>5 : 5
deleted() {
>deleted : () => void
function container(f) {
>container : (f: any) => void
>f : any
delete f
>delete f : boolean
>f : any
}
var g = 6
>g : number
>6 : 6
delete g
>delete g : boolean
>g : number
delete container
>delete container : boolean
>container : (f: any) => void
}
evalArguments() {
>evalArguments : () => void
const eval = 7
>eval : 7
>7 : 7
const arguments = 8
>arguments : 8
>8 : 8
}
withOctal() {
>withOctal : () => any
const redundant = 010
>redundant : 10
>010 : 10
with (redundant) {
>redundant : 10
return toFixed()
>toFixed() : any
>toFixed : any
}
}
label() {
>label : () => number
for(;;) {
label: var x = 1
>label : any
>x : number
>1 : 1
break label
>label : any
}
return x
>x : number
}
}
const eval = 9
>eval : 9
>9 : 9
const arguments = 10
>arguments : 10
>10 : 10

View file

@ -1,37 +0,0 @@
tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js(1,1): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js(2,1): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js(3,7): error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js(4,7): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js(6,11): error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here.
tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js(9,11): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
==== tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js (6 errors) ====
export default 12
~~~~~~~~~~~~~~~~~
!!! error TS2528: A module cannot have multiple default exports.
!!! related TS2753 tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js:2:1: Another export default is here.
export default 13
~~~~~~~~~~~~~~~~~
!!! error TS2528: A module cannot have multiple default exports.
!!! related TS2752 tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js:1:1: The first export default is here.
const await = 1
~~~~~
!!! error TS1262: Identifier expected. 'await' is a reserved word at the top-level of a module.
const yield = 2
~~~~~
!!! error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
async function f() {
const await = 3
~~~~~
!!! error TS1359: Identifier expected. 'await' is a reserved word that cannot be used here.
}
function* g() {
const yield = 4
~~~~~
!!! error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
}
class C {
#constructor = 1
}

View file

@ -1,30 +0,0 @@
//// [plainJSMultipleDefaultExport.js]
export default 12
export default 13
const await = 1
const yield = 2
async function f() {
const await = 3
}
function* g() {
const yield = 4
}
class C {
#constructor = 1
}
//// [plainJSMultipleDefaultExport.js]
export default 12;
export default 13;
const await = 1;
const yield = 2;
async function f() {
const await = 3;
}
function* g() {
const yield = 4;
}
class C {
#constructor = 1;
}

View file

@ -1,28 +0,0 @@
=== tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js ===
export default 12
export default 13
const await = 1
>await : Symbol(await, Decl(plainJSMultipleDefaultExport.js, 2, 5))
const yield = 2
>yield : Symbol(yield, Decl(plainJSMultipleDefaultExport.js, 3, 5))
async function f() {
>f : Symbol(f, Decl(plainJSMultipleDefaultExport.js, 3, 15))
const await = 3
>await : Symbol(await, Decl(plainJSMultipleDefaultExport.js, 5, 9))
}
function* g() {
>g : Symbol(g, Decl(plainJSMultipleDefaultExport.js, 6, 1))
const yield = 4
>yield : Symbol(yield, Decl(plainJSMultipleDefaultExport.js, 8, 9))
}
class C {
>C : Symbol(C, Decl(plainJSMultipleDefaultExport.js, 9, 1))
#constructor = 1
>#constructor : Symbol(C.#constructor, Decl(plainJSMultipleDefaultExport.js, 10, 9))
}

View file

@ -1,33 +0,0 @@
=== tests/cases/conformance/salsa/plainJSMultipleDefaultExport.js ===
export default 12
export default 13
const await = 1
>await : 1
>1 : 1
const yield = 2
>yield : 2
>2 : 2
async function f() {
>f : () => Promise<void>
const await = 3
>await : 3
>3 : 3
}
function* g() {
>g : () => Generator<never, void, unknown>
const yield = 4
>yield : 4
>4 : 4
}
class C {
>C : C
#constructor = 1
>#constructor : number
>1 : 1
}

View file

@ -1,13 +0,0 @@
tests/cases/conformance/salsa/plainJSRedeclare.js(1,7): error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
tests/cases/conformance/salsa/plainJSRedeclare.js(2,5): error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
==== tests/cases/conformance/salsa/plainJSRedeclare.js (2 errors) ====
const orbitol = 1
~~~~~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
var orbitol = 1 + false
~~~~~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
orbitol.toExponential()

View file

@ -1,10 +0,0 @@
//// [plainJSRedeclare.js]
const orbitol = 1
var orbitol = 1 + false
orbitol.toExponential()
//// [plainJSRedeclare.js]
var orbitol = 1;
var orbitol = 1 + false;
orbitol.toExponential();

View file

@ -1,12 +0,0 @@
=== tests/cases/conformance/salsa/plainJSRedeclare.js ===
const orbitol = 1
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 0, 5))
var orbitol = 1 + false
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 1, 3))
orbitol.toExponential()
>orbitol.toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --))
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 0, 5))
>toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --))

View file

@ -1,17 +0,0 @@
=== tests/cases/conformance/salsa/plainJSRedeclare.js ===
const orbitol = 1
>orbitol : 1
>1 : 1
var orbitol = 1 + false
>orbitol : any
>1 + false : any
>1 : 1
>false : false
orbitol.toExponential()
>orbitol.toExponential() : string
>orbitol.toExponential : (fractionDigits?: number) => string
>orbitol : 1
>toExponential : (fractionDigits?: number) => string

View file

@ -1,16 +0,0 @@
tests/cases/conformance/salsa/plainJSRedeclare.js(1,7): error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
tests/cases/conformance/salsa/plainJSRedeclare.js(2,5): error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
tests/cases/conformance/salsa/plainJSRedeclare.js(2,15): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
==== tests/cases/conformance/salsa/plainJSRedeclare.js (3 errors) ====
const orbitol = 1
~~~~~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
var orbitol = 1 + false
~~~~~~~
!!! error TS2451: Cannot redeclare block-scoped variable 'orbitol'.
~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
orbitol.toExponential()

View file

@ -1,10 +0,0 @@
//// [plainJSRedeclare.js]
const orbitol = 1
var orbitol = 1 + false
orbitol.toExponential()
//// [plainJSRedeclare.js]
var orbitol = 1;
var orbitol = 1 + false;
orbitol.toExponential();

View file

@ -1,12 +0,0 @@
=== tests/cases/conformance/salsa/plainJSRedeclare.js ===
const orbitol = 1
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 0, 5))
var orbitol = 1 + false
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 1, 3))
orbitol.toExponential()
>orbitol.toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --))
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 0, 5))
>toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --))

View file

@ -1,17 +0,0 @@
=== tests/cases/conformance/salsa/plainJSRedeclare.js ===
const orbitol = 1
>orbitol : 1
>1 : 1
var orbitol = 1 + false
>orbitol : any
>1 + false : any
>1 : 1
>false : false
orbitol.toExponential()
>orbitol.toExponential() : string
>orbitol.toExponential : (fractionDigits?: number) => string
>orbitol : 1
>toExponential : (fractionDigits?: number) => string

View file

@ -1,10 +0,0 @@
//// [plainJSRedeclare.js]
const orbitol = 1
var orbitol = 1 + false
orbitol.toExponential()
//// [plainJSRedeclare.js]
var orbitol = 1;
var orbitol = 1 + false;
orbitol.toExponential();

View file

@ -1,12 +0,0 @@
=== tests/cases/conformance/salsa/plainJSRedeclare.js ===
const orbitol = 1
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 0, 5))
var orbitol = 1 + false
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 1, 3))
orbitol.toExponential()
>orbitol.toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --))
>orbitol : Symbol(orbitol, Decl(plainJSRedeclare.js, 0, 5))
>toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --))

View file

@ -1,17 +0,0 @@
=== tests/cases/conformance/salsa/plainJSRedeclare.js ===
const orbitol = 1
>orbitol : 1
>1 : 1
var orbitol = 1 + false
>orbitol : any
>1 + false : any
>1 : 1
>false : false
orbitol.toExponential()
>orbitol.toExponential() : string
>orbitol.toExponential : (fractionDigits?: number) => string
>orbitol : 1
>toExponential : (fractionDigits?: number) => string

View file

@ -1,13 +0,0 @@
tests/cases/conformance/salsa/plainJSReservedStrict.js(2,7): error TS1100: Invalid use of 'eval' in strict mode.
tests/cases/conformance/salsa/plainJSReservedStrict.js(3,7): error TS1100: Invalid use of 'arguments' in strict mode.
==== tests/cases/conformance/salsa/plainJSReservedStrict.js (2 errors) ====
"use strict"
const eval = 1
~~~~
!!! error TS1100: Invalid use of 'eval' in strict mode.
const arguments = 2
~~~~~~~~~
!!! error TS1100: Invalid use of 'arguments' in strict mode.

View file

@ -1,10 +0,0 @@
//// [plainJSReservedStrict.js]
"use strict"
const eval = 1
const arguments = 2
//// [plainJSReservedStrict.js]
"use strict";
const eval = 1;
const arguments = 2;

View file

@ -1,8 +0,0 @@
=== tests/cases/conformance/salsa/plainJSReservedStrict.js ===
"use strict"
const eval = 1
>eval : Symbol(eval, Decl(plainJSReservedStrict.js, 1, 5))
const arguments = 2
>arguments : Symbol(arguments, Decl(plainJSReservedStrict.js, 2, 5))

View file

@ -1,12 +0,0 @@
=== tests/cases/conformance/salsa/plainJSReservedStrict.js ===
"use strict"
>"use strict" : "use strict"
const eval = 1
>eval : 1
>1 : 1
const arguments = 2
>arguments : 2
>2 : 2

View file

@ -69,7 +69,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -135,7 +135,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -201,7 +201,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -411,7 +411,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -549,7 +549,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -687,7 +687,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -791,7 +791,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -857,7 +857,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -923,7 +923,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -1149,7 +1149,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -1295,7 +1295,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -1441,7 +1441,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",

View file

@ -69,7 +69,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -135,7 +135,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -201,7 +201,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -411,7 +411,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -549,7 +549,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -687,7 +687,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -791,7 +791,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -857,7 +857,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -923,7 +923,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -1149,7 +1149,7 @@
},
{
"text": "\"e1\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -1295,7 +1295,7 @@
},
{
"text": "'e2'",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",
@ -1441,7 +1441,7 @@
},
{
"text": "\"e3\"",
"kind": "enumMemberName"
"kind": "stringLiteral"
},
{
"text": "]",

View file

@ -1,134 +0,0 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsEnum4.ts",
"position": 51,
"name": "1"
},
"quickInfo": {
"kind": "enum member",
"kindModifiers": "",
"textSpan": {
"start": 51,
"length": 4
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "enum member",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Foo",
"kind": "enumName"
},
{
"text": "[",
"kind": "punctuation"
},
{
"text": "\"\\t\"",
"kind": "enumMemberName"
},
{
"text": "]",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "9",
"kind": "numericLiteral"
}
],
"documentation": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsEnum4.ts",
"position": 61,
"name": "2"
},
"quickInfo": {
"kind": "enum member",
"kindModifiers": "",
"textSpan": {
"start": 61,
"length": 8
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "enum member",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Foo",
"kind": "enumName"
},
{
"text": "[",
"kind": "punctuation"
},
{
"text": "\"\\u007f\"",
"kind": "enumMemberName"
},
{
"text": "]",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "127",
"kind": "numericLiteral"
}
],
"documentation": []
}
}
]

View file

@ -4,7 +4,7 @@
* @return {number}
*/
function f(s) {
>f : (this: { n: number; }, s: string) => number
>f : (s: string) => number
>s : string
return this.n + s.length
@ -18,11 +18,11 @@ function f(s) {
}
const o = {
>o : { f: (this: { n: number; }, s: string) => number; n: number; }
>{ f, n: 1} : { f: (this: { n: number; }, s: string) => number; n: number; }
>o : { f: (s: string) => number; n: number; }
>{ f, n: 1} : { f: (s: string) => number; n: number; }
f,
>f : (this: { n: number; }, s: string) => number
>f : (s: string) => number
n: 1
>n : number
@ -30,8 +30,8 @@ const o = {
}
o.f('hi')
>o.f('hi') : number
>o.f : (this: { n: number; }, s: string) => number
>o : { f: (this: { n: number; }, s: string) => number; n: number; }
>f : (this: { n: number; }, s: string) => number
>o.f : (s: string) => number
>o : { f: (s: string) => number; n: number; }
>f : (s: string) => number
>'hi' : "hi"

View file

@ -1,15 +0,0 @@
//// [a.js]
/** @this {string} */
export function f1() {}
/** @this */
export function f2() {}
//// [a.d.ts]
/** @this {string} */
export function f1(this: string): void;
/** @this */
export function f2(this: any): void;

View file

@ -1,9 +0,0 @@
=== tests/cases/conformance/jsdoc/a.js ===
/** @this {string} */
export function f1() {}
>f1 : Symbol(f1, Decl(a.js, 0, 0))
/** @this */
export function f2() {}
>f2 : Symbol(f2, Decl(a.js, 1, 23))

View file

@ -1,9 +0,0 @@
=== tests/cases/conformance/jsdoc/a.js ===
/** @this {string} */
export function f1() {}
>f1 : (this: string) => void
/** @this */
export function f2() {}
>f2 : (this: any) => void

View file

@ -1,11 +0,0 @@
// @target: esnext
// @allowJs: true
// @declaration: true
// @emitDeclarationOnly: true
// @filename: a.js
/** @this {string} */
export function f1() {}
/** @this */
export function f2() {}

View file

@ -1,44 +0,0 @@
// @outdir: out/
// @target: esnext
// @allowJS: true
// @filename: plainJSBinderErrors.js
export default 12
export default 13
const await = 1
const yield = 2
async function f() {
const await = 3
}
function* g() {
const yield = 4
}
class C {
#constructor = 5
deleted() {
function container(f) {
delete f
}
var g = 6
delete g
delete container
}
evalArguments() {
const eval = 7
const arguments = 8
}
withOctal() {
const redundant = 010
with (redundant) {
return toFixed()
}
}
label() {
for(;;) {
label: var x = 1
break label
}
return x
}
}
const eval = 9
const arguments = 10

View file

@ -1,6 +0,0 @@
// @outdir: out/
// @allowJS: true
// @filename: plainJSRedeclare.js
const orbitol = 1
var orbitol = 1 + false
orbitol.toExponential()

View file

@ -1,7 +0,0 @@
// @outdir: out/
// @allowJS: true
// @checkJS: true
// @filename: plainJSRedeclare.js
const orbitol = 1
var orbitol = 1 + false
orbitol.toExponential()

View file

@ -1,7 +0,0 @@
// @outdir: out/
// @allowJS: true
// @checkJS: false
// @filename: plainJSRedeclare.js
const orbitol = 1
var orbitol = 1 + false
orbitol.toExponential()

View file

@ -1,7 +0,0 @@
// @outdir: out/
// @target: esnext
// @allowJS: true
// @filename: plainJSReservedStrict.js
"use strict"
const eval = 1
const arguments = 2

View file

@ -1,6 +0,0 @@
/// <reference path='fourslash.ts' />
////type /*definition*/T = string;
////const x: /*reference*/T;
verify.goToType("reference", "definition");

View file

@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @Filename: foo.ts
////export type /*def0*/T = string;
////export const /*def1*/T = "";
// @Filename: bar.ts
////import { T } from "./foo";
////let x: [|/*reference*/T|];
verify.goToType("reference", []);
verify.goToDefinition("reference", ["def0", "def1"]);

View file

@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @Filename: foo.ts
////let Foo: /*definition*/unresolved;
////type Foo = { x: string };
/////*reference*/Foo;
verify.goToType("reference", []);

View file

@ -1,10 +0,0 @@
/// <reference path='fourslash.ts'/>
////const enum Foo {
//// "\t" = 9,
//// "\u007f" = 127,
////}
////Foo[/*1*/"\t"]
////Foo[/*2*/"\u007f"]
verify.baselineQuickInfo();

View file

@ -1,68 +0,0 @@
/// <reference path="../fourslash.ts" />
// @Filename: /tsconfig.json
//// { "compilerOptions": { "module": "commonjs" } }
// @Filename: /package.json
//// { "dependencies": { "mylib": "file:packages/mylib" } }
// @Filename: /packages/mylib/package.json
//// { "name": "mylib", "version": "1.0.0", "main": "index.js", "types": "index" }
// @Filename: /packages/mylib/index.ts
//// export * from "./mySubDir";
// @Filename: /packages/mylib/mySubDir/index.ts
//// export * from "./myClass";
//// export * from "./myClass2";
// @Filename: /packages/mylib/mySubDir/myClass.ts
//// export class MyClass {}
// @Filename: /packages/mylib/mySubDir/myClass2.ts
//// export class MyClass2 {}
// @link: /packages/mylib -> /node_modules/mylib
// @Filename: /src/index.ts
////
//// const a = new MyClass/*1*/();
//// const b = new MyClass2/*2*/();
goTo.marker("1");
format.setOption("newLineCharacter", "\n");
verify.completions({
marker: "1",
includes: [{
name: "MyClass",
source: "mylib",
sourceDisplay: "mylib",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true,
allowIncompleteCompletions: true,
}
});
verify.applyCodeActionFromCompletion("1", {
name: "MyClass",
source: "mylib",
description: `Import 'MyClass' from module "mylib"`,
data: {
exportName: "MyClass",
fileName: "/packages/mylib/index.ts",
},
preferences: {
includeCompletionsForModuleExports: true,
includeCompletionsWithInsertText: true,
allowIncompleteCompletions: true,
},
newFileContent: `import { MyClass } from "mylib";
const a = new MyClass();
const b = new MyClass2();`,
});

View file

@ -1,20 +0,0 @@
/// <reference path="../fourslash.ts" />
// @Filename: /tsconfig.json
//// { "compilerOptions": { "module": "nodenext" } }
// @Filename: /package.json
//// { "name": "foo", "type": "module", "exports": { ".": "./main.js" } }
// @Filename: /main.ts
//// export {};
// @Filename: /index.ts
//// import {} from "foo";
goTo.file("/index.ts");
verify.noErrors();
edit.paste(`\n"${"a".repeat(256)}";`);
verify.noErrors();