Compare commits
28 commits
Author | SHA1 | Date | |
---|---|---|---|
90600e1b17 | |||
a90389a22d | |||
0163a624b7 | |||
9766757ee6 | |||
868c275fdf | |||
6143237376 | |||
1ade73df2b | |||
de4ba0f208 | |||
a75f26e68b | |||
f11f14baba | |||
009dd487a6 | |||
0bf97296d6 | |||
fcdbc932bf | |||
7615547d42 | |||
719ab0b477 | |||
fe3e117cb2 | |||
1298f498f4 | |||
7b86a65f22 | |||
b12d5c5dc5 | |||
416571ca90 | |||
e5a6ae397d | |||
4a065f524c | |||
e040e8516f | |||
a05d851dc3 | |||
9713cc1a75 | |||
3ef3cdddb3 | |||
0a628ff0c9 | |||
2d4b243195 |
18
package-lock.json
generated
18
package-lock.json
generated
|
@ -676,9 +676,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "16.11.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz",
|
||||
"integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==",
|
||||
"version": "16.11.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.10.tgz",
|
||||
"integrity": "sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node-fetch": {
|
||||
|
@ -6997,9 +6997,9 @@
|
|||
}
|
||||
},
|
||||
"source-map-support": {
|
||||
"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==",
|
||||
"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==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
|
@ -8423,9 +8423,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"camelcase": {
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz",
|
||||
"integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==",
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.1.tgz",
|
||||
"integrity": "sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==",
|
||||
"dev": true
|
||||
},
|
||||
"decamelize": {
|
||||
|
|
|
@ -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));
|
||||
if (signature.thisParameter) {
|
||||
const thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
|
||||
const thisParameter = tryGetThisParameterDeclaration(signature, context);
|
||||
if (thisParameter) {
|
||||
parameters.unshift(thisParameter);
|
||||
}
|
||||
|
||||
|
@ -5713,6 +5713,25 @@ 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
|
||||
|
@ -6204,12 +6223,8 @@ namespace ts {
|
|||
firstChar = symbolName.charCodeAt(0);
|
||||
}
|
||||
let expression: Expression | undefined;
|
||||
if (isSingleOrDoubleQuote(firstChar)) {
|
||||
expression = factory.createStringLiteral(
|
||||
symbolName
|
||||
.substring(1, symbolName.length - 1)
|
||||
.replace(/\\./g, s => s.substring(1)),
|
||||
firstChar === CharacterCodes.singleQuote);
|
||||
if (isSingleOrDoubleQuote(firstChar) && !(symbol.flags & SymbolFlags.EnumMember)) {
|
||||
expression = factory.createStringLiteral(stripQuotes(symbolName).replace(/\\./g, s => s.substring(1)), firstChar === CharacterCodes.singleQuote);
|
||||
}
|
||||
else if (("" + +symbolName) === symbolName) {
|
||||
expression = factory.createNumericLiteral(+symbolName);
|
||||
|
@ -16013,7 +16028,7 @@ namespace ts {
|
|||
const declarations = concatenate(leftProp.declarations, rightProp.declarations);
|
||||
const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional);
|
||||
const result = createSymbol(flags, leftProp.escapedName);
|
||||
result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)]);
|
||||
result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], UnionReduction.Subtype);
|
||||
result.leftSpread = leftProp;
|
||||
result.rightSpread = rightProp;
|
||||
result.declarations = declarations;
|
||||
|
@ -40407,9 +40422,8 @@ namespace ts {
|
|||
const enclosingFile = getSourceFileOfNode(node);
|
||||
const links = getNodeLinks(enclosingFile);
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
links.deferredNodes = links.deferredNodes || new Map();
|
||||
const id = getNodeId(node);
|
||||
links.deferredNodes.set(id, node);
|
||||
links.deferredNodes ||= new Set();
|
||||
links.deferredNodes.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41589,7 +41603,7 @@ namespace ts {
|
|||
if (!symbol) {
|
||||
return false;
|
||||
}
|
||||
const target = resolveAlias(symbol);
|
||||
const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
|
||||
if (target === unknownSymbol) {
|
||||
return true;
|
||||
}
|
||||
|
@ -43062,8 +43076,7 @@ namespace ts {
|
|||
|
||||
// Modifiers are never allowed on properties except for 'async' on a method declaration
|
||||
if (prop.modifiers) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
for (const mod of prop.modifiers!) { // TODO: GH#19955
|
||||
for (const mod of prop.modifiers) {
|
||||
if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) {
|
||||
grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod));
|
||||
}
|
||||
|
|
|
@ -23,34 +23,6 @@ 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;
|
||||
}
|
||||
|
|
|
@ -171,12 +171,6 @@ 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) {
|
||||
|
@ -190,12 +184,6 @@ 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);
|
||||
|
|
|
@ -1604,6 +1604,7 @@ namespace ts {
|
|||
return emitJSDocSignature(node as JSDocSignature);
|
||||
case SyntaxKind.JSDocTag:
|
||||
case SyntaxKind.JSDocClassTag:
|
||||
case SyntaxKind.JSDocOverrideTag:
|
||||
return emitJSDocSimpleTag(node as JSDocTag);
|
||||
case SyntaxKind.JSDocAugmentsTag:
|
||||
case SyntaxKind.JSDocImplementsTag:
|
||||
|
@ -1616,7 +1617,6 @@ namespace ts {
|
|||
case SyntaxKind.JSDocPrivateTag:
|
||||
case SyntaxKind.JSDocProtectedTag:
|
||||
case SyntaxKind.JSDocReadonlyTag:
|
||||
case SyntaxKind.JSDocOverrideTag:
|
||||
return;
|
||||
case SyntaxKind.JSDocCallbackTag:
|
||||
return emitJSDocCallbackTag(node as JSDocCallbackTag);
|
||||
|
|
|
@ -6387,7 +6387,7 @@ namespace ts {
|
|||
sourceMapText = mapTextOrStripInternal as string;
|
||||
}
|
||||
const node = oldFileOfCurrentEmit ?
|
||||
parseOldFileOfCurrentEmit(Debug.assertDefined(bundleFileInfo)) :
|
||||
parseOldFileOfCurrentEmit(Debug.checkDefined(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.assertDefined(javascriptMapTextOrDeclarationPath);
|
||||
node.declarationPath = Debug.checkDefined(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.assertDefined(javascriptMapTextOrDeclarationPath)); } },
|
||||
declarationText: { get() { return definedTextGetter(Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
|
||||
declarationMapText: { get() { return textGetter(declarationMapPath); } }, // TODO:: if there is inline sourceMap in dtsFile, use that
|
||||
buildInfo: { get() { return getAndCacheBuildInfo(() => textGetter(declarationMapTextOrBuildInfoPath)); } }
|
||||
});
|
||||
|
|
|
@ -818,6 +818,25 @@ 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
|
||||
*/
|
||||
|
@ -1577,6 +1596,7 @@ 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) {
|
||||
|
@ -2004,15 +2024,24 @@ namespace ts {
|
|||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
|
||||
const isCheckJs = isCheckJsEnabledForFile(sourceFile, options);
|
||||
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 isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
|
||||
// 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 || 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);
|
||||
// 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
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3160,7 +3189,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function verifyCompilerOptions() {
|
||||
const isNightly = stringContains(version, "-dev");
|
||||
const isNightly = stringContains(version, "-dev") || stringContains(version, "-insiders");
|
||||
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");
|
||||
|
|
|
@ -619,7 +619,7 @@ namespace ts {
|
|||
) {
|
||||
if (resolution.refCount) {
|
||||
resolution.refCount++;
|
||||
Debug.assertDefined(resolution.files);
|
||||
Debug.assertIsDefined(resolution.files);
|
||||
}
|
||||
else {
|
||||
resolution.refCount = 1;
|
||||
|
@ -696,7 +696,7 @@ namespace ts {
|
|||
filePath: Path,
|
||||
getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>,
|
||||
) {
|
||||
unorderedRemoveItem(Debug.assertDefined(resolution.files), filePath);
|
||||
unorderedRemoveItem(Debug.checkDefined(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.assertDefined(resolution.files)) {
|
||||
for (const containingFilePath of Debug.checkDefined(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);
|
||||
|
|
|
@ -1625,7 +1625,6 @@ namespace ts {
|
|||
sysLog(`sysLog:: ${fileOrDirectory}:: Defaulting to fsWatchFile`);
|
||||
return watchPresentFileSystemEntryWithFsWatchFile();
|
||||
}
|
||||
|
||||
try {
|
||||
const presentWatcher = _fs.watch(
|
||||
fileOrDirectory,
|
||||
|
@ -1804,7 +1803,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function readDirectory(path: string, extensions?: readonly string[], excludes?: readonly string[], includes?: readonly string[], depth?: number): string[] {
|
||||
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath, directoryExists);
|
||||
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
|
||||
}
|
||||
|
||||
function fileSystemEntryExists(path: string, entryKind: FileSystemEntryKind): boolean {
|
||||
|
|
|
@ -282,7 +282,7 @@ namespace ts {
|
|||
function visitYieldExpression(node: YieldExpression) {
|
||||
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
|
||||
if (node.asteriskToken) {
|
||||
const expression = visitNode(Debug.assertDefined(node.expression), visitor, isExpression);
|
||||
const expression = visitNode(Debug.checkDefined(node.expression), visitor, isExpression);
|
||||
|
||||
return setOriginalNode(
|
||||
setTextRange(
|
||||
|
|
|
@ -48,11 +48,11 @@ namespace ts {
|
|||
return existing.name;
|
||||
}
|
||||
if (!currentFileState.utilizedImplicitRuntimeImports) {
|
||||
currentFileState.utilizedImplicitRuntimeImports = createMap();
|
||||
currentFileState.utilizedImplicitRuntimeImports = new Map();
|
||||
}
|
||||
let specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
|
||||
if (!specifierSourceImports) {
|
||||
specifierSourceImports = createMap();
|
||||
specifierSourceImports = new Map();
|
||||
currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
|
||||
}
|
||||
const generatedName = factory.createUniqueName(`_${name}`, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.AllowNameSubstitution);
|
||||
|
|
|
@ -1609,7 +1609,7 @@ namespace ts {
|
|||
export interface TypePredicateNode extends TypeNode {
|
||||
readonly kind: SyntaxKind.TypePredicate;
|
||||
readonly parent: SignatureDeclaration | JSDocTypeExpression;
|
||||
readonly assertsModifier?: AssertsToken;
|
||||
readonly assertsModifier?: AssertsKeyword;
|
||||
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?: ReadonlyToken | PlusToken | MinusToken;
|
||||
readonly readonlyToken?: ReadonlyKeyword | 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?: AwaitKeywordToken;
|
||||
readonly awaitModifier?: AwaitKeyword;
|
||||
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?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred
|
||||
deferredNodes?: Set<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
|
||||
|
|
|
@ -20,21 +20,6 @@ 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) {
|
||||
|
@ -6629,7 +6614,7 @@ namespace ts {
|
|||
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
|
||||
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
|
||||
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
|
||||
basePaths: getBasePaths(absolutePath, includes, useCaseSensitiveFileNames)
|
||||
basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6638,7 +6623,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
/** @param path directory of the tsconfig.json */
|
||||
export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[] {
|
||||
export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[] {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
|
||||
|
@ -6653,22 +6638,20 @@ namespace ts {
|
|||
const results: string[][] = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]];
|
||||
const visited = new Map<string, true>();
|
||||
const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
for (const absoluteBasePath of patterns.basePaths) {
|
||||
if (directoryExists(absoluteBasePath)) {
|
||||
visitDirectory(absoluteBasePath, depth);
|
||||
}
|
||||
for (const basePath of patterns.basePaths) {
|
||||
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
|
||||
}
|
||||
|
||||
return flatten(results);
|
||||
|
||||
function visitDirectory(absolutePath: string, depth: number | undefined) {
|
||||
function visitDirectory(path: string, absolutePath: string, depth: number | undefined) {
|
||||
const canonicalPath = toCanonical(realpath(absolutePath));
|
||||
if (visited.has(canonicalPath)) return;
|
||||
visited.set(canonicalPath, true);
|
||||
const { files, directories } = getFileSystemEntries(absolutePath);
|
||||
const { files, directories } = getFileSystemEntries(path);
|
||||
|
||||
for (const current of sort<string>(files, compareStringsCaseSensitive)) {
|
||||
const name = combinePaths(absolutePath, current);
|
||||
const name = combinePaths(path, current);
|
||||
const absoluteName = combinePaths(absolutePath, current);
|
||||
if (extensions && !fileExtensionIsOneOf(name, extensions)) continue;
|
||||
if (excludeRegex && excludeRegex.test(absoluteName)) continue;
|
||||
|
@ -6691,10 +6674,11 @@ namespace ts {
|
|||
}
|
||||
|
||||
for (const current of sort<string>(directories, compareStringsCaseSensitive)) {
|
||||
const name = combinePaths(path, current);
|
||||
const absoluteName = combinePaths(absolutePath, current);
|
||||
if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
|
||||
(!excludeRegex || !excludeRegex.test(absoluteName))) {
|
||||
visitDirectory(absoluteName, depth);
|
||||
visitDirectory(name, absoluteName, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6702,11 +6686,10 @@ namespace ts {
|
|||
|
||||
/**
|
||||
* Computes the unique non-wildcard base paths amongst the provided include patterns.
|
||||
* @returns Absolute directory paths
|
||||
*/
|
||||
function getBasePaths(absoluteTsconfigPath: string, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean): string[] {
|
||||
function getBasePaths(path: string, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean): string[] {
|
||||
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
|
||||
const basePaths: string[] = [absoluteTsconfigPath];
|
||||
const basePaths: string[] = [path];
|
||||
|
||||
if (includes) {
|
||||
// Storage for literal base paths amongst the include patterns.
|
||||
|
@ -6714,9 +6697,9 @@ namespace ts {
|
|||
for (const include of includes) {
|
||||
// We also need to check the relative paths by converting them to absolute and normalizing
|
||||
// in case they escape the base path (e.g "..\somedirectory")
|
||||
const absoluteIncludePath: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(absoluteTsconfigPath, include));
|
||||
const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
|
||||
// Append the literal and canonical candidate base paths.
|
||||
includeBasePaths.push(getIncludeBasePath(absoluteIncludePath));
|
||||
includeBasePaths.push(getIncludeBasePath(absolute));
|
||||
}
|
||||
|
||||
// Sort the offsets array using either the literal or canonical path representations.
|
||||
|
@ -6725,7 +6708,7 @@ namespace ts {
|
|||
// Iterate over each include base path and include unique base paths that are not a
|
||||
// subpath of an existing base path
|
||||
for (const includeBasePath of includeBasePaths) {
|
||||
if (every(basePaths, basePath => !containsPath(basePath, includeBasePath, absoluteTsconfigPath, !useCaseSensitiveFileNames))) {
|
||||
if (every(basePaths, basePath => !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames))) {
|
||||
basePaths.push(includeBasePath);
|
||||
}
|
||||
}
|
||||
|
@ -6996,18 +6979,6 @@ 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 };
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ namespace ts {
|
|||
const rootResult = tryReadDirectory(rootDir, rootDirPath);
|
||||
let rootSymLinkResult: FileSystemEntries | undefined;
|
||||
if (rootResult !== undefined) {
|
||||
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath, directoryExists);
|
||||
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
|
||||
}
|
||||
return host.readDirectory!(rootDir, extensions, excludes, includes, depth);
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace fakes {
|
|||
}
|
||||
|
||||
public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
|
||||
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path), path => this.directoryExists(path));
|
||||
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path));
|
||||
}
|
||||
|
||||
public getAccessibleFileSystemEntries(path: string): ts.FileSystemEntries {
|
||||
|
|
|
@ -637,7 +637,8 @@ namespace FourSlash {
|
|||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!ts.isAnySupportedFileExtension(fileName)
|
||||
|| Harness.getConfigNameFromFileName(fileName)
|
||||
|| !ts.getAllowJSCompilerOption(this.getProgram().getCompilerOptions()) && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))
|
||||
// Can't get a Program in Server tests
|
||||
|| this.testType !== FourSlashTestType.Server && !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) {
|
||||
|
|
|
@ -922,7 +922,7 @@ interface Array<T> { length: number; [n: number]: T; }`
|
|||
});
|
||||
}
|
||||
return { directories, files };
|
||||
}, path => this.realpath(path), path => this.directoryExists(path));
|
||||
}, path => this.realpath(path));
|
||||
}
|
||||
|
||||
createHash(s: string): string {
|
||||
|
|
4
src/lib/es2020.intl.d.ts
vendored
4
src/lib/es2020.intl.d.ts
vendored
|
@ -200,7 +200,7 @@ declare namespace Intl {
|
|||
interface NumberFormatOptions {
|
||||
compactDisplay?: "short" | "long" | undefined;
|
||||
notation?: "standard" | "scientific" | "engineering" | "compact" | undefined;
|
||||
signDisplay?: "auto" | "never" | "always" | undefined;
|
||||
signDisplay?: "auto" | "never" | "always" | "exceptZero" | undefined;
|
||||
unit?: string | undefined;
|
||||
unitDisplay?: "short" | "long" | "narrow" | undefined;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ declare namespace Intl {
|
|||
interface ResolvedNumberFormatOptions {
|
||||
compactDisplay?: "short" | "long";
|
||||
notation?: "standard" | "scientific" | "engineering" | "compact";
|
||||
signDisplay?: "auto" | "never" | "always";
|
||||
signDisplay?: "auto" | "never" | "always" | "exceptZero";
|
||||
unit?: string;
|
||||
unitDisplay?: "short" | "long" | "narrow";
|
||||
}
|
||||
|
|
4
src/lib/es2022.array.d.ts
vendored
4
src/lib/es2022.array.d.ts
vendored
|
@ -91,7 +91,7 @@ interface BigInt64Array {
|
|||
* Returns the item located at the specified index.
|
||||
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
|
||||
*/
|
||||
at(index: number): number | undefined;
|
||||
at(index: number): bigint | undefined;
|
||||
}
|
||||
|
||||
interface BigUint64Array {
|
||||
|
@ -99,5 +99,5 @@ interface BigUint64Array {
|
|||
* Returns the item located at the specified index.
|
||||
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
|
||||
*/
|
||||
at(index: number): number | undefined;
|
||||
at(index: number): bigint | undefined;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2112,7 +2112,7 @@ namespace ts.server {
|
|||
private getFullNavigateToItems(args: protocol.NavtoRequestArgs): CombineOutputResult<NavigateToItem> {
|
||||
const { currentFileOnly, searchValue, maxResultCount, projectFileName } = args;
|
||||
if (currentFileOnly) {
|
||||
Debug.assertDefined(args.file);
|
||||
Debug.assertIsDefined(args.file);
|
||||
const { file, project } = this.getFileAndProject(args as protocol.FileRequestArgs);
|
||||
return [{ project, result: project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file) }];
|
||||
}
|
||||
|
|
|
@ -408,9 +408,7 @@ namespace ts.codefix {
|
|||
const importSpecifiers = mapAllOrFail(name.elements, e =>
|
||||
e.dotDotDotToken || e.initializer || e.propertyName && !isIdentifier(e.propertyName) || !isIdentifier(e.name)
|
||||
? undefined
|
||||
// (TODO: GH#18217)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
: makeImportSpecifier(e.propertyName && (e.propertyName as Identifier).text, e.name.text));
|
||||
: makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text));
|
||||
if (importSpecifiers) {
|
||||
return convertedImports([makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]);
|
||||
}
|
||||
|
|
|
@ -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.assertDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
|
||||
const fnKeyword = Debug.checkDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
|
||||
const { name } = fn;
|
||||
const body = Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression
|
||||
const body = Debug.checkDefined(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.
|
||||
|
|
|
@ -17,37 +17,81 @@ namespace ts.codefix {
|
|||
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
|
||||
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
|
||||
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code,
|
||||
Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code
|
||||
Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code,
|
||||
Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code,
|
||||
Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code,
|
||||
Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code,
|
||||
Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code,
|
||||
];
|
||||
|
||||
const errorCodeFixIdMap: Record<number, [DiagnosticMessage, string | undefined, DiagnosticMessage | undefined]> = {
|
||||
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code]: [
|
||||
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Add_all_missing_override_modifiers,
|
||||
],
|
||||
[Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code]: [
|
||||
Diagnostics.Remove_override_modifier, fixRemoveOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
|
||||
],
|
||||
[Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code]: [
|
||||
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Add_all_missing_override_modifiers,
|
||||
],
|
||||
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code]: [
|
||||
Diagnostics.Add_override_modifier, fixAddOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
|
||||
],
|
||||
[Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code]: [
|
||||
Diagnostics.Remove_override_modifier, fixRemoveOverrideId, Diagnostics.Remove_all_unnecessary_override_modifiers
|
||||
]
|
||||
interface ErrorCodeFixInfo {
|
||||
descriptions: DiagnosticMessage;
|
||||
fixId?: string | undefined;
|
||||
fixAllDescriptions?: DiagnosticMessage | undefined;
|
||||
}
|
||||
|
||||
const errorCodeFixIdMap: Record<number, ErrorCodeFixInfo> = {
|
||||
// case #1:
|
||||
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code]: {
|
||||
descriptions: Diagnostics.Add_override_modifier,
|
||||
fixId: fixAddOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers,
|
||||
},
|
||||
[Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code]: {
|
||||
descriptions: Diagnostics.Add_override_modifier,
|
||||
fixId: fixAddOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers
|
||||
},
|
||||
// case #2:
|
||||
[Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code]: {
|
||||
descriptions: Diagnostics.Remove_override_modifier,
|
||||
fixId: fixRemoveOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
|
||||
},
|
||||
[Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code]: {
|
||||
descriptions: Diagnostics.Remove_override_modifier,
|
||||
fixId: fixRemoveOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Remove_override_modifier
|
||||
},
|
||||
// case #3:
|
||||
[Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code]: {
|
||||
descriptions: Diagnostics.Add_override_modifier,
|
||||
fixId: fixAddOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers,
|
||||
},
|
||||
[Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code]: {
|
||||
descriptions: Diagnostics.Add_override_modifier,
|
||||
fixId: fixAddOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Add_all_missing_override_modifiers,
|
||||
},
|
||||
// case #4:
|
||||
[Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code]: {
|
||||
descriptions: Diagnostics.Add_override_modifier,
|
||||
fixId: fixAddOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
|
||||
},
|
||||
// case #5:
|
||||
[Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code]: {
|
||||
descriptions: Diagnostics.Remove_override_modifier,
|
||||
fixId: fixRemoveOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
|
||||
},
|
||||
[Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code]: {
|
||||
descriptions: Diagnostics.Remove_override_modifier,
|
||||
fixId: fixRemoveOverrideId,
|
||||
fixAllDescriptions: Diagnostics.Remove_all_unnecessary_override_modifiers,
|
||||
}
|
||||
};
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
getCodeActions: context => {
|
||||
const { errorCode, span, sourceFile } = context;
|
||||
const { errorCode, span } = context;
|
||||
|
||||
const info = errorCodeFixIdMap[errorCode];
|
||||
if (!info) return emptyArray;
|
||||
|
||||
const [ descriptions, fixId, fixAllDescriptions ] = info;
|
||||
if (isSourceFileJS(sourceFile)) return emptyArray;
|
||||
const { descriptions, fixId, fixAllDescriptions } = info;
|
||||
const changes = textChanges.ChangeTracker.with(context, changes => dispatchChanges(changes, context, errorCode, span.start));
|
||||
|
||||
return [
|
||||
|
@ -57,9 +101,9 @@ namespace ts.codefix {
|
|||
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
||||
getAllCodeActions: context =>
|
||||
codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const { code, start, file } = diag;
|
||||
const { code, start } = diag;
|
||||
const info = errorCodeFixIdMap[code];
|
||||
if (!info || info[1] !== context.fixId || isSourceFileJS(file)) {
|
||||
if (!info || info.fixId !== context.fixId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -74,11 +118,15 @@ namespace ts.codefix {
|
|||
pos: number) {
|
||||
switch (errorCode) {
|
||||
case Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code:
|
||||
case Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code:
|
||||
case Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code:
|
||||
case Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code:
|
||||
case Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code:
|
||||
return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos);
|
||||
case Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code:
|
||||
case Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code:
|
||||
case Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code:
|
||||
case Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code:
|
||||
return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos);
|
||||
default:
|
||||
Debug.fail("Unexpected error code: " + errorCode);
|
||||
|
@ -87,6 +135,10 @@ namespace ts.codefix {
|
|||
|
||||
function doAddOverrideModifierChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
|
||||
const classElement = findContainerClassElementLike(sourceFile, pos);
|
||||
if (isSourceFileJS(sourceFile)) {
|
||||
changeTracker.addJSDocTags(sourceFile, classElement, [factory.createJSDocOverrideTag(factory.createIdentifier("override"))]);
|
||||
return;
|
||||
}
|
||||
const modifiers = classElement.modifiers || emptyArray;
|
||||
const staticModifier = find(modifiers, isStaticModifier);
|
||||
const abstractModifier = find(modifiers, isAbstractModifier);
|
||||
|
@ -101,6 +153,10 @@ namespace ts.codefix {
|
|||
|
||||
function doRemoveOverrideModifierChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
|
||||
const classElement = findContainerClassElementLike(sourceFile, pos);
|
||||
if (isSourceFileJS(sourceFile)) {
|
||||
changeTracker.filterJSDocTags(sourceFile, classElement, not(isJSDocOverrideTag));
|
||||
return;
|
||||
}
|
||||
const overrideModifier = classElement.modifiers && find(classElement.modifiers, modifier => modifier.kind === SyntaxKind.OverrideKeyword);
|
||||
Debug.assertIsDefined(overrideModifier);
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace ts.codefix {
|
|||
if (typeNode) {
|
||||
// Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags
|
||||
const typeTag = factory.createJSDocTypeTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined);
|
||||
addJSDocTags(changes, sourceFile, cast(parent.parent.parent, isExpressionStatement), [typeTag]);
|
||||
changes.addJSDocTags(sourceFile, cast(parent.parent.parent, isExpressionStatement), [typeTag]);
|
||||
}
|
||||
importAdder.writeFixes(changes);
|
||||
return parent;
|
||||
|
@ -271,7 +271,7 @@ namespace ts.codefix {
|
|||
}
|
||||
|
||||
function annotateJSDocThis(changes: textChanges.ChangeTracker, sourceFile: SourceFile, containingFunction: SignatureDeclaration, typeNode: TypeNode) {
|
||||
addJSDocTags(changes, sourceFile, containingFunction, [
|
||||
changes.addJSDocTags(sourceFile, containingFunction, [
|
||||
factory.createJSDocThisTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode)),
|
||||
]);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ namespace ts.codefix {
|
|||
}
|
||||
const typeExpression = factory.createJSDocTypeExpression(typeNode);
|
||||
const typeTag = isGetAccessorDeclaration(declaration) ? factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined);
|
||||
addJSDocTags(changes, sourceFile, parent, [typeTag]);
|
||||
changes.addJSDocTags(sourceFile, parent, [typeTag]);
|
||||
}
|
||||
else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, getEmitScriptTarget(program.getCompilerOptions()))) {
|
||||
changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode);
|
||||
|
@ -378,46 +378,7 @@ namespace ts.codefix {
|
|||
else {
|
||||
const paramTags = map(inferences, ({ name, typeNode, isOptional }) =>
|
||||
factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined));
|
||||
addJSDocTags(changes, sourceFile, signature, paramTags);
|
||||
}
|
||||
}
|
||||
|
||||
export function addJSDocTags(changes: textChanges.ChangeTracker, sourceFile: SourceFile, parent: HasJSDoc, newTags: readonly JSDocTag[]): void {
|
||||
const comments = flatMap(parent.jsDoc, j => typeof j.comment === "string" ? factory.createJSDocText(j.comment) : j.comment) as JSDocComment[];
|
||||
const oldTags = flatMapToMutable(parent.jsDoc, j => j.tags);
|
||||
const unmergedNewTags = newTags.filter(newTag => !oldTags || !oldTags.some((tag, i) => {
|
||||
const merged = tryMergeJsdocTags(tag, newTag);
|
||||
if (merged) oldTags[i] = merged;
|
||||
return !!merged;
|
||||
}));
|
||||
const tag = factory.createJSDocComment(factory.createNodeArray(intersperse(comments, factory.createJSDocText("\n"))), factory.createNodeArray([...(oldTags || emptyArray), ...unmergedNewTags]));
|
||||
const jsDocNode = parent.kind === SyntaxKind.ArrowFunction ? getJsDocNodeForArrowFunction(parent) : parent;
|
||||
jsDocNode.jsDoc = parent.jsDoc;
|
||||
jsDocNode.jsDocCache = parent.jsDocCache;
|
||||
changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag);
|
||||
}
|
||||
|
||||
function getJsDocNodeForArrowFunction(signature: ArrowFunction): HasJSDoc {
|
||||
if (signature.parent.kind === SyntaxKind.PropertyDeclaration) {
|
||||
return signature.parent as HasJSDoc;
|
||||
}
|
||||
return signature.parent.parent as HasJSDoc;
|
||||
}
|
||||
|
||||
function tryMergeJsdocTags(oldTag: JSDocTag, newTag: JSDocTag): JSDocTag | undefined {
|
||||
if (oldTag.kind !== newTag.kind) {
|
||||
return undefined;
|
||||
}
|
||||
switch (oldTag.kind) {
|
||||
case SyntaxKind.JSDocParameterTag: {
|
||||
const oldParam = oldTag as JSDocParameterTag;
|
||||
const newParam = newTag as JSDocParameterTag;
|
||||
return isIdentifier(oldParam.name) && isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
|
||||
? factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
|
||||
: undefined;
|
||||
}
|
||||
case SyntaxKind.JSDocReturnTag:
|
||||
return factory.createJSDocReturnTag(/*tagName*/ undefined, (newTag as JSDocReturnTag).typeExpression, oldTag.comment);
|
||||
changes.addJSDocTags(sourceFile, signature, paramTags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1000,13 +961,25 @@ namespace ts.codefix {
|
|||
if (usage.numberIndex) {
|
||||
types.push(checker.createArrayType(combineFromUsage(usage.numberIndex)));
|
||||
}
|
||||
if (usage.properties?.size || usage.calls?.length || usage.constructs?.length || usage.stringIndex) {
|
||||
if (usage.properties?.size || usage.constructs?.length || usage.stringIndex) {
|
||||
types.push(inferStructuralType(usage));
|
||||
}
|
||||
|
||||
types.push(...(usage.candidateTypes || []).map(t => checker.getBaseTypeOfLiteralType(t)));
|
||||
types.push(...inferNamedTypesFromProperties(usage));
|
||||
const candidateTypes = (usage.candidateTypes || []).map(t => checker.getBaseTypeOfLiteralType(t));
|
||||
const callsType = usage.calls?.length ? inferStructuralType(usage) : undefined;
|
||||
if (callsType && candidateTypes) {
|
||||
types.push(checker.getUnionType([callsType, ...candidateTypes], UnionReduction.Subtype));
|
||||
}
|
||||
else {
|
||||
if (callsType) {
|
||||
types.push(callsType);
|
||||
}
|
||||
if (length(candidateTypes)) {
|
||||
types.push(...candidateTypes);
|
||||
}
|
||||
}
|
||||
|
||||
types.push(...inferNamedTypesFromProperties(usage));
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -738,10 +738,6 @@ namespace ts.Completions {
|
|||
insertText = `${escapeSnippetText(name)}={$1}`;
|
||||
isSnippet = true;
|
||||
}
|
||||
|
||||
if (isSnippet) {
|
||||
replacementSpan = createTextSpanFromNode(location, sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
|
||||
|
@ -851,7 +847,7 @@ namespace ts.Completions {
|
|||
removeComments: true,
|
||||
module: options.module,
|
||||
target: options.target,
|
||||
omitTrailingSemicolon: true,
|
||||
omitTrailingSemicolon: false,
|
||||
newLine: getNewLineKind(getNewLineCharacter(options, maybeBind(host, host.getNewLine))),
|
||||
});
|
||||
const importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
|
||||
|
@ -923,7 +919,10 @@ namespace ts.Completions {
|
|||
isAbstract);
|
||||
|
||||
if (completionNodes.length) {
|
||||
insertText = printer.printSnippetList(ListFormat.MultiLine, factory.createNodeArray(completionNodes), sourceFile);
|
||||
insertText = printer.printSnippetList(
|
||||
ListFormat.MultiLine | ListFormat.NoTrailingNewLine,
|
||||
factory.createNodeArray(completionNodes),
|
||||
sourceFile);
|
||||
}
|
||||
|
||||
return { insertText, isSnippet, importAdder };
|
||||
|
@ -3526,6 +3525,7 @@ namespace ts.Completions {
|
|||
// function f<T>(x: T) {}
|
||||
// f({ abc/**/: "" }) // `abc` is a member of `T` but only because it declares itself
|
||||
function hasDeclarationOtherThanSelf(member: Symbol) {
|
||||
if (!length(member.declarations)) return true;
|
||||
return some(member.declarations, decl => decl.parent !== obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1323,7 +1323,7 @@ namespace ts.FindAllReferences {
|
|||
if (!symbol) return undefined;
|
||||
for (const token of getPossibleSymbolReferenceNodes(sourceFile, symbol.name, searchContainer)) {
|
||||
if (!isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) continue;
|
||||
const referenceSymbol: Symbol = checker.getSymbolAtLocation(token)!; // See GH#19955 for why the type annotation is necessary
|
||||
const referenceSymbol = checker.getSymbolAtLocation(token)!;
|
||||
if (referenceSymbol === symbol
|
||||
|| checker.getShorthandAssignmentValueSymbol(token.parent) === symbol
|
||||
|| isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) {
|
||||
|
|
|
@ -198,14 +198,17 @@ namespace ts.GoToDefinition {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const symbol = typeChecker.getSymbolAtLocation(node);
|
||||
const symbol = getSymbol(node, typeChecker);
|
||||
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.
|
||||
return fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
||||
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;
|
||||
}
|
||||
|
||||
function definitionFromType(type: Type, checker: TypeChecker, node: Node): readonly DefinitionInfo[] {
|
||||
|
|
|
@ -314,8 +314,7 @@ namespace ts.refactor.extractSymbol {
|
|||
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
||||
}
|
||||
const statements: Statement[] = [];
|
||||
const start2 = start; // TODO: GH#18217 Need to alias `start` to get this to compile. See https://github.com/Microsoft/TypeScript/issues/19955#issuecomment-344118248
|
||||
for (const statement of (start2.parent as BlockLike).statements) {
|
||||
for (const statement of start.parent.statements) {
|
||||
if (statement === start || statements.length) {
|
||||
const errors = checkNode(statement);
|
||||
if (errors) {
|
||||
|
@ -364,10 +363,11 @@ namespace ts.refactor.extractSymbol {
|
|||
return node.expression;
|
||||
}
|
||||
}
|
||||
else if (isVariableStatement(node)) {
|
||||
else if (isVariableStatement(node) || isVariableDeclarationList(node)) {
|
||||
const declarations = isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
||||
let numInitializers = 0;
|
||||
let lastInitializer: Expression | undefined;
|
||||
for (const declaration of node.declarationList.declarations) {
|
||||
for (const declaration of declarations) {
|
||||
if (declaration.initializer) {
|
||||
numInitializers++;
|
||||
lastInitializer = declaration.initializer;
|
||||
|
@ -383,7 +383,6 @@ namespace ts.refactor.extractSymbol {
|
|||
return node.initializer;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -599,10 +599,11 @@ namespace ts {
|
|||
}
|
||||
|
||||
function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration, cb: (symbol: Symbol) => T[] | undefined): T[] | undefined {
|
||||
if (hasStaticModifier(declaration)) return;
|
||||
|
||||
const classOrInterfaceDeclaration = declaration.parent?.kind === SyntaxKind.Constructor ? declaration.parent.parent : declaration.parent;
|
||||
if (!classOrInterfaceDeclaration) {
|
||||
return;
|
||||
}
|
||||
if (!classOrInterfaceDeclaration) return;
|
||||
|
||||
return firstDefined(getAllSuperTypeNodes(classOrInterfaceDeclaration), superTypeNode => {
|
||||
const symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name);
|
||||
return symbol ? cb(symbol) : undefined;
|
||||
|
|
|
@ -494,6 +494,27 @@ namespace ts.textChanges {
|
|||
this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
|
||||
}
|
||||
|
||||
public addJSDocTags(sourceFile: SourceFile, parent: HasJSDoc, newTags: readonly JSDocTag[]): void {
|
||||
const comments = flatMap(parent.jsDoc, j => typeof j.comment === "string" ? factory.createJSDocText(j.comment) : j.comment) as JSDocComment[];
|
||||
const oldTags = flatMapToMutable(parent.jsDoc, j => j.tags);
|
||||
const unmergedNewTags = newTags.filter(newTag => !oldTags.some((tag, i) => {
|
||||
const merged = tryMergeJsdocTags(tag, newTag);
|
||||
if (merged) oldTags[i] = merged;
|
||||
return !!merged;
|
||||
}));
|
||||
const tag = factory.createJSDocComment(factory.createNodeArray(intersperse(comments, factory.createJSDocText("\n"))), factory.createNodeArray([...oldTags, ...unmergedNewTags]));
|
||||
const host = updateJSDocHost(parent);
|
||||
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
||||
}
|
||||
|
||||
public filterJSDocTags(sourceFile: SourceFile, parent: HasJSDoc, predicate: (tag: JSDocTag) => boolean): void {
|
||||
const comments = flatMap(parent.jsDoc, j => typeof j.comment === "string" ? factory.createJSDocText(j.comment) : j.comment) as JSDocComment[];
|
||||
const oldTags = flatMapToMutable(parent.jsDoc, j => j.tags);
|
||||
const tag = factory.createJSDocComment(factory.createNodeArray(intersperse(comments, factory.createJSDocText("\n"))), factory.createNodeArray([...(filter(oldTags, predicate) || emptyArray)]));
|
||||
const host = updateJSDocHost(parent);
|
||||
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
||||
}
|
||||
|
||||
public replaceRangeWithText(sourceFile: SourceFile, range: TextRange, text: string): void {
|
||||
this.changes.push({ kind: ChangeKind.Text, sourceFile, range, text });
|
||||
}
|
||||
|
@ -920,6 +941,35 @@ namespace ts.textChanges {
|
|||
}
|
||||
}
|
||||
|
||||
function updateJSDocHost(parent: HasJSDoc): HasJSDoc {
|
||||
if (parent.kind !== SyntaxKind.ArrowFunction) {
|
||||
return parent;
|
||||
}
|
||||
const jsDocNode = parent.parent.kind === SyntaxKind.PropertyDeclaration ?
|
||||
parent.parent as HasJSDoc :
|
||||
parent.parent.parent as HasJSDoc;
|
||||
jsDocNode.jsDoc = parent.jsDoc;
|
||||
jsDocNode.jsDocCache = parent.jsDocCache;
|
||||
return jsDocNode;
|
||||
}
|
||||
|
||||
function tryMergeJsdocTags(oldTag: JSDocTag, newTag: JSDocTag): JSDocTag | undefined {
|
||||
if (oldTag.kind !== newTag.kind) {
|
||||
return undefined;
|
||||
}
|
||||
switch (oldTag.kind) {
|
||||
case SyntaxKind.JSDocParameterTag: {
|
||||
const oldParam = oldTag as JSDocParameterTag;
|
||||
const newParam = newTag as JSDocParameterTag;
|
||||
return isIdentifier(oldParam.name) && isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
|
||||
? factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
|
||||
: undefined;
|
||||
}
|
||||
case SyntaxKind.JSDocReturnTag:
|
||||
return factory.createJSDocReturnTag(/*tagName*/ undefined, (newTag as JSDocReturnTag).typeExpression, oldTag.comment);
|
||||
}
|
||||
}
|
||||
|
||||
// find first non-whitespace position in the leading trivia of the node
|
||||
function startPositionToDeleteNodeInList(sourceFile: SourceFile, node: Node): number {
|
||||
return skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
|
||||
|
|
|
@ -182,34 +182,3 @@ describe("unittests:: Public APIs:: getChild* methods on EndOfFileToken with JSD
|
|||
assert.equal(endOfFileToken.getChildCount(), 1);
|
||||
assert.notEqual(endOfFileToken.getChildAt(0), /*expected*/ undefined);
|
||||
});
|
||||
|
||||
describe("unittests:: Public APIs:: sys", () => {
|
||||
it("readDirectory", () => {
|
||||
// #45990, testing passing a non-absolute path
|
||||
// `sys.readDirectory` is just `matchFiles` plugged into the real FS
|
||||
const read = ts.matchFiles(
|
||||
/*path*/ "",
|
||||
/*extensions*/ [".ts", ".tsx"],
|
||||
/*excludes*/ ["node_modules", "dist"],
|
||||
/*includes*/ ["**/*"],
|
||||
/*useCaseSensitiveFileNames*/ true,
|
||||
/*currentDirectory*/ "/",
|
||||
/*depth*/ undefined,
|
||||
/*getFileSystemEntries*/ path => {
|
||||
switch (path) {
|
||||
case "/": return { directories: [], files: ["file.ts"] };
|
||||
default: return { directories: [], files: [] };
|
||||
}
|
||||
},
|
||||
/*realpath*/ ts.identity,
|
||||
/*directoryExists*/ path => {
|
||||
switch (path) {
|
||||
case "/": return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
assert.deepEqual(read, ["/file.ts"]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace ts {
|
|||
testExtractRange("extractRange28", `[#|return [$|1|];|]`);
|
||||
|
||||
// For statements
|
||||
testExtractRange("extractRange29", `for ([#|var i = 1|]; i < 2; i++) {}`);
|
||||
testExtractRange("extractRange29", `for ([#|var i = [$|1|]|]; i < 2; i++) {}`);
|
||||
testExtractRange("extractRange30", `for (var i = [#|[$|1|]|]; i < 2; i++) {}`);
|
||||
});
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ namespace ts.projectSystem {
|
|||
};
|
||||
|
||||
function updateFile(path: string, newText: string) {
|
||||
Debug.assertDefined(files.find(f => f.path === path));
|
||||
Debug.assertIsDefined(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.assertDefined(files.find(f => f.path === file));
|
||||
Debug.assertIsDefined(files.find(f => f.path === file));
|
||||
session.executeCommandSeq<protocol.ReferencesRequest>({
|
||||
command: protocol.CommandTypes.References,
|
||||
arguments: {
|
||||
|
|
|
@ -897,7 +897,7 @@ declare namespace ts {
|
|||
export interface TypePredicateNode extends TypeNode {
|
||||
readonly kind: SyntaxKind.TypePredicate;
|
||||
readonly parent: SignatureDeclaration | JSDocTypeExpression;
|
||||
readonly assertsModifier?: AssertsToken;
|
||||
readonly assertsModifier?: AssertsKeyword;
|
||||
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?: ReadonlyToken | PlusToken | MinusToken;
|
||||
readonly readonlyToken?: ReadonlyKeyword | 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?: AwaitKeywordToken;
|
||||
readonly awaitModifier?: AwaitKeyword;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
|
|
|
@ -897,7 +897,7 @@ declare namespace ts {
|
|||
export interface TypePredicateNode extends TypeNode {
|
||||
readonly kind: SyntaxKind.TypePredicate;
|
||||
readonly parent: SignatureDeclaration | JSDocTypeExpression;
|
||||
readonly assertsModifier?: AssertsToken;
|
||||
readonly assertsModifier?: AssertsKeyword;
|
||||
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?: ReadonlyToken | PlusToken | MinusToken;
|
||||
readonly readonlyToken?: ReadonlyKeyword | 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?: AwaitKeywordToken;
|
||||
readonly awaitModifier?: AwaitKeyword;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/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: {} };
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/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: {} };
|
||||
}
|
||||
}
|
||||
|
9
tests/baselines/reference/defaultNamedExportWithType1.js
Normal file
9
tests/baselines/reference/defaultNamedExportWithType1.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [defaultNamedExportWithType1.ts]
|
||||
type Foo = number;
|
||||
export const Foo = 1;
|
||||
export default Foo;
|
||||
|
||||
|
||||
//// [defaultNamedExportWithType1.js]
|
||||
export const Foo = 1;
|
||||
export default Foo;
|
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
|
||||
type Foo = number;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))
|
||||
|
||||
export const Foo = 1;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 1, 12))
|
||||
|
||||
export default Foo;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))
|
||||
|
11
tests/baselines/reference/defaultNamedExportWithType1.types
Normal file
11
tests/baselines/reference/defaultNamedExportWithType1.types
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
|
||||
type Foo = number;
|
||||
>Foo : number
|
||||
|
||||
export const Foo = 1;
|
||||
>Foo : 1
|
||||
>1 : 1
|
||||
|
||||
export default Foo;
|
||||
>Foo : number
|
||||
|
9
tests/baselines/reference/defaultNamedExportWithType2.js
Normal file
9
tests/baselines/reference/defaultNamedExportWithType2.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [defaultNamedExportWithType2.ts]
|
||||
type Foo = number;
|
||||
const Foo = 1;
|
||||
export default Foo;
|
||||
|
||||
|
||||
//// [defaultNamedExportWithType2.js]
|
||||
const Foo = 1;
|
||||
export default Foo;
|
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
|
||||
type Foo = number;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
|
||||
|
||||
const Foo = 1;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
|
||||
|
||||
export default Foo;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
|
||||
|
11
tests/baselines/reference/defaultNamedExportWithType2.types
Normal file
11
tests/baselines/reference/defaultNamedExportWithType2.types
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
|
||||
type Foo = number;
|
||||
>Foo : number
|
||||
|
||||
const Foo = 1;
|
||||
>Foo : 1
|
||||
>1 : 1
|
||||
|
||||
export default Foo;
|
||||
>Foo : number
|
||||
|
9
tests/baselines/reference/defaultNamedExportWithType3.js
Normal file
9
tests/baselines/reference/defaultNamedExportWithType3.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [defaultNamedExportWithType3.ts]
|
||||
interface Foo {}
|
||||
export const Foo = {};
|
||||
export default Foo;
|
||||
|
||||
|
||||
//// [defaultNamedExportWithType3.js]
|
||||
export const Foo = {};
|
||||
export default Foo;
|
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
|
||||
interface Foo {}
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))
|
||||
|
||||
export const Foo = {};
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 1, 12))
|
||||
|
||||
export default Foo;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
|
||||
interface Foo {}
|
||||
export const Foo = {};
|
||||
>Foo : {}
|
||||
>{} : {}
|
||||
|
||||
export default Foo;
|
||||
>Foo : Foo
|
||||
|
9
tests/baselines/reference/defaultNamedExportWithType4.js
Normal file
9
tests/baselines/reference/defaultNamedExportWithType4.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [defaultNamedExportWithType4.ts]
|
||||
interface Foo {}
|
||||
const Foo = {};
|
||||
export default Foo;
|
||||
|
||||
|
||||
//// [defaultNamedExportWithType4.js]
|
||||
const Foo = {};
|
||||
export default Foo;
|
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
|
||||
interface Foo {}
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
|
||||
|
||||
const Foo = {};
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
|
||||
|
||||
export default Foo;
|
||||
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
|
||||
interface Foo {}
|
||||
const Foo = {};
|
||||
>Foo : {}
|
||||
>{} : {}
|
||||
|
||||
export default Foo;
|
||||
>Foo : Foo
|
||||
|
|
@ -43,6 +43,7 @@ var x = 0;
|
|||
var y = "";
|
||||
var z = 0;
|
||||
//// [duplicateVarsAcrossFileBoundaries_4.js]
|
||||
var p = P;
|
||||
var q;
|
||||
//// [duplicateVarsAcrossFileBoundaries_5.js]
|
||||
var p;
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,6 @@ export = x;
|
|||
|
||||
//// [importDeclWithExportModifierAndExportAssignment.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.a = void 0;
|
||||
exports.a = x.c;
|
||||
module.exports = x;
|
||||
|
|
|
@ -87,18 +87,18 @@ new Float64Array().at(0);
|
|||
>0 : 0
|
||||
|
||||
new BigInt64Array().at(0);
|
||||
>new BigInt64Array().at(0) : number
|
||||
>new BigInt64Array().at : (index: number) => number
|
||||
>new BigInt64Array().at(0) : bigint
|
||||
>new BigInt64Array().at : (index: number) => bigint
|
||||
>new BigInt64Array() : BigInt64Array
|
||||
>BigInt64Array : BigInt64ArrayConstructor
|
||||
>at : (index: number) => number
|
||||
>at : (index: number) => bigint
|
||||
>0 : 0
|
||||
|
||||
new BigUint64Array().at(0);
|
||||
>new BigUint64Array().at(0) : number
|
||||
>new BigUint64Array().at : (index: number) => number
|
||||
>new BigUint64Array().at(0) : bigint
|
||||
>new BigUint64Array().at : (index: number) => bigint
|
||||
>new BigUint64Array() : BigUint64Array
|
||||
>BigUint64Array : BigUint64ArrayConstructor
|
||||
>at : (index: number) => number
|
||||
>at : (index: number) => bigint
|
||||
>0 : 0
|
||||
|
||||
|
|
|
@ -87,18 +87,18 @@ new Float64Array().at(0);
|
|||
>0 : 0
|
||||
|
||||
new BigInt64Array().at(0);
|
||||
>new BigInt64Array().at(0) : number
|
||||
>new BigInt64Array().at : (index: number) => number
|
||||
>new BigInt64Array().at(0) : bigint
|
||||
>new BigInt64Array().at : (index: number) => bigint
|
||||
>new BigInt64Array() : BigInt64Array
|
||||
>BigInt64Array : BigInt64ArrayConstructor
|
||||
>at : (index: number) => number
|
||||
>at : (index: number) => bigint
|
||||
>0 : 0
|
||||
|
||||
new BigUint64Array().at(0);
|
||||
>new BigUint64Array().at(0) : number
|
||||
>new BigUint64Array().at : (index: number) => number
|
||||
>new BigUint64Array().at(0) : bigint
|
||||
>new BigUint64Array().at : (index: number) => bigint
|
||||
>new BigUint64Array() : BigUint64Array
|
||||
>BigUint64Array : BigUint64ArrayConstructor
|
||||
>at : (index: number) => number
|
||||
>at : (index: number) => bigint
|
||||
>0 : 0
|
||||
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
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 (1 errors) ====
|
||||
==== tests/cases/compiler/export.js (3 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;
|
||||
export const foo = 5;
|
||||
~~~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'foo'.
|
97
tests/baselines/reference/plainJSBinderErrors.errors.txt
Normal file
97
tests/baselines/reference/plainJSBinderErrors.errors.txt
Normal file
|
@ -0,0 +1,97 @@
|
|||
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.
|
||||
|
84
tests/baselines/reference/plainJSBinderErrors.js
Normal file
84
tests/baselines/reference/plainJSBinderErrors.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
//// [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;
|
86
tests/baselines/reference/plainJSBinderErrors.symbols
Normal file
86
tests/baselines/reference/plainJSBinderErrors.symbols
Normal file
|
@ -0,0 +1,86 @@
|
|||
=== 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))
|
||||
|
105
tests/baselines/reference/plainJSBinderErrors.types
Normal file
105
tests/baselines/reference/plainJSBinderErrors.types
Normal file
|
@ -0,0 +1,105 @@
|
|||
=== 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
|
||||
|
37
tests/baselines/reference/plainJSModuleStrict.errors.txt
Normal file
37
tests/baselines/reference/plainJSModuleStrict.errors.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
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
|
||||
}
|
||||
|
30
tests/baselines/reference/plainJSModuleStrict.js
Normal file
30
tests/baselines/reference/plainJSModuleStrict.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
//// [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;
|
||||
}
|
28
tests/baselines/reference/plainJSModuleStrict.symbols
Normal file
28
tests/baselines/reference/plainJSModuleStrict.symbols
Normal file
|
@ -0,0 +1,28 @@
|
|||
=== 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))
|
||||
}
|
||||
|
33
tests/baselines/reference/plainJSModuleStrict.types
Normal file
33
tests/baselines/reference/plainJSModuleStrict.types
Normal file
|
@ -0,0 +1,33 @@
|
|||
=== 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
|
||||
}
|
||||
|
13
tests/baselines/reference/plainJSRedeclare.errors.txt
Normal file
13
tests/baselines/reference/plainJSRedeclare.errors.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
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()
|
||||
|
10
tests/baselines/reference/plainJSRedeclare.js
Normal file
10
tests/baselines/reference/plainJSRedeclare.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
//// [plainJSRedeclare.js]
|
||||
const orbitol = 1
|
||||
var orbitol = 1 + false
|
||||
orbitol.toExponential()
|
||||
|
||||
|
||||
//// [plainJSRedeclare.js]
|
||||
var orbitol = 1;
|
||||
var orbitol = 1 + false;
|
||||
orbitol.toExponential();
|
12
tests/baselines/reference/plainJSRedeclare.symbols
Normal file
12
tests/baselines/reference/plainJSRedeclare.symbols
Normal file
|
@ -0,0 +1,12 @@
|
|||
=== 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, --, --))
|
||||
|
17
tests/baselines/reference/plainJSRedeclare.types
Normal file
17
tests/baselines/reference/plainJSRedeclare.types
Normal file
|
@ -0,0 +1,17 @@
|
|||
=== 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
|
||||
|
16
tests/baselines/reference/plainJSRedeclare2.errors.txt
Normal file
16
tests/baselines/reference/plainJSRedeclare2.errors.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
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()
|
||||
|
10
tests/baselines/reference/plainJSRedeclare2.js
Normal file
10
tests/baselines/reference/plainJSRedeclare2.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
//// [plainJSRedeclare.js]
|
||||
const orbitol = 1
|
||||
var orbitol = 1 + false
|
||||
orbitol.toExponential()
|
||||
|
||||
|
||||
//// [plainJSRedeclare.js]
|
||||
var orbitol = 1;
|
||||
var orbitol = 1 + false;
|
||||
orbitol.toExponential();
|
12
tests/baselines/reference/plainJSRedeclare2.symbols
Normal file
12
tests/baselines/reference/plainJSRedeclare2.symbols
Normal file
|
@ -0,0 +1,12 @@
|
|||
=== 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, --, --))
|
||||
|
17
tests/baselines/reference/plainJSRedeclare2.types
Normal file
17
tests/baselines/reference/plainJSRedeclare2.types
Normal file
|
@ -0,0 +1,17 @@
|
|||
=== 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
|
||||
|
10
tests/baselines/reference/plainJSRedeclare3.js
Normal file
10
tests/baselines/reference/plainJSRedeclare3.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
//// [plainJSRedeclare.js]
|
||||
const orbitol = 1
|
||||
var orbitol = 1 + false
|
||||
orbitol.toExponential()
|
||||
|
||||
|
||||
//// [plainJSRedeclare.js]
|
||||
var orbitol = 1;
|
||||
var orbitol = 1 + false;
|
||||
orbitol.toExponential();
|
12
tests/baselines/reference/plainJSRedeclare3.symbols
Normal file
12
tests/baselines/reference/plainJSRedeclare3.symbols
Normal file
|
@ -0,0 +1,12 @@
|
|||
=== 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, --, --))
|
||||
|
17
tests/baselines/reference/plainJSRedeclare3.types
Normal file
17
tests/baselines/reference/plainJSRedeclare3.types
Normal file
|
@ -0,0 +1,17 @@
|
|||
=== 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
|
||||
|
13
tests/baselines/reference/plainJSReservedStrict.errors.txt
Normal file
13
tests/baselines/reference/plainJSReservedStrict.errors.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
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.
|
||||
|
10
tests/baselines/reference/plainJSReservedStrict.js
Normal file
10
tests/baselines/reference/plainJSReservedStrict.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
//// [plainJSReservedStrict.js]
|
||||
"use strict"
|
||||
const eval = 1
|
||||
const arguments = 2
|
||||
|
||||
|
||||
//// [plainJSReservedStrict.js]
|
||||
"use strict";
|
||||
const eval = 1;
|
||||
const arguments = 2;
|
8
tests/baselines/reference/plainJSReservedStrict.symbols
Normal file
8
tests/baselines/reference/plainJSReservedStrict.symbols
Normal file
|
@ -0,0 +1,8 @@
|
|||
=== 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))
|
||||
|
12
tests/baselines/reference/plainJSReservedStrict.types
Normal file
12
tests/baselines/reference/plainJSReservedStrict.types
Normal file
|
@ -0,0 +1,12 @@
|
|||
=== 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
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -135,7 +135,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -201,7 +201,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -411,7 +411,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -549,7 +549,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -687,7 +687,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -791,7 +791,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -857,7 +857,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -923,7 +923,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -1149,7 +1149,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -1295,7 +1295,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -1441,7 +1441,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -135,7 +135,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -201,7 +201,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -411,7 +411,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -549,7 +549,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -687,7 +687,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -791,7 +791,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -857,7 +857,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -923,7 +923,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -1149,7 +1149,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e1\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -1295,7 +1295,7 @@
|
|||
},
|
||||
{
|
||||
"text": "'e2'",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
@ -1441,7 +1441,7 @@
|
|||
},
|
||||
{
|
||||
"text": "\"e3\"",
|
||||
"kind": "stringLiteral"
|
||||
"kind": "enumMemberName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
|
|
134
tests/baselines/reference/quickInfoDisplayPartsEnum4.baseline
Normal file
134
tests/baselines/reference/quickInfoDisplayPartsEnum4.baseline
Normal file
|
@ -0,0 +1,134 @@
|
|||
[
|
||||
{
|
||||
"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": []
|
||||
}
|
||||
}
|
||||
]
|
20
tests/baselines/reference/spreadUnion4.js
Normal file
20
tests/baselines/reference/spreadUnion4.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
//// [spreadUnion4.ts]
|
||||
declare const a: { x: () => void }
|
||||
declare const b: { x?: () => void }
|
||||
|
||||
const c = { ...a, ...b };
|
||||
|
||||
|
||||
//// [spreadUnion4.js]
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var c = __assign(__assign({}, a), b);
|
14
tests/baselines/reference/spreadUnion4.symbols
Normal file
14
tests/baselines/reference/spreadUnion4.symbols
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== tests/cases/conformance/types/spread/spreadUnion4.ts ===
|
||||
declare const a: { x: () => void }
|
||||
>a : Symbol(a, Decl(spreadUnion4.ts, 0, 13))
|
||||
>x : Symbol(x, Decl(spreadUnion4.ts, 0, 18))
|
||||
|
||||
declare const b: { x?: () => void }
|
||||
>b : Symbol(b, Decl(spreadUnion4.ts, 1, 13))
|
||||
>x : Symbol(x, Decl(spreadUnion4.ts, 1, 18))
|
||||
|
||||
const c = { ...a, ...b };
|
||||
>c : Symbol(c, Decl(spreadUnion4.ts, 3, 5))
|
||||
>a : Symbol(a, Decl(spreadUnion4.ts, 0, 13))
|
||||
>b : Symbol(b, Decl(spreadUnion4.ts, 1, 13))
|
||||
|
15
tests/baselines/reference/spreadUnion4.types
Normal file
15
tests/baselines/reference/spreadUnion4.types
Normal file
|
@ -0,0 +1,15 @@
|
|||
=== tests/cases/conformance/types/spread/spreadUnion4.ts ===
|
||||
declare const a: { x: () => void }
|
||||
>a : { x: () => void; }
|
||||
>x : () => void
|
||||
|
||||
declare const b: { x?: () => void }
|
||||
>b : { x?: () => void; }
|
||||
>x : () => void
|
||||
|
||||
const c = { ...a, ...b };
|
||||
>c : { x: () => void; }
|
||||
>{ ...a, ...b } : { x: () => void; }
|
||||
>a : { x: () => void; }
|
||||
>b : { x?: () => void; }
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @return {number}
|
||||
*/
|
||||
function f(s) {
|
||||
>f : (s: string) => number
|
||||
>f : (this: { n: number; }, s: string) => number
|
||||
>s : string
|
||||
|
||||
return this.n + s.length
|
||||
|
@ -18,11 +18,11 @@ function f(s) {
|
|||
}
|
||||
|
||||
const o = {
|
||||
>o : { f: (s: string) => number; n: number; }
|
||||
>{ f, n: 1} : { f: (s: string) => number; n: number; }
|
||||
>o : { f: (this: { n: number; }, s: string) => number; n: number; }
|
||||
>{ f, n: 1} : { f: (this: { n: number; }, s: string) => number; n: number; }
|
||||
|
||||
f,
|
||||
>f : (s: string) => number
|
||||
>f : (this: { n: number; }, s: string) => number
|
||||
|
||||
n: 1
|
||||
>n : number
|
||||
|
@ -30,8 +30,8 @@ const o = {
|
|||
}
|
||||
o.f('hi')
|
||||
>o.f('hi') : number
|
||||
>o.f : (s: string) => number
|
||||
>o : { f: (s: string) => number; n: number; }
|
||||
>f : (s: string) => 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
|
||||
>'hi' : "hi"
|
||||
|
||||
|
|
15
tests/baselines/reference/thisTag2.js
Normal file
15
tests/baselines/reference/thisTag2.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [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;
|
9
tests/baselines/reference/thisTag2.symbols
Normal file
9
tests/baselines/reference/thisTag2.symbols
Normal file
|
@ -0,0 +1,9 @@
|
|||
=== 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))
|
||||
|
9
tests/baselines/reference/thisTag2.types
Normal file
9
tests/baselines/reference/thisTag2.types
Normal file
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/conformance/jsdoc/a.js ===
|
||||
/** @this {string} */
|
||||
export function f1() {}
|
||||
>f1 : (this: string) => void
|
||||
|
||||
/** @this */
|
||||
export function f2() {}
|
||||
>f2 : (this: any) => void
|
||||
|
5
tests/cases/compiler/defaultNamedExportWithType1.ts
Normal file
5
tests/cases/compiler/defaultNamedExportWithType1.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
// @target: esnext
|
||||
|
||||
type Foo = number;
|
||||
export const Foo = 1;
|
||||
export default Foo;
|
5
tests/cases/compiler/defaultNamedExportWithType2.ts
Normal file
5
tests/cases/compiler/defaultNamedExportWithType2.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
// @target: esnext
|
||||
|
||||
type Foo = number;
|
||||
const Foo = 1;
|
||||
export default Foo;
|
5
tests/cases/compiler/defaultNamedExportWithType3.ts
Normal file
5
tests/cases/compiler/defaultNamedExportWithType3.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
// @target: esnext
|
||||
|
||||
interface Foo {}
|
||||
export const Foo = {};
|
||||
export default Foo;
|
5
tests/cases/compiler/defaultNamedExportWithType4.ts
Normal file
5
tests/cases/compiler/defaultNamedExportWithType4.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
// @target: esnext
|
||||
|
||||
interface Foo {}
|
||||
const Foo = {};
|
||||
export default Foo;
|
11
tests/cases/conformance/jsdoc/thisTag2.ts
Normal file
11
tests/cases/conformance/jsdoc/thisTag2.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
// @target: esnext
|
||||
// @allowJs: true
|
||||
// @declaration: true
|
||||
// @emitDeclarationOnly: true
|
||||
// @filename: a.js
|
||||
|
||||
/** @this {string} */
|
||||
export function f1() {}
|
||||
|
||||
/** @this */
|
||||
export function f2() {}
|
44
tests/cases/conformance/salsa/plainJSBinderErrors.ts
Normal file
44
tests/cases/conformance/salsa/plainJSBinderErrors.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
// @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
|
6
tests/cases/conformance/salsa/plainJSRedeclare.ts
Normal file
6
tests/cases/conformance/salsa/plainJSRedeclare.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
// @outdir: out/
|
||||
// @allowJS: true
|
||||
// @filename: plainJSRedeclare.js
|
||||
const orbitol = 1
|
||||
var orbitol = 1 + false
|
||||
orbitol.toExponential()
|
7
tests/cases/conformance/salsa/plainJSRedeclare2.ts
Normal file
7
tests/cases/conformance/salsa/plainJSRedeclare2.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
// @outdir: out/
|
||||
// @allowJS: true
|
||||
// @checkJS: true
|
||||
// @filename: plainJSRedeclare.js
|
||||
const orbitol = 1
|
||||
var orbitol = 1 + false
|
||||
orbitol.toExponential()
|
7
tests/cases/conformance/salsa/plainJSRedeclare3.ts
Normal file
7
tests/cases/conformance/salsa/plainJSRedeclare3.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
// @outdir: out/
|
||||
// @allowJS: true
|
||||
// @checkJS: false
|
||||
// @filename: plainJSRedeclare.js
|
||||
const orbitol = 1
|
||||
var orbitol = 1 + false
|
||||
orbitol.toExponential()
|
7
tests/cases/conformance/salsa/plainJSReservedStrict.ts
Normal file
7
tests/cases/conformance/salsa/plainJSReservedStrict.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
// @outdir: out/
|
||||
// @target: esnext
|
||||
// @allowJS: true
|
||||
// @filename: plainJSReservedStrict.js
|
||||
"use strict"
|
||||
const eval = 1
|
||||
const arguments = 2
|
4
tests/cases/conformance/types/spread/spreadUnion4.ts
Normal file
4
tests/cases/conformance/types/spread/spreadUnion4.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
declare const a: { x: () => void }
|
||||
declare const b: { x?: () => void }
|
||||
|
||||
const c = { ...a, ...b };
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue