Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint

This commit is contained in:
Alexander T 2019-08-06 09:07:48 +03:00
commit 034ba9fd25
82 changed files with 1374 additions and 7824 deletions

View file

@ -446,10 +446,10 @@ task("runtests-parallel").flags = {
" --shardId": "1-based ID of this shard (default: 1)",
};
task("diff", () => exec(getDiffTool(), [refBaseline, localBaseline], { ignoreExitCode: true }));
task("diff", () => exec(getDiffTool(), [refBaseline, localBaseline], { ignoreExitCode: true, waitForExit: false }));
task("diff").description = "Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable";
task("diff-rwc", () => exec(getDiffTool(), [refRwcBaseline, localRwcBaseline], { ignoreExitCode: true }));
task("diff-rwc", () => exec(getDiffTool(), [refRwcBaseline, localRwcBaseline], { ignoreExitCode: true, waitForExit: false }));
task("diff-rwc").description = "Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable";
/**

File diff suppressed because it is too large Load diff

View file

@ -25,10 +25,11 @@ const isWindows = /^win/.test(process.platform);
* @property {boolean} [ignoreExitCode]
* @property {import("prex").CancellationToken} [cancelToken]
* @property {boolean} [hidePrompt]
* @property {boolean} [waitForExit=true]
*/
function exec(cmd, args, options = {}) {
return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => {
const { ignoreExitCode, cancelToken = CancellationToken.none } = options;
const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options;
cancelToken.throwIfCancellationRequested();
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
@ -36,26 +37,33 @@ function exec(cmd, args, options = {}) {
const command = isWindows ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`];
if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
const proc = spawn(isWindows ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true });
const proc = spawn(isWindows ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: waitForExit ? "inherit" : "ignore", windowsVerbatimArguments: true });
const registration = cancelToken.register(() => {
log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`);
proc.kill("SIGINT");
proc.kill("SIGTERM");
reject(new CancelError());
});
proc.on("exit", exitCode => {
registration.unregister();
if (exitCode === 0 || ignoreExitCode) {
resolve({ exitCode });
}
else {
reject(new Error(`Process exited with code: ${exitCode}`));
}
});
proc.on("error", error => {
registration.unregister();
reject(error);
});
if (waitForExit) {
proc.on("exit", exitCode => {
registration.unregister();
if (exitCode === 0 || ignoreExitCode) {
resolve({ exitCode });
}
else {
reject(new Error(`Process exited with code: ${exitCode}`));
}
});
proc.on("error", error => {
registration.unregister();
reject(error);
});
}
else {
proc.unref();
// wait a short period in order to allow the process to start successfully before Node exits.
setTimeout(() => resolve({ exitCode: undefined }), 100);
}
}));
}
exports.exec = exec;

View file

@ -27,9 +27,14 @@ async function copyLibFiles() {
async function copyLocalizedDiagnostics() {
const dir = await fs.readdir(source);
const ignoredFolders = ["enu"];
for (const d of dir) {
const fileName = path.join(source, d);
if (fs.statSync(fileName).isDirectory()) {
if (
fs.statSync(fileName).isDirectory() &&
ignoredFolders.indexOf(d) < 0
) {
await fs.copy(fileName, path.join(dest, d));
}
}

View file

@ -2377,7 +2377,7 @@ namespace ts {
return links.target;
}
function markExportAsReferenced(node: ImportEqualsDeclaration | ExportAssignment | ExportSpecifier) {
function markExportAsReferenced(node: ImportEqualsDeclaration | ExportSpecifier) {
const symbol = getSymbolOfNode(node);
const target = resolveAlias(symbol);
if (target) {
@ -2399,15 +2399,10 @@ namespace ts {
links.referenced = true;
const node = getDeclarationOfAliasSymbol(symbol);
if (!node) return Debug.fail();
if (node.kind === SyntaxKind.ExportAssignment) {
// export default <symbol>
checkExpressionCached((<ExportAssignment>node).expression);
}
else if (node.kind === SyntaxKind.ExportSpecifier) {
// export { <symbol> } or export { <symbol> as foo }
checkExpressionCached((<ExportSpecifier>node).propertyName || (<ExportSpecifier>node).name);
}
else if (isInternalModuleImportEqualsDeclaration(node)) {
// We defer checking of the reference of an `import =` until the import itself is referenced,
// This way a chain of imports can be elided if ultimately the final input is only used in a type
// position.
if (isInternalModuleImportEqualsDeclaration(node)) {
// import foo = <symbol>
checkExpressionCached(<Expression>node.moduleReference);
}
@ -17829,8 +17824,12 @@ namespace ts {
return type;
}
function isExportOrExportExpression(location: Node) {
return !!findAncestor(location, e => e.parent && isExportAssignment(e.parent) && e.parent.expression === e && isEntityNameExpression(e));
}
function markAliasReferenced(symbol: Symbol, location: Node) {
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) {
markAliasSymbolAsReferenced(symbol);
}
}
@ -18812,6 +18811,17 @@ namespace ts {
return false;
}
function getContextualIterationType(kind: IterationTypeKind, functionDecl: SignatureDeclaration): Type | undefined {
const isAsync = !!(getFunctionFlags(functionDecl) & FunctionFlags.Async);
const contextualReturnType = getContextualReturnType(functionDecl);
if (contextualReturnType) {
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
|| undefined;
}
return undefined;
}
function getContextualReturnType(functionDecl: SignatureDeclaration): Type | undefined {
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
@ -20341,8 +20351,8 @@ namespace ts {
// if jsx emit was not react as there wont be error being emitted
reactSym.isReferenced = SymbolFlags.All;
// If react symbol is alias, mark it as referenced
if (reactSym.flags & SymbolFlags.Alias && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) {
// If react symbol is alias, mark it as refereced
if (reactSym.flags & SymbolFlags.Alias) {
markAliasSymbolAsReferenced(reactSym);
}
}
@ -23477,7 +23487,11 @@ namespace ts {
}
if (isGenerator) {
return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync);
return createGeneratorReturnType(
yieldType || neverType,
returnType || fallbackReturnType,
nextType || getContextualIterationType(IterationTypeKind.Next, func) || unknownType,
isAsync);
}
else {
// From within an async function you can return either a non-promise value or a promise. Any
@ -24839,13 +24853,7 @@ namespace ts {
|| anyType;
}
const contextualReturnType = getContextualReturnType(func);
if (contextualReturnType) {
return getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Next, contextualReturnType, isAsync)
|| anyType;
}
return anyType;
return getContextualIterationType(IterationTypeKind.Next, func) || anyType;
}
function checkConditionalExpression(node: ConditionalExpression, checkMode?: CheckMode): Type {
@ -24894,7 +24902,7 @@ namespace ts {
return result;
}
function checkExpressionCached(node: Expression, checkMode?: CheckMode): Type {
function checkExpressionCached(node: Expression | QualifiedName, checkMode?: CheckMode): Type {
const links = getNodeLinks(node);
if (!links.resolvedType) {
if (checkMode && checkMode !== CheckMode.Normal) {
@ -25222,7 +25230,8 @@ namespace ts {
(node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).expression === node) ||
(node.parent.kind === SyntaxKind.ElementAccessExpression && (<ElementAccessExpression>node.parent).expression === node) ||
((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(<Identifier>node) ||
(node.parent.kind === SyntaxKind.TypeQuery && (<TypeQueryNode>node.parent).exprName === node));
(node.parent.kind === SyntaxKind.TypeQuery && (<TypeQueryNode>node.parent).exprName === node)) ||
(node.parent.kind === SyntaxKind.ExportSpecifier && (compilerOptions.preserveConstEnums || node.flags & NodeFlags.Ambient)); // We allow reexporting const enums
if (!ok) {
error(node, Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query);
@ -30152,6 +30161,10 @@ namespace ts {
}
else {
markExportAsReferenced(node);
const target = symbol && (symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
if (!target || target === unknownSymbol || target.flags & SymbolFlags.Value) {
checkExpressionCached(node.propertyName || node.name);
}
}
}
}
@ -30178,7 +30191,17 @@ namespace ts {
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
}
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
const id = node.expression as Identifier;
const sym = resolveEntityName(id, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node);
if (sym) {
markAliasReferenced(sym, id);
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
const target = sym.flags & SymbolFlags.Alias ? resolveAlias(sym) : sym;
if (target === unknownSymbol || target.flags & SymbolFlags.Value) {
// However if it is a value, we need to check it's being used correctly
checkExpressionCached(node.expression);
}
}
if (getEmitDeclarations(compilerOptions)) {
collectLinkedAliases(node.expression as Identifier, /*setVisibility*/ true);

View file

@ -1743,6 +1743,16 @@ namespace ts {
return false;
}
/** @internal */
export interface TSConfig {
compilerOptions: CompilerOptions;
compileOnSave: boolean | undefined;
exclude?: ReadonlyArray<string>;
files: ReadonlyArray<string> | undefined;
include?: ReadonlyArray<string>;
references: ReadonlyArray<ProjectReference> | undefined;
}
/**
* Generate an uncommented, complete tsconfig for use with "--showConfig"
* @param configParseResult options to be generated into tsconfig.json
@ -1750,7 +1760,7 @@ namespace ts {
* @param host provides current directory and case sensitivity services
*/
/** @internal */
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): object {
export function convertToTSConfig(configParseResult: ParsedCommandLine, configFileName: string, host: { getCurrentDirectory(): string, useCaseSensitiveFileNames: boolean }): TSConfig {
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
const files = map(
filter(
@ -1778,13 +1788,13 @@ namespace ts {
build: undefined,
version: undefined,
},
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath, originalPath: undefined })),
references: map(configParseResult.projectReferences, r => ({ ...r, path: r.originalPath ? r.originalPath : "", originalPath: undefined })),
files: length(files) ? files : undefined,
...(configParseResult.configFileSpecs ? {
include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
} : {}),
compilerOnSave: !!configParseResult.compileOnSave ? true : undefined
compileOnSave: !!configParseResult.compileOnSave ? true : undefined
};
return config;
}

View file

@ -22,6 +22,7 @@ namespace ts {
const previousOnSubstituteNode = context.onSubstituteNode;
context.onSubstituteNode = onSubstituteNode;
let exportedVariableStatement = false;
let enabledSubstitutions: ESNextSubstitutionFlags;
let enclosingFunctionFlags: FunctionFlags;
let enclosingSuperContainerFlags: NodeCheckFlags = 0;
@ -40,6 +41,7 @@ namespace ts {
return node;
}
exportedVariableStatement = false;
const visited = visitEachChild(node, visitor, context);
addEmitHelpers(visited, context.readEmitHelpers());
return visited;
@ -79,6 +81,8 @@ namespace ts {
return visitBinaryExpression(node as BinaryExpression, noDestructuringValue);
case SyntaxKind.CatchClause:
return visitCatchClause(node as CatchClause);
case SyntaxKind.VariableStatement:
return visitVariableStatement(node as VariableStatement);
case SyntaxKind.VariableDeclaration:
return visitVariableDeclaration(node as VariableDeclaration);
case SyntaxKind.ForOfStatement:
@ -321,19 +325,43 @@ namespace ts {
return visitEachChild(node, visitor, context);
}
function visitVariableStatement(node: VariableStatement): VisitResult<VariableStatement> {
if (hasModifier(node, ModifierFlags.Export)) {
const savedExportedVariableStatement = exportedVariableStatement;
exportedVariableStatement = true;
const visited = visitEachChild(node, visitor, context);
exportedVariableStatement = savedExportedVariableStatement;
return visited;
}
return visitEachChild(node, visitor, context);
}
/**
* Visits a VariableDeclaration node with a binding pattern.
*
* @param node A VariableDeclaration node.
*/
function visitVariableDeclaration(node: VariableDeclaration): VisitResult<VariableDeclaration> {
if (exportedVariableStatement) {
const savedExportedVariableStatement = exportedVariableStatement;
exportedVariableStatement = false;
const visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true);
exportedVariableStatement = savedExportedVariableStatement;
return visited;
}
return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false);
}
function visitVariableDeclarationWorker(node: VariableDeclaration, exportedVariableStatement: boolean): VisitResult<VariableDeclaration> {
// If we are here it is because the name contains a binding pattern with a rest somewhere in it.
if (isBindingPattern(node.name) && node.name.transformFlags & TransformFlags.ContainsObjectRestOrSpread) {
return flattenDestructuringBinding(
node,
visitor,
context,
FlattenLevel.ObjectRest
FlattenLevel.ObjectRest,
/*rval*/ undefined,
exportedVariableStatement
);
}
return visitEachChild(node, visitor, context);

View file

@ -567,6 +567,8 @@ namespace ts {
return emitNode && emitNode.flags || 0;
}
const escapeNoSubstitutionTemplateLiteralText = compose(escapeString, escapeTemplateSubstitution);
const escapeNonAsciiNoSubstitutionTemplateLiteralText = compose(escapeNonAsciiString, escapeTemplateSubstitution);
export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, neverAsciiEscape: boolean | undefined) {
// If we don't need to downlevel and we can reach the original source text using
// the node's parent reference, then simply get the text as it was originally written.
@ -577,7 +579,11 @@ namespace ts {
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
}
const escapeText = neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ? escapeString : escapeNonAsciiString;
// If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text
// had to include a backslash: `not \${a} substitution`.
const escapeText = neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ?
node.kind === SyntaxKind.NoSubstitutionTemplateLiteral ? escapeNoSubstitutionTemplateLiteralText : escapeString :
node.kind === SyntaxKind.NoSubstitutionTemplateLiteral ? escapeNonAsciiNoSubstitutionTemplateLiteralText : escapeNonAsciiString;
// If we can't reach the original source text, use the canonical form if it's a number,
// or a (possibly escaped) quoted form of the original text if it's string-like.
@ -3118,6 +3124,11 @@ namespace ts {
}
}
const templateSubstitutionRegExp = /\$\{/g;
function escapeTemplateSubstitution(str: string): string {
return str.replace(templateSubstitutionRegExp, "\\${");
}
// This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator,
// paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in
// the language service. These characters should be escaped when printing, and if any characters are added,

View file

@ -730,6 +730,7 @@ namespace Harness {
includeBuiltFile?: string;
baselineFile?: string;
libFiles?: string;
noTypesAndSymbols?: boolean;
}
// Additional options not already in ts.optionDeclarations
@ -746,6 +747,7 @@ namespace Harness {
{ name: "currentDirectory", type: "string" },
{ name: "symlink", type: "string" },
{ name: "link", type: "string" },
{ name: "noTypesAndSymbols", type: "boolean" },
// Emitted js baseline will print full paths for every output file
{ name: "fullEmitPaths", type: "boolean" }
];

View file

@ -577,10 +577,10 @@ namespace ts.FindAllReferences {
// If a reference is a class expression, the exported node would be its parent.
// If a reference is a variable declaration, the exported node would be the variable statement.
function getExportNode(parent: Node, node: Node): Node | undefined {
if (parent.kind === SyntaxKind.VariableDeclaration) {
const p = parent as VariableDeclaration;
return p.name !== node ? undefined :
p.parent.kind === SyntaxKind.CatchClause ? undefined : p.parent.parent.kind === SyntaxKind.VariableStatement ? p.parent.parent : undefined;
const declaration = isVariableDeclaration(parent) ? parent : isBindingElement(parent) ? walkUpBindingElementsAndPatterns(parent) : undefined;
if (declaration) {
return (parent as VariableDeclaration | BindingElement).name !== node ? undefined :
isCatchClause(declaration.parent) ? undefined : isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined;
}
else {
return parent;

View file

@ -58,16 +58,18 @@ class CompilerBaselineRunner extends RunnerBase {
}
public checkTestCodeOutput(fileName: string, test?: CompilerFileBasedTest) {
if (test && test.configurations) {
if (test && ts.some(test.configurations)) {
test.configurations.forEach(configuration => {
describe(`${this.testSuiteName} tests for ${fileName}${configuration ? ` (${Harness.getFileBasedTestConfigurationDescription(configuration)})` : ``}`, () => {
this.runSuite(fileName, test, configuration);
});
});
}
describe(`${this.testSuiteName} tests for ${fileName}`, () => {
this.runSuite(fileName, test);
});
else {
describe(`${this.testSuiteName} tests for ${fileName}`, () => {
this.runSuite(fileName, test);
});
}
}
private runSuite(fileName: string, test?: CompilerFileBasedTest, configuration?: Harness.FileBasedTestConfiguration) {
@ -112,6 +114,7 @@ class CompilerBaselineRunner extends RunnerBase {
class CompilerTest {
private fileName: string;
private justName: string;
private configuredName: string;
private lastUnit: Harness.TestCaseParser.TestUnitData;
private harnessSettings: Harness.TestCaseParser.CompilerSettings;
private hasNonDtsFiles: boolean;
@ -126,6 +129,25 @@ class CompilerTest {
constructor(fileName: string, testCaseContent?: Harness.TestCaseParser.TestCaseContent, configurationOverrides?: Harness.TestCaseParser.CompilerSettings) {
this.fileName = fileName;
this.justName = vpath.basename(fileName);
this.configuredName = this.justName;
if (configurationOverrides) {
let configuredName = "";
const keys = Object
.keys(configurationOverrides)
.map(k => k.toLowerCase())
.sort();
for (const key of keys) {
if (configuredName) {
configuredName += ",";
}
configuredName += `${key}=${configurationOverrides[key].toLowerCase()}`;
}
if (configuredName) {
const extname = vpath.extname(this.justName);
const basename = vpath.basename(this.justName, extname, /*ignoreCase*/ true);
this.configuredName = `${basename}(${configuredName})${extname}`;
}
}
const rootDir = fileName.indexOf("conformance") === -1 ? "tests/cases/compiler/" : ts.getDirectoryPath(fileName) + "/";
@ -205,7 +227,7 @@ class CompilerTest {
public verifyDiagnostics() {
// check errors
Harness.Compiler.doErrorBaseline(
this.justName,
this.configuredName,
this.tsConfigFiles.concat(this.toBeCompiled, this.otherFiles),
this.result.diagnostics,
!!this.options.pretty);
@ -213,7 +235,7 @@ class CompilerTest {
public verifyModuleResolution() {
if (this.options.traceResolution) {
Harness.Baseline.runBaseline(this.justName.replace(/\.tsx?$/, ".trace.json"),
Harness.Baseline.runBaseline(this.configuredName.replace(/\.tsx?$/, ".trace.json"),
JSON.stringify(this.result.traces.map(utils.sanitizeTraceResolutionLogEntry), undefined, 4));
}
}
@ -225,14 +247,14 @@ class CompilerTest {
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required.
? null // eslint-disable-line no-null/no-null
: record;
Harness.Baseline.runBaseline(this.justName.replace(/\.tsx?$/, ".sourcemap.txt"), baseline);
Harness.Baseline.runBaseline(this.configuredName.replace(/\.tsx?$/, ".sourcemap.txt"), baseline);
}
}
public verifyJavaScriptOutput() {
if (this.hasNonDtsFiles) {
Harness.Compiler.doJsEmitBaseline(
this.justName,
this.configuredName,
this.fileName,
this.options,
this.result,
@ -245,7 +267,7 @@ class CompilerTest {
public verifySourceMapOutput() {
Harness.Compiler.doSourcemapBaseline(
this.justName,
this.configuredName,
this.options,
this.result,
this.harnessSettings);
@ -256,8 +278,15 @@ class CompilerTest {
return;
}
const noTypesAndSymbols =
this.harnessSettings.noTypesAndSymbols &&
this.harnessSettings.noTypesAndSymbols.toLowerCase() === "true";
if (noTypesAndSymbols) {
return;
}
Harness.Compiler.doTypeAndSymbolBaseline(
this.justName,
this.configuredName,
this.result.program!,
this.toBeCompiled.concat(this.otherFiles).filter(file => !!this.result.program!.getSourceFile(file.unitName)),
/*opts*/ undefined,

View file

@ -131,6 +131,7 @@
"unittests/tsserver/formatSettings.ts",
"unittests/tsserver/getApplicableRefactors.ts",
"unittests/tsserver/getEditsForFileRename.ts",
"unittests/tsserver/getExportReferences.ts",
"unittests/tsserver/importHelpers.ts",
"unittests/tsserver/inferredProjects.ts",
"unittests/tsserver/languageService.ts",

View file

@ -53,6 +53,26 @@ namespace ts {
showTSConfigCorrectly("Show TSConfig with advanced options", ["--showConfig", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]);
showTSConfigCorrectly("Show TSConfig with compileOnSave and more", ["-p", "tsconfig.json"], {
compilerOptions: {
esModuleInterop: true,
target: "es5",
module: "commonjs",
strict: true,
},
compileOnSave: true,
exclude: [
"dist"
],
files: [],
include: [
"src/*"
],
references: [
{ path: "./test" }
],
});
// Regression test for https://github.com/Microsoft/TypeScript/issues/28836
showTSConfigCorrectly("Show TSConfig with paths and more", ["-p", "tsconfig.json"], {
compilerOptions: {

View file

@ -1,11 +1,4 @@
namespace ts.projectSystem {
interface DocumentSpanFromSubstring {
file: File;
text: string;
options?: SpanFromSubstringOptions;
contextText?: string;
contextOptions?: SpanFromSubstringOptions;
}
function documentSpanFromSubstring({ file, text, contextText, options, contextOptions }: DocumentSpanFromSubstring): DocumentSpan {
const contextSpan = contextText !== undefined ? documentSpanFromSubstring({ file, text: contextText, options: contextOptions }) : undefined;
return {
@ -19,19 +12,6 @@ namespace ts.projectSystem {
return documentSpanFromSubstring(input);
}
interface MakeReferenceItem extends DocumentSpanFromSubstring {
isDefinition: boolean;
lineText: string;
}
function makeReferenceItem({ isDefinition, lineText, ...rest }: MakeReferenceItem): protocol.ReferencesResponseItem {
return {
...protocolFileSpanWithContextFromSubstring(rest),
isDefinition,
isWriteAccess: isDefinition,
lineText,
};
}
interface MakeReferenceEntry extends DocumentSpanFromSubstring {
isDefinition: boolean;
}

View file

@ -0,0 +1,185 @@
namespace ts.projectSystem {
describe("unittests:: tsserver:: getExportReferences", () => {
const exportVariable = "export const value = 0;";
const exportArrayDestructured = "export const [valueA, valueB] = [0, 1];";
const exportObjectDestructured = "export const { valueC, valueD: renamedD } = { valueC: 0, valueD: 1 };";
const exportNestedObject = "export const { nest: [valueE, { valueF }] } = { nest: [0, { valueF: 1 }] };";
const mainTs: File = {
path: "/main.ts",
content: 'import { value, valueA, valueB, valueC, renamedD, valueE, valueF } from "./mod";',
};
const modTs: File = {
path: "/mod.ts",
content: `${exportVariable}
${exportArrayDestructured}
${exportObjectDestructured}
${exportNestedObject}
`,
};
const tsconfig: File = {
path: "/tsconfig.json",
content: "{}",
};
function makeSampleSession() {
const host = createServerHost([mainTs, modTs, tsconfig]);
const session = createSession(host);
openFilesForSession([mainTs, modTs], session);
return session;
}
const referenceMainTs = (mainTs: File, text: string): protocol.ReferencesResponseItem =>
makeReferenceItem({
file: mainTs,
isDefinition: true,
lineText: mainTs.content,
contextText: mainTs.content,
text,
});
const referenceModTs = (
texts: { text: string; lineText: string; contextText?: string },
override: Partial<MakeReferenceItem> = {},
): protocol.ReferencesResponseItem =>
makeReferenceItem({
file: modTs,
isDefinition: true,
...texts,
...override,
});
it("should get const variable declaration references", () => {
const session = makeSampleSession();
const response = executeSessionRequest<protocol.ReferencesRequest, protocol.ReferencesResponse>(
session,
protocol.CommandTypes.References,
protocolFileLocationFromSubstring(modTs, "value"),
);
const expectResponse = {
refs: [
referenceModTs({ text: "value", lineText: exportVariable, contextText: exportVariable }),
referenceMainTs(mainTs, "value"),
],
symbolDisplayString: "const value: 0",
symbolName: "value",
symbolStartOffset: protocolLocationFromSubstring(modTs.content, "value").offset,
};
assert.deepEqual(response, expectResponse);
});
it("should get array destructuring declaration references", () => {
const session = makeSampleSession();
const response = executeSessionRequest<protocol.ReferencesRequest, protocol.ReferencesResponse>(
session,
protocol.CommandTypes.References,
protocolFileLocationFromSubstring(modTs, "valueA"),
);
const expectResponse = {
refs: [
referenceModTs({
text: "valueA",
lineText: exportArrayDestructured,
contextText: exportArrayDestructured,
}),
referenceMainTs(mainTs, "valueA"),
],
symbolDisplayString: "const valueA: number",
symbolName: "valueA",
symbolStartOffset: protocolLocationFromSubstring(modTs.content, "valueA").offset,
};
assert.deepEqual(response, expectResponse);
});
it("should get object destructuring declaration references", () => {
const session = makeSampleSession();
const response = executeSessionRequest<protocol.ReferencesRequest, protocol.ReferencesResponse>(
session,
protocol.CommandTypes.References,
protocolFileLocationFromSubstring(modTs, "valueC"),
);
const expectResponse = {
refs: [
referenceModTs({
text: "valueC",
lineText: exportObjectDestructured,
contextText: exportObjectDestructured,
}),
referenceMainTs(mainTs, "valueC"),
referenceModTs(
{ text: "valueC", lineText: exportObjectDestructured, contextText: "valueC: 0" },
{ options: { index: 1 } },
),
],
symbolDisplayString: "const valueC: number",
symbolName: "valueC",
symbolStartOffset: protocolLocationFromSubstring(modTs.content, "valueC").offset,
};
assert.deepEqual(response, expectResponse);
});
it("should get object declaration references that renames destructured property", () => {
const session = makeSampleSession();
const response = executeSessionRequest<protocol.ReferencesRequest, protocol.ReferencesResponse>(
session,
protocol.CommandTypes.References,
protocolFileLocationFromSubstring(modTs, "renamedD"),
);
const expectResponse = {
refs: [
referenceModTs({
text: "renamedD",
lineText: exportObjectDestructured,
contextText: exportObjectDestructured,
}),
referenceMainTs(mainTs, "renamedD"),
],
symbolDisplayString: "const renamedD: number",
symbolName: "renamedD",
symbolStartOffset: protocolLocationFromSubstring(modTs.content, "renamedD").offset,
};
assert.deepEqual(response, expectResponse);
});
it("should get nested object declaration references", () => {
const session = makeSampleSession();
const response = executeSessionRequest<protocol.ReferencesRequest, protocol.ReferencesResponse>(
session,
protocol.CommandTypes.References,
protocolFileLocationFromSubstring(modTs, "valueF"),
);
const expectResponse = {
refs: [
referenceModTs({
text: "valueF",
lineText: exportNestedObject,
contextText: exportNestedObject,
}),
referenceMainTs(mainTs, "valueF"),
referenceModTs(
{
text: "valueF",
lineText: exportNestedObject,
contextText: "valueF: 1",
},
{ options: { index: 1 } },
),
],
symbolDisplayString: "const valueF: number",
symbolName: "valueF",
symbolStartOffset: protocolLocationFromSubstring(modTs.content, "valueF").offset,
};
assert.deepEqual(response, expectResponse);
});
});
}

View file

@ -519,6 +519,8 @@ namespace ts.projectSystem {
file: File;
text: string;
options?: SpanFromSubstringOptions;
contextText?: string;
contextOptions?: SpanFromSubstringOptions;
}
export function protocolFileSpanFromSubstring({ file, text, options }: DocumentSpanFromSubstring): protocol.FileSpan {
return { file: file.path, ...protocolTextSpanFromSubstring(file.content, text, options) };
@ -727,4 +729,18 @@ namespace ts.projectSystem {
assert.strictEqual(outputs.length, index + 1, JSON.stringify(outputs));
}
}
export interface MakeReferenceItem extends DocumentSpanFromSubstring {
isDefinition: boolean;
lineText: string;
}
export function makeReferenceItem({ isDefinition, lineText, ...rest }: MakeReferenceItem): protocol.ReferencesResponseItem {
return {
...protocolFileSpanWithContextFromSubstring(rest),
isDefinition,
isWriteAccess: isDefinition,
lineText,
};
}
}

View file

@ -0,0 +1,40 @@
//// [tests/cases/compiler/amdModuleConstEnumUsage.ts] ////
//// [cc.ts]
export const enum CharCode {
A,
B
}
//// [file.ts]
import { CharCode } from 'defs/cc';
export class User {
method(input: number) {
if (CharCode.A === input) {}
}
}
//// [cc.js]
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
var CharCode;
(function (CharCode) {
CharCode[CharCode["A"] = 0] = "A";
CharCode[CharCode["B"] = 1] = "B";
})(CharCode = exports.CharCode || (exports.CharCode = {}));
});
//// [file.js]
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
var User = /** @class */ (function () {
function User() {
}
User.prototype.method = function (input) {
if (0 /* A */ === input) { }
};
return User;
}());
exports.User = User;
});

View file

@ -0,0 +1,29 @@
=== /proj/defs/cc.ts ===
export const enum CharCode {
>CharCode : Symbol(CharCode, Decl(cc.ts, 0, 0))
A,
>A : Symbol(CharCode.A, Decl(cc.ts, 0, 28))
B
>B : Symbol(CharCode.B, Decl(cc.ts, 1, 6))
}
=== /proj/component/file.ts ===
import { CharCode } from 'defs/cc';
>CharCode : Symbol(CharCode, Decl(file.ts, 0, 8))
export class User {
>User : Symbol(User, Decl(file.ts, 0, 35))
method(input: number) {
>method : Symbol(User.method, Decl(file.ts, 1, 19))
>input : Symbol(input, Decl(file.ts, 2, 11))
if (CharCode.A === input) {}
>CharCode.A : Symbol(CharCode.A, Decl(cc.ts, 0, 28))
>CharCode : Symbol(CharCode, Decl(file.ts, 0, 8))
>A : Symbol(CharCode.A, Decl(cc.ts, 0, 28))
>input : Symbol(input, Decl(file.ts, 2, 11))
}
}

View file

@ -0,0 +1,30 @@
=== /proj/defs/cc.ts ===
export const enum CharCode {
>CharCode : CharCode
A,
>A : CharCode.A
B
>B : CharCode.B
}
=== /proj/component/file.ts ===
import { CharCode } from 'defs/cc';
>CharCode : typeof CharCode
export class User {
>User : User
method(input: number) {
>method : (input: number) => void
>input : number
if (CharCode.A === input) {}
>CharCode.A === input : boolean
>CharCode.A : CharCode.A
>CharCode : typeof CharCode
>A : CharCode.A
>input : number
}
}

View file

@ -0,0 +1,28 @@
//// [tests/cases/compiler/constEnumNoPreserveDeclarationReexport.ts] ////
//// [ConstEnum.d.ts]
export const enum MyConstEnum {
Foo,
Bar
}
//// [ImportExport.d.ts]
import { MyConstEnum } from './ConstEnum';
export default MyConstEnum;
//// [ReExport.d.ts]
export { MyConstEnum as default } from './ConstEnum';
//// [usages.ts]
import {MyConstEnum} from "./ConstEnum";
import AlsoEnum from "./ImportExport";
import StillEnum from "./ReExport";
MyConstEnum.Foo;
AlsoEnum.Foo;
StillEnum.Foo;
//// [usages.js]
"use strict";
exports.__esModule = true;
0 /* Foo */;
0 /* Foo */;
0 /* Foo */;

View file

@ -0,0 +1,47 @@
=== tests/cases/compiler/ConstEnum.d.ts ===
export const enum MyConstEnum {
>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.d.ts, 0, 0))
Foo,
>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31))
Bar
>Bar : Symbol(MyConstEnum.Bar, Decl(ConstEnum.d.ts, 1, 8))
}
=== tests/cases/compiler/ImportExport.d.ts ===
import { MyConstEnum } from './ConstEnum';
>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.d.ts, 0, 8))
export default MyConstEnum;
>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.d.ts, 0, 8))
=== tests/cases/compiler/ReExport.d.ts ===
export { MyConstEnum as default } from './ConstEnum';
>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.d.ts, 0, 0))
>default : Symbol(default, Decl(ReExport.d.ts, 0, 8))
=== tests/cases/compiler/usages.ts ===
import {MyConstEnum} from "./ConstEnum";
>MyConstEnum : Symbol(MyConstEnum, Decl(usages.ts, 0, 8))
import AlsoEnum from "./ImportExport";
>AlsoEnum : Symbol(AlsoEnum, Decl(usages.ts, 1, 6))
import StillEnum from "./ReExport";
>StillEnum : Symbol(StillEnum, Decl(usages.ts, 2, 6))
MyConstEnum.Foo;
>MyConstEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31))
>MyConstEnum : Symbol(MyConstEnum, Decl(usages.ts, 0, 8))
>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31))
AlsoEnum.Foo;
>AlsoEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31))
>AlsoEnum : Symbol(AlsoEnum, Decl(usages.ts, 1, 6))
>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31))
StillEnum.Foo;
>StillEnum.Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31))
>StillEnum : Symbol(StillEnum, Decl(usages.ts, 2, 6))
>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.d.ts, 0, 31))

View file

@ -0,0 +1,47 @@
=== tests/cases/compiler/ConstEnum.d.ts ===
export const enum MyConstEnum {
>MyConstEnum : MyConstEnum
Foo,
>Foo : MyConstEnum
Bar
>Bar : MyConstEnum
}
=== tests/cases/compiler/ImportExport.d.ts ===
import { MyConstEnum } from './ConstEnum';
>MyConstEnum : typeof MyConstEnum
export default MyConstEnum;
>MyConstEnum : MyConstEnum
=== tests/cases/compiler/ReExport.d.ts ===
export { MyConstEnum as default } from './ConstEnum';
>MyConstEnum : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum
>default : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum
=== tests/cases/compiler/usages.ts ===
import {MyConstEnum} from "./ConstEnum";
>MyConstEnum : typeof MyConstEnum
import AlsoEnum from "./ImportExport";
>AlsoEnum : typeof MyConstEnum
import StillEnum from "./ReExport";
>StillEnum : typeof MyConstEnum
MyConstEnum.Foo;
>MyConstEnum.Foo : MyConstEnum
>MyConstEnum : typeof MyConstEnum
>Foo : MyConstEnum
AlsoEnum.Foo;
>AlsoEnum.Foo : MyConstEnum
>AlsoEnum : typeof MyConstEnum
>Foo : MyConstEnum
StillEnum.Foo;
>StillEnum.Foo : MyConstEnum
>StillEnum : typeof MyConstEnum
>Foo : MyConstEnum

View file

@ -0,0 +1,32 @@
//// [tests/cases/compiler/constEnumPreserveEmitReexport.ts] ////
//// [ConstEnum.ts]
export const enum MyConstEnum {
Foo,
Bar
};
//// [ImportExport.ts]
import { MyConstEnum } from './ConstEnum';
export default MyConstEnum;
//// [ReExport.ts]
export { MyConstEnum as default } from './ConstEnum';
//// [ConstEnum.js]
"use strict";
exports.__esModule = true;
var MyConstEnum;
(function (MyConstEnum) {
MyConstEnum[MyConstEnum["Foo"] = 0] = "Foo";
MyConstEnum[MyConstEnum["Bar"] = 1] = "Bar";
})(MyConstEnum = exports.MyConstEnum || (exports.MyConstEnum = {}));
;
//// [ImportExport.js]
"use strict";
exports.__esModule = true;
var ConstEnum_1 = require("./ConstEnum");
exports["default"] = ConstEnum_1.MyConstEnum;
//// [ReExport.js]
"use strict";
exports.__esModule = true;
var ConstEnum_1 = require("./ConstEnum");
exports["default"] = ConstEnum_1.MyConstEnum;

View file

@ -0,0 +1,23 @@
=== tests/cases/compiler/ConstEnum.ts ===
export const enum MyConstEnum {
>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.ts, 0, 0))
Foo,
>Foo : Symbol(MyConstEnum.Foo, Decl(ConstEnum.ts, 0, 31))
Bar
>Bar : Symbol(MyConstEnum.Bar, Decl(ConstEnum.ts, 1, 8))
};
=== tests/cases/compiler/ImportExport.ts ===
import { MyConstEnum } from './ConstEnum';
>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.ts, 0, 8))
export default MyConstEnum;
>MyConstEnum : Symbol(MyConstEnum, Decl(ImportExport.ts, 0, 8))
=== tests/cases/compiler/ReExport.ts ===
export { MyConstEnum as default } from './ConstEnum';
>MyConstEnum : Symbol(MyConstEnum, Decl(ConstEnum.ts, 0, 0))
>default : Symbol(default, Decl(ReExport.ts, 0, 8))

View file

@ -0,0 +1,23 @@
=== tests/cases/compiler/ConstEnum.ts ===
export const enum MyConstEnum {
>MyConstEnum : MyConstEnum
Foo,
>Foo : MyConstEnum.Foo
Bar
>Bar : MyConstEnum.Bar
};
=== tests/cases/compiler/ImportExport.ts ===
import { MyConstEnum } from './ConstEnum';
>MyConstEnum : typeof MyConstEnum
export default MyConstEnum;
>MyConstEnum : MyConstEnum
=== tests/cases/compiler/ReExport.ts ===
export { MyConstEnum as default } from './ConstEnum';
>MyConstEnum : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum
>default : typeof import("tests/cases/compiler/ConstEnum").MyConstEnum

View file

@ -1,12 +1,9 @@
/a.d.ts(2,10): error TS2708: Cannot use namespace 'N' as a value.
/a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'.
==== /a.d.ts (2 errors) ====
==== /a.d.ts (1 errors) ====
declare global { namespace N {} }
export = N;
~
!!! error TS2708: Cannot use namespace 'N' as a value.
export as namespace N;
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2303: Circular definition of import alias 'N'.

View file

@ -0,0 +1,10 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
define(["require", "exports"], function (require, exports) {
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports._b = _a = [];
});

View file

@ -0,0 +1,10 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
define(["require", "exports"], function (require, exports) {
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
_a = [];
});

View file

@ -0,0 +1,8 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports._b = _a = [];

View file

@ -0,0 +1,8 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
_a = [];

View file

@ -0,0 +1,6 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
var _a;
export var _b = _a = [];

View file

@ -0,0 +1,5 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
export const [] = [];

View file

@ -0,0 +1,6 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
var _a;
export var _b = _a = [];

View file

@ -0,0 +1,5 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
export const [] = [];

View file

@ -0,0 +1,15 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _a, _b;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
exports_1("_b", _b = _a = []);
}
};
});

View file

@ -0,0 +1,15 @@
//// [exportEmptyArrayBindingPattern.ts]
export const [] = [];
//// [exportEmptyArrayBindingPattern.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _a;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
_a = [];
}
};
});

View file

@ -0,0 +1,10 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
define(["require", "exports"], function (require, exports) {
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports._b = _a = {};
});

View file

@ -0,0 +1,10 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
define(["require", "exports"], function (require, exports) {
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
_a = {};
});

View file

@ -0,0 +1,8 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports._b = _a = {};

View file

@ -0,0 +1,8 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
_a = {};

View file

@ -0,0 +1,6 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
var _a;
export var _b = _a = {};

View file

@ -0,0 +1,5 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
export const {} = {};

View file

@ -0,0 +1,6 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
var _a;
export var _b = _a = {};

View file

@ -0,0 +1,5 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
export const {} = {};

View file

@ -0,0 +1,15 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _a, _b;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
exports_1("_b", _b = _a = {});
}
};
});

View file

@ -0,0 +1,15 @@
//// [exportEmptyObjectBindingPattern.ts]
export const {} = {};
//// [exportEmptyObjectBindingPattern.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _a;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
_a = {};
}
};
});

View file

@ -0,0 +1,10 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
define(["require", "exports"], function (require, exports) {
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = (_a = { x: 'x', y: 'y' }, _a).x, exports.rest = __rest(_a, ["x"]);
});

View file

@ -0,0 +1,10 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
define(["require", "exports"], function (require, exports) {
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
_a = { x: 'x', y: 'y' }, exports.x = _a.x, exports.rest = __rest(_a, ["x"]);
});

View file

@ -0,0 +1,8 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = (_a = { x: 'x', y: 'y' }, _a).x, exports.rest = __rest(_a, ["x"]);

View file

@ -0,0 +1,8 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
_a = { x: 'x', y: 'y' }, exports.x = _a.x, exports.rest = __rest(_a, ["x"]);

View file

@ -0,0 +1,6 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
var _a;
export var x = (_a = { x: 'x', y: 'y' }, _a).x, rest = __rest(_a, ["x"]);

View file

@ -0,0 +1,5 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
export const { x, ...rest } = { x: 'x', y: 'y' };

View file

@ -0,0 +1,6 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
var _a;
export var x = (_a = { x: 'x', y: 'y' }, _a).x, rest = __rest(_a, ["x"]);

View file

@ -0,0 +1,5 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
export const { x, ...rest } = { x: 'x', y: 'y' };

View file

@ -0,0 +1,15 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _a, x, rest;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
exports_1("x", x = (_a = { x: 'x', y: 'y' }, _a).x), exports_1("rest", rest = __rest(_a, ["x"]));
}
};
});

View file

@ -0,0 +1,15 @@
//// [exportObjectRest.ts]
export const { x, ...rest } = { x: 'x', y: 'y' };
//// [exportObjectRest.js]
System.register([], function (exports_1, context_1) {
"use strict";
var _a, x, rest;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
_a = { x: 'x', y: 'y' }, exports_1("x", x = _a.x), exports_1("rest", rest = __rest(_a, ["x"]));
}
};
});

View file

@ -0,0 +1,40 @@
tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ====
var v = 1;
function f() { }
class C {
}
interface I {
}
enum E {
A, B, C
}
const enum D {
A, B, C
}
module M {
export var x;
}
module N {
export interface I {
}
}
type T = number;
import a = M.x;
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ====
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.

View file

@ -0,0 +1,40 @@
tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ====
var v = 1;
function f() { }
class C {
}
interface I {
}
enum E {
A, B, C
}
const enum D {
A, B, C
}
module M {
export var x;
}
module N {
export interface I {
}
}
type T = number;
import a = M.x;
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ====
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.

View file

@ -0,0 +1,40 @@
tests/cases/conformance/es6/modules/t1.ts(23,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ====
var v = 1;
function f() { }
class C {
}
interface I {
}
enum E {
A, B, C
}
const enum D {
A, B, C
}
module M {
export var x;
}
module N {
export interface I {
}
}
type T = number;
import a = M.x;
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ====
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.

View file

@ -0,0 +1,40 @@
tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ====
export var v = 1;
export function f() { }
export class C {
}
export interface I {
}
export enum E {
A, B, C
}
export const enum D {
A, B, C
}
export module M {
export var x;
}
export module N {
export interface I {
}
}
export type T = number;
export import a = M.x;
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ====
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.

View file

@ -0,0 +1,40 @@
tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ====
export var v = 1;
export function f() { }
export class C {
}
export interface I {
}
export enum E {
A, B, C
}
export const enum D {
A, B, C
}
export module M {
export var x;
}
export module N {
export interface I {
}
}
export type T = number;
export import a = M.x;
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ====
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.

View file

@ -0,0 +1,40 @@
tests/cases/conformance/es6/modules/t1.ts(23,55): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
tests/cases/conformance/es6/modules/t3.ts(2,25): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t1.ts (1 errors) ====
export var v = 1;
export function f() { }
export class C {
}
export interface I {
}
export enum E {
A, B, C
}
export const enum D {
A, B, C
}
export module M {
export var x;
}
export module N {
export interface I {
}
}
export type T = number;
export import a = M.x;
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ====
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
export { v, f, C, I, E, D, M, N, T, a };
~
!!! error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.

View file

@ -5,10 +5,10 @@ function* g(): IterableIterator<(x: string) => number> {
yield * {
>yield * { *[Symbol.iterator]() { yield x => x.length; } } : void
>{ *[Symbol.iterator]() { yield x => x.length; } } : { [Symbol.iterator](): Generator<(x: string) => number, void, unknown>; }
>{ *[Symbol.iterator]() { yield x => x.length; } } : { [Symbol.iterator](): Generator<(x: string) => number, void, undefined>; }
*[Symbol.iterator]() {
>[Symbol.iterator] : () => Generator<(x: string) => number, void, unknown>
>[Symbol.iterator] : () => Generator<(x: string) => number, void, undefined>
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol

View file

@ -11,7 +11,7 @@ foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, sh
>foo("", function* () { yield x => x.length }, p => undefined) : string
>foo : <T, U>(x: T, fun: () => Iterator<(x: T) => U, any, undefined>, fun2: (y: U) => T) => T
>"" : ""
>function* () { yield x => x.length } : () => Generator<(x: string) => number, void, unknown>
>function* () { yield x => x.length } : () => Generator<(x: string) => number, void, undefined>
>yield x => x.length : undefined
>x => x.length : (x: string) => number
>x : string

View file

@ -11,14 +11,14 @@ foo("", function* () {
>foo("", function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }}, p => undefined) : string
>foo : <T, U>(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T) => T
>"" : ""
>function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => Generator<(x: string) => number, void, unknown>
>function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => Generator<(x: string) => number, void, undefined>
yield* {
>yield* { *[Symbol.iterator]() { yield x => x.length } } : void
>{ *[Symbol.iterator]() { yield x => x.length } } : { [Symbol.iterator](): Generator<(x: string) => number, void, unknown>; }
>{ *[Symbol.iterator]() { yield x => x.length } } : { [Symbol.iterator](): Generator<(x: string) => number, void, undefined>; }
*[Symbol.iterator]() {
>[Symbol.iterator] : () => Generator<(x: string) => number, void, unknown>
>[Symbol.iterator] : () => Generator<(x: string) => number, void, undefined>
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol

View file

@ -12,7 +12,7 @@ export function strategy<T extends StrategicState>(stratName: string, gen: (a: T
>a : T
return function*(state) {
>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator<T, void, unknown>
>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator<T, void, undefined>
>state : T
for (const next of gen(state)) {
@ -53,7 +53,7 @@ export const Nothing1: Strategy<State> = strategy("Nothing", function*(state: St
>strategy("Nothing", function*(state: State) { return state;}) : (a: State) => IterableIterator<State>
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
>"Nothing" : "Nothing"
>function*(state: State) { return state;} : (state: State) => Generator<never, State, unknown>
>function*(state: State) { return state;} : (state: State) => Generator<never, State, undefined>
>state : State
return state;
@ -66,7 +66,7 @@ export const Nothing2: Strategy<State> = strategy("Nothing", function*(state: St
>strategy("Nothing", function*(state: State) { yield state;}) : (a: State) => IterableIterator<State>
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
>"Nothing" : "Nothing"
>function*(state: State) { yield state;} : (state: State) => Generator<State, void, unknown>
>function*(state: State) { yield state;} : (state: State) => Generator<State, void, undefined>
>state : State
yield state;
@ -80,7 +80,7 @@ export const Nothing3: Strategy<State> = strategy("Nothing", function* (state: S
>strategy("Nothing", function* (state: State) { yield ; return state;}) : (a: any) => IterableIterator<any>
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
>"Nothing" : "Nothing"
>function* (state: State) { yield ; return state;} : (state: State) => Generator<any, State, unknown>
>function* (state: State) { yield ; return state;} : (state: State) => Generator<any, State, undefined>
>state : State
yield ;

View file

@ -1,7 +1,7 @@
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => Generator<number, State, unknown>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
Type 'Generator<number, State, unknown>' is not assignable to type 'IterableIterator<State>'.
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => Generator<number, State, undefined>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
Type 'Generator<number, State, undefined>' is not assignable to type 'IterableIterator<State>'.
Types of property 'next' are incompatible.
Type '(...args: [] | [unknown]) => IteratorResult<number, State>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<State, any>'.
Type '(...args: [] | [undefined]) => IteratorResult<number, State>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<State, any>'.
Type 'IteratorResult<number, State>' is not assignable to type 'IteratorResult<State, any>'.
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<State, any>'.
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<State>'.
@ -34,10 +34,10 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): err
export const Nothing: Strategy<State> = strategy("Nothing", function* (state: State) {
~~~~~~~~
!!! error TS2345: Argument of type '(state: State) => Generator<number, State, unknown>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
!!! error TS2345: Type 'Generator<number, State, unknown>' is not assignable to type 'IterableIterator<State>'.
!!! error TS2345: Argument of type '(state: State) => Generator<number, State, undefined>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
!!! error TS2345: Type 'Generator<number, State, undefined>' is not assignable to type 'IterableIterator<State>'.
!!! error TS2345: Types of property 'next' are incompatible.
!!! error TS2345: Type '(...args: [] | [unknown]) => IteratorResult<number, State>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<State, any>'.
!!! error TS2345: Type '(...args: [] | [undefined]) => IteratorResult<number, State>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<State, any>'.
!!! error TS2345: Type 'IteratorResult<number, State>' is not assignable to type 'IteratorResult<State, any>'.
!!! error TS2345: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<State, any>'.
!!! error TS2345: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<State>'.

View file

@ -12,7 +12,7 @@ export function strategy<T extends StrategicState>(stratName: string, gen: (a: T
>a : T
return function*(state) {
>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator<T, void, unknown>
>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator<T, void, undefined>
>state : T
for (const next of gen(state)) {
@ -53,7 +53,7 @@ export const Nothing: Strategy<State> = strategy("Nothing", function* (state: St
>strategy("Nothing", function* (state: State) { yield 1; return state;}) : any
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
>"Nothing" : "Nothing"
>function* (state: State) { yield 1; return state;} : (state: State) => Generator<number, State, unknown>
>function* (state: State) { yield 1; return state;} : (state: State) => Generator<number, State, undefined>
>state : State
yield 1;
@ -70,7 +70,7 @@ export const Nothing1: Strategy<State> = strategy("Nothing", function* (state: S
>strategy("Nothing", function* (state: State) {}) : (a: State) => IterableIterator<State>
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
>"Nothing" : "Nothing"
>function* (state: State) {} : (state: State) => Generator<never, void, unknown>
>function* (state: State) {} : (state: State) => Generator<never, void, undefined>
>state : State
});
@ -80,7 +80,7 @@ export const Nothing2: Strategy<State> = strategy("Nothing", function* (state: S
>strategy("Nothing", function* (state: State) { return 1;}) : (a: State) => IterableIterator<State>
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
>"Nothing" : "Nothing"
>function* (state: State) { return 1;} : (state: State) => Generator<never, number, unknown>
>function* (state: State) { return 1;} : (state: State) => Generator<never, number, undefined>
>state : State
return 1;
@ -93,7 +93,7 @@ export const Nothing3: Strategy<State> = strategy("Nothing", function* (state: S
>strategy("Nothing", function* (state: State) { yield state; return 1;}) : (a: State) => IterableIterator<State>
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
>"Nothing" : "Nothing"
>function* (state: State) { yield state; return 1;} : (state: State) => Generator<State, number, unknown>
>function* (state: State) { yield state; return 1;} : (state: State) => Generator<State, number, undefined>
>state : State
yield state;

View file

@ -6,7 +6,7 @@ declare function f1<T, R, S>(gen: () => Generator<R, T, S>): void;
f1<0, 0, 1>(function* () {
>f1<0, 0, 1>(function* () { const a = yield 0; return 0;}) : void
>f1 : <T, R, S>(gen: () => Generator<R, T, S>) => void
>function* () { const a = yield 0; return 0;} : () => Generator<0, 0, unknown>
>function* () { const a = yield 0; return 0;} : () => Generator<0, 0, 1>
const a = yield 0;
>a : 1
@ -25,7 +25,7 @@ declare function f2<T, R, S>(gen: () => Generator<R, T, S> | AsyncGenerator<R, T
f2<0, 0, 1>(async function* () {
>f2<0, 0, 1>(async function* () { const a = yield 0; return 0;}) : void
>f2 : <T, R, S>(gen: () => Generator<R, T, S> | AsyncGenerator<R, T, S>) => void
>async function* () { const a = yield 0; return 0;} : () => AsyncGenerator<0, 0, unknown>
>async function* () { const a = yield 0; return 0;} : () => AsyncGenerator<0, 0, 1>
const a = yield 0;
>a : 1

View file

@ -0,0 +1,20 @@
{
"compilerOptions": {
"esModuleInterop": true,
"target": "es5",
"module": "commonjs",
"strict": true
},
"references": [
{
"path": "./test"
}
],
"include": [
"src/*"
],
"exclude": [
"dist"
],
"compileOnSave": true
}

View file

@ -75,7 +75,7 @@ async function * inferReturnType8() {
}
const assignability1: () => AsyncIterableIterator<number> = async function * () {
>assignability1 : () => AsyncIterableIterator<number>
>async function * () { yield 1;} : () => AsyncGenerator<number, void, unknown>
>async function * () { yield 1;} : () => AsyncGenerator<number, void, undefined>
yield 1;
>yield 1 : undefined
@ -84,7 +84,7 @@ const assignability1: () => AsyncIterableIterator<number> = async function * ()
};
const assignability2: () => AsyncIterableIterator<number> = async function * () {
>assignability2 : () => AsyncIterableIterator<number>
>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator<number, void, unknown>
>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator<number, void, undefined>
yield Promise.resolve(1);
>yield Promise.resolve(1) : undefined
@ -135,7 +135,7 @@ const assignability5: () => AsyncIterableIterator<number> = async function * ()
};
const assignability6: () => AsyncIterable<number> = async function * () {
>assignability6 : () => AsyncIterable<number>
>async function * () { yield 1;} : () => AsyncGenerator<number, void, unknown>
>async function * () { yield 1;} : () => AsyncGenerator<number, void, undefined>
yield 1;
>yield 1 : undefined
@ -144,7 +144,7 @@ const assignability6: () => AsyncIterable<number> = async function * () {
};
const assignability7: () => AsyncIterable<number> = async function * () {
>assignability7 : () => AsyncIterable<number>
>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator<number, void, unknown>
>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator<number, void, undefined>
yield Promise.resolve(1);
>yield Promise.resolve(1) : undefined
@ -195,7 +195,7 @@ const assignability10: () => AsyncIterable<number> = async function * () {
};
const assignability11: () => AsyncIterator<number> = async function * () {
>assignability11 : () => AsyncIterator<number, any, undefined>
>async function * () { yield 1;} : () => AsyncGenerator<number, void, unknown>
>async function * () { yield 1;} : () => AsyncGenerator<number, void, undefined>
yield 1;
>yield 1 : undefined
@ -204,7 +204,7 @@ const assignability11: () => AsyncIterator<number> = async function * () {
};
const assignability12: () => AsyncIterator<number> = async function * () {
>assignability12 : () => AsyncIterator<number, any, undefined>
>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator<number, void, unknown>
>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator<number, void, undefined>
yield Promise.resolve(1);
>yield Promise.resolve(1) : undefined

View file

@ -1,9 +1,9 @@
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(2,12): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(8,12): error TS2504: Type 'Promise<number[]>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterableIterator<number>'.
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterableIterator<number>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterableIterator<number>'.
Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterableIterator<number>'.
Types of property 'next' are incompatible.
Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
Type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
Type 'IteratorResult<string, void>' is not assignable to type 'IteratorResult<number, any>'.
Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorResult<number, any>'.
@ -11,20 +11,12 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(13,7): error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterableIterator<number>'.
Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterableIterator<number>'.
Types of property 'next' are incompatible.
Type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(16,7): error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterableIterator<number>'.
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterableIterator<number>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterable<number>'.
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterable<number>'.
Types of property '[Symbol.asyncIterator]' are incompatible.
Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
Types of property 'next' are incompatible.
Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterable<number>'.
Types of property 'next' are incompatible.
Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterable<number>'.
Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterable<number>'.
Types of property '[Symbol.asyncIterator]' are incompatible.
Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
@ -32,10 +24,18 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(
Types of property 'next' are incompatible.
Type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterable<number>'.
Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterable<number>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(25,7): error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterable<number>'.
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterable<number>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
Types of property '[Symbol.asyncIterator]' are incompatible.
Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
Types of property 'next' are incompatible.
Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(31,7): error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(34,7): error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
@ -76,10 +76,10 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(
}
const assignability1: () => AsyncIterableIterator<number> = async function * () {
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterableIterator<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterableIterator<number>'.
!!! error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterableIterator<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterableIterator<number>'.
!!! error TS2322: Types of property 'next' are incompatible.
!!! error TS2322: Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type 'IteratorResult<string, void>' is not assignable to type 'IteratorResult<number, any>'.
!!! error TS2322: Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorResult<number, any>'.
@ -91,31 +91,19 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterableIterator<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterableIterator<number>'.
!!! error TS2322: Types of property 'next' are incompatible.
!!! error TS2322: Type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
yield* ["a", "b"];
};
const assignability3: () => AsyncIterableIterator<number> = async function * () {
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterableIterator<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterableIterator<number>'.
!!! error TS2322: Types of property 'next' are incompatible.
!!! error TS2322: Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
yield* (async function * () { yield "a"; })();
};
const assignability4: () => AsyncIterable<number> = async function * () {
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterable<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterable<number>'.
!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible.
!!! error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
!!! error TS2322: Types of property 'next' are incompatible.
!!! error TS2322: Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
yield "a";
};
const assignability5: () => AsyncIterable<number> = async function * () {
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterable<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterable<number>'.
!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible.
@ -124,18 +112,30 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(
!!! error TS2322: Types of property 'next' are incompatible.
!!! error TS2322: Type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
yield "a";
};
const assignability5: () => AsyncIterable<number> = async function * () {
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterable<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterable<number>'.
yield* ["a", "b"];
};
const assignability6: () => AsyncIterable<number> = async function * () {
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterable<number>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterable<number>'.
!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible.
!!! error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
!!! error TS2322: Types of property 'next' are incompatible.
!!! error TS2322: Type '(...args: [] | [unknown]) => Promise<IteratorResult<string, void>>' is not assignable to type '(...args: [] | [PromiseLike<undefined>]) => Promise<IteratorResult<number, any>>'.
!!! error TS2322: Type 'Promise<IteratorResult<string, void>>' is not assignable to type 'Promise<IteratorResult<number, any>>'.
yield* (async function * () { yield "a"; })();
};
const assignability7: () => AsyncIterator<number> = async function * () {
~~~~~~~~~~~~~~
!!! error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
!!! error TS2322: Type '() => AsyncGenerator<string, void, undefined>' is not assignable to type '() => AsyncIterator<number, any, undefined>'.
!!! error TS2322: Type 'AsyncGenerator<string, void, undefined>' is not assignable to type 'AsyncIterator<number, any, undefined>'.
yield "a";
};
const assignability8: () => AsyncIterator<number> = async function * () {

View file

@ -29,7 +29,7 @@ async function * inferReturnType3() {
}
const assignability1: () => AsyncIterableIterator<number> = async function * () {
>assignability1 : () => AsyncIterableIterator<number>
>async function * () { yield "a";} : () => AsyncGenerator<string, void, unknown>
>async function * () { yield "a";} : () => AsyncGenerator<string, void, undefined>
yield "a";
>yield "a" : undefined
@ -62,7 +62,7 @@ const assignability3: () => AsyncIterableIterator<number> = async function * ()
};
const assignability4: () => AsyncIterable<number> = async function * () {
>assignability4 : () => AsyncIterable<number>
>async function * () { yield "a";} : () => AsyncGenerator<string, void, unknown>
>async function * () { yield "a";} : () => AsyncGenerator<string, void, undefined>
yield "a";
>yield "a" : undefined
@ -95,7 +95,7 @@ const assignability6: () => AsyncIterable<number> = async function * () {
};
const assignability7: () => AsyncIterator<number> = async function * () {
>assignability7 : () => AsyncIterator<number, any, undefined>
>async function * () { yield "a";} : () => AsyncGenerator<string, void, unknown>
>async function * () { yield "a";} : () => AsyncGenerator<string, void, undefined>
yield "a";
>yield "a" : undefined

View file

@ -819,7 +819,7 @@ interface Context {
const o3: Context = {
>o3 : Context
>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise<unique symbol>; method3(): AsyncGenerator<unique symbol, void, unknown>; method4(): Generator<unique symbol, void, unknown>; method5(p?: unique symbol): unique symbol; }
>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise<unique symbol>; method3(): AsyncGenerator<unique symbol, void, undefined>; method4(): Generator<unique symbol, void, undefined>; method5(p?: unique symbol): unique symbol; }
method1() {
>method1 : () => unique symbol
@ -836,7 +836,7 @@ const o3: Context = {
},
async * method3() {
>method3 : () => AsyncGenerator<unique symbol, void, unknown>
>method3 : () => AsyncGenerator<unique symbol, void, undefined>
yield s; // yield type should not widen due to contextual type
>yield s : undefined
@ -844,7 +844,7 @@ const o3: Context = {
},
* method4() {
>method4 : () => Generator<unique symbol, void, unknown>
>method4 : () => Generator<unique symbol, void, undefined>
yield s; // yield type should not widen due to contextual type
>yield s : undefined

View file

@ -812,7 +812,7 @@ interface Context {
const o4: Context = {
>o4 : Context
>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise<unique symbol>; method3(): AsyncGenerator<unique symbol, void, unknown>; method4(): Generator<unique symbol, void, unknown>; method5(p?: unique symbol): unique symbol; }
>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise<unique symbol>; method3(): AsyncGenerator<unique symbol, void, undefined>; method4(): Generator<unique symbol, void, undefined>; method5(p?: unique symbol): unique symbol; }
method1() {
>method1 : () => unique symbol
@ -829,7 +829,7 @@ const o4: Context = {
},
async * method3() {
>method3 : () => AsyncGenerator<unique symbol, void, unknown>
>method3 : () => AsyncGenerator<unique symbol, void, undefined>
yield s; // yield type should not widen due to contextual type
>yield s : undefined
@ -837,7 +837,7 @@ const o4: Context = {
},
* method4() {
>method4 : () => Generator<unique symbol, void, unknown>
>method4 : () => Generator<unique symbol, void, undefined>
yield s; // yield type should not widen due to contextual type
>yield s : undefined

View file

@ -0,0 +1,16 @@
// @module: amd
// @preserveConstEnums: true
// @baseUrl: /proj
// @filename: /proj/defs/cc.ts
export const enum CharCode {
A,
B
}
// @filename: /proj/component/file.ts
import { CharCode } from 'defs/cc';
export class User {
method(input: number) {
if (CharCode.A === input) {}
}
}

View file

@ -0,0 +1,18 @@
// @filename: ConstEnum.d.ts
export const enum MyConstEnum {
Foo,
Bar
}
// @filename: ImportExport.d.ts
import { MyConstEnum } from './ConstEnum';
export default MyConstEnum;
// @filename: ReExport.d.ts
export { MyConstEnum as default } from './ConstEnum';
// @filename: usages.ts
import {MyConstEnum} from "./ConstEnum";
import AlsoEnum from "./ImportExport";
import StillEnum from "./ReExport";
MyConstEnum.Foo;
AlsoEnum.Foo;
StillEnum.Foo;

View file

@ -0,0 +1,11 @@
// @preserveConstEnums: true
// @filename: ConstEnum.ts
export const enum MyConstEnum {
Foo,
Bar
};
// @filename: ImportExport.ts
import { MyConstEnum } from './ConstEnum';
export default MyConstEnum;
// @filename: ReExport.ts
export { MyConstEnum as default } from './ConstEnum';

View file

@ -0,0 +1,5 @@
// @module: commonjs,amd,system,es2015,esnext
// @target: esnext,es5
// @noEmitHelpers: true
// @noTypesAndSymbols: true
export const [] = [];

View file

@ -0,0 +1,5 @@
// @module: commonjs,amd,system,es2015,esnext
// @target: esnext,es5
// @noEmitHelpers: true
// @noTypesAndSymbols: true
export const {} = {};

View file

@ -0,0 +1,5 @@
// @module: commonjs,amd,system,es2015,esnext
// @target: esnext,es5
// @noEmitHelpers: true
// @noTypesAndSymbols: true
export const { x, ...rest } = { x: 'x', y: 'y' };

View file

@ -0,0 +1,16 @@
/// <reference path='fourslash.ts' />
////function /*a*/insert/*b*/(template: string, overwriteBefore = 0) {}
////insert(`this is \${not} a substitution`);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: [
'function insert({ template, overwriteBefore = 0 }: { template: string; overwriteBefore?: number; }) {}',
'insert({ template: `this is \\${not} a substitution` });'
].join('\n')
});