Merge branch 'master' into asyncGenerators

This commit is contained in:
Ron Buckton 2016-11-18 10:32:54 -08:00
commit 1c0917abef
169 changed files with 1527 additions and 274 deletions

View File

@ -2,7 +2,7 @@
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
**TypeScript Version:** 2.0.3 / nightly (2.1.0-dev.201xxxxx)
**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx)
**Code**
@ -13,4 +13,4 @@
**Expected behavior:**
**Actual behavior:**
**Actual behavior:**

View File

@ -106,10 +106,10 @@ namespace ts {
getEmitResolver,
getExportsOfModule: getExportsOfModuleAsArray,
getAmbientModules,
getJsxElementAttributesType,
getJsxIntrinsicTagNames,
isOptionalParameter,
tryGetMemberInModuleExports,
tryFindAmbientModuleWithoutAugmentations: moduleName => {
// we deliberately exclude augmentations
// since we are only interested in declarations of the module itself
@ -1474,6 +1474,13 @@ namespace ts {
return symbolsToArray(getExportsOfModule(moduleSymbol));
}
function tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined {
const symbolTable = getExportsOfModule(moduleSymbol);
if (symbolTable) {
return symbolTable[memberName];
}
}
function getExportsOfSymbol(symbol: Symbol): SymbolTable {
return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols;
}
@ -14849,7 +14856,7 @@ namespace ts {
function checkDeclarationInitializer(declaration: VariableLikeDeclaration) {
const type = checkExpressionCached(declaration.initializer);
return getCombinedNodeFlags(declaration) & NodeFlags.Const ||
getCombinedModifierFlags(declaration) & ModifierFlags.Readonly ||
getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) ||
isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type);
}

View File

@ -884,7 +884,7 @@ namespace ts {
function tryExtendsName(extendedConfig: string): [string[], string[], string[], CompilerOptions] {
// If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future)
if (!(isRootedDiskPath(extendedConfig) || startsWith(normalizeSlashes(extendedConfig), "./") || startsWith(normalizeSlashes(extendedConfig), "../"))) {
errors.push(createCompilerDiagnostic(Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted));
errors.push(createCompilerDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig));
return;
}
let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName);

View File

@ -1391,6 +1391,14 @@ namespace ts {
getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
}
export function getEmitModuleResolutionKind(compilerOptions: CompilerOptions) {
let moduleResolution = compilerOptions.moduleResolution;
if (moduleResolution === undefined) {
moduleResolution = getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
}
return moduleResolution;
}
/* @internal */
export function hasZeroOrOneAsteriskCharacter(str: string): boolean {
let seenAsterisk = false;

View File

@ -3174,7 +3174,7 @@
"category": "Error",
"code": 18000
},
"The path in an 'extends' options must be relative or rooted.": {
"A path in an 'extends' option must be relative or rooted, but '{0}' is not.": {
"category": "Error",
"code": 18001
},
@ -3222,5 +3222,17 @@
"Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated.": {
"category": "Error",
"code": 90010
},
"Import {0} from {1}": {
"category": "Message",
"code": 90013
},
"Change {0} to {1}": {
"category": "Message",
"code": 90014
},
"Add {0} to existing import declaration from {1}": {
"category": "Message",
"code": 90015
}
}

View File

@ -61,7 +61,7 @@ namespace ts {
return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations };
}
function moduleHasNonRelativeName(moduleName: string): boolean {
export function moduleHasNonRelativeName(moduleName: string): boolean {
return !(isRootedDiskPath(moduleName) || isExternalModuleNameRelative(moduleName));
}

View File

@ -1309,7 +1309,9 @@ namespace ts {
createAssignment(
createElementAccess(
expressionName,
createSubtract(temp, createLiteral(restIndex))
restIndex === 0
? temp
: createSubtract(temp, createLiteral(restIndex))
),
createElementAccess(createIdentifier("arguments"), temp)
),

View File

@ -400,9 +400,6 @@ namespace ts {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};`

View File

@ -2375,6 +2375,8 @@ namespace ts {
isOptionalParameter(node: ParameterDeclaration): boolean;
getAmbientModules(): Symbol[];
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
// Should not be called directly. Should only be accessed through the Program instance.
@ -3203,7 +3205,7 @@ namespace ts {
target?: ScriptTarget;
traceResolution?: boolean;
types?: string[];
/** Paths used to used to compute primary types search locations */
/** Paths used to compute primary types search locations */
typeRoots?: string[];
/*@internal*/ version?: boolean;
/*@internal*/ watch?: boolean;

View File

@ -4561,7 +4561,7 @@ namespace ts {
}
}
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
export function isParameterPropertyDeclaration(node: Node): boolean {
return hasModifier(node, ModifierFlags.ParameterPropertyModifier) && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
}

View File

@ -2046,6 +2046,34 @@ namespace FourSlash {
}
}
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
const ranges = this.getRanges();
if (ranges.length == 0) {
this.raiseError("At least one range should be specified in the testfile.");
}
const codeFixes = this.getCodeFixes(errorCode);
if (!codeFixes || codeFixes.length == 0) {
this.raiseError("No codefixes returned.");
}
const actualTextArray: string[] = [];
const scriptInfo = this.languageServiceAdapterHost.getScriptInfo(codeFixes[0].changes[0].fileName);
const originalContent = scriptInfo.content;
for (const codeFix of codeFixes) {
this.applyEdits(codeFix.changes[0].fileName, codeFix.changes[0].textChanges, /*isFormattingEdit*/ false);
actualTextArray.push(this.normalizeNewlines(this.rangeText(ranges[0])));
scriptInfo.updateContent(originalContent);
}
const sortedExpectedArray = ts.map(expectedTextArray, str => this.normalizeNewlines(str)).sort();
const sortedActualArray = actualTextArray.sort();
if (!ts.arrayIsEqualTo(sortedExpectedArray, sortedActualArray)) {
this.raiseError(
`Actual text array doesn't match expected text array. \nActual: \n"${sortedActualArray.join("\n\n")}"\n---\nExpected: \n'${sortedExpectedArray.join("\n\n")}'`);
}
}
public verifyDocCommentTemplate(expected?: ts.TextInsertion) {
const name = "verifyDocCommentTemplate";
const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition);
@ -2079,6 +2107,10 @@ namespace FourSlash {
});
}
private normalizeNewlines(str: string) {
return str.replace(/\r?\n/g, "\n");
}
public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) {
const openBraceMap = ts.createMap<ts.CharacterCodes>({
@ -2606,7 +2638,7 @@ ${code}
resetLocalData();
}
currentFileName = basePath + "/" + value;
currentFileName = ts.isRootedDiskPath(value) ? value : basePath + "/" + value;
currentFileOptions[key] = value;
}
else {
@ -3303,6 +3335,10 @@ namespace FourSlashInterface {
this.state.verifyCodeFixAtPosition(expectedText, errorCode);
}
public importFixAtPosition(expectedTextArray: string[], errorCode?: number): void {
this.state.verifyImportFixAtPosition(expectedTextArray, errorCode);
}
public navigationBar(json: any) {
this.state.verifyNavigationBar(json);
}

View File

@ -179,7 +179,7 @@ namespace ts {
testFailure("can error when 'extends' is neither relative nor rooted.", "extends2.json", [{
code: 18001,
category: DiagnosticCategory.Error,
messageText: `The path in an 'extends' options must be relative or rooted.`
messageText: `A path in an 'extends' option must be relative or rooted, but 'configs/base' is not.`
}]);
});
});

View File

@ -1614,6 +1614,7 @@ namespace ts.projectSystem {
return;
}
assert.equal(e.eventName, server.ProjectLanguageServiceStateEvent);
assert.equal(e.data.project.getProjectName(), config.path, "project name");
lastEvent = <server.ProjectLanguageServiceStateEvent>e;
});
session.executeCommand(<protocol.OpenRequest>{
@ -1628,6 +1629,7 @@ namespace ts.projectSystem {
assert.isFalse(project.languageServiceEnabled, "Language service enabled");
assert.isTrue(!!lastEvent, "should receive event");
assert.equal(lastEvent.data.project, project, "project name");
assert.equal(lastEvent.data.project.getProjectName(), config.path, "config path");
assert.isFalse(lastEvent.data.languageServiceEnabled, "Language service state");
host.reloadFS([f1, f2, configWithExclude]);

View File

@ -205,13 +205,13 @@ interface NumberConstructor {
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
*/
isFinite(value: any): value is number;
isFinite(number: number): boolean;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param number A numeric value.
*/
isInteger(value: any): value is number;
isInteger(number: number): boolean;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
@ -219,13 +219,13 @@ interface NumberConstructor {
* to a number. Only values of the type number, that are also NaN, result in true.
* @param number A numeric value.
*/
isNaN(value: any): value is number;
isNaN(number: number): boolean;
/**
* Returns true if the value passed is a safe integer.
* @param number A numeric value.
*/
isSafeInteger(value: any): value is number;
isSafeInteger(number: number): boolean;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as

View File

@ -470,7 +470,7 @@ namespace ts.server {
private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) {
this.logger.info(`Type root file ${fileName} changed`);
this.throttledOperations.schedule(project.configFileName + " * type root", /*delay*/ 250, () => {
this.throttledOperations.schedule(project.getConfigFilePath() + " * type root", /*delay*/ 250, () => {
project.updateTypes();
this.updateConfiguredProject(project); // TODO: Figure out why this is needed (should be redundant?)
this.refreshInferredProjects();
@ -492,13 +492,13 @@ namespace ts.server {
this.logger.info(`Detected source file changes: ${fileName}`);
this.throttledOperations.schedule(
project.configFileName,
project.getConfigFilePath(),
/*delay*/250,
() => this.handleChangeInSourceFileForConfiguredProject(project, fileName));
}
private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject, triggerFile: string) {
const { projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.configFileName);
const { projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath());
this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile);
const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
@ -520,7 +520,7 @@ namespace ts.server {
}
private onConfigChangedForConfiguredProject(project: ConfiguredProject) {
this.logger.info(`Config file changed: ${project.configFileName}`);
this.logger.info(`Config file changed: ${project.getConfigFilePath()}`);
this.updateConfiguredProject(project);
this.refreshInferredProjects();
}
@ -1009,13 +1009,13 @@ namespace ts.server {
}
private updateConfiguredProject(project: ConfiguredProject) {
if (!this.host.fileExists(project.configFileName)) {
if (!this.host.fileExists(project.getConfigFilePath())) {
this.logger.info("Config file deleted");
this.removeProject(project);
return;
}
const { success, projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.configFileName);
const { success, projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath());
if (!success) {
// reset project settings to default
this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, /*compileOnSave*/false, configFileErrors);

View File

@ -229,6 +229,7 @@ namespace ts.server {
}
constructor(
private readonly projectName: string,
readonly projectKind: ProjectKind,
readonly projectService: ProjectService,
private documentRegistry: ts.DocumentRegistry,
@ -307,7 +308,9 @@ namespace ts.server {
this.projectService.onUpdateLanguageServiceStateForProject(this, /*languageServiceEnabled*/ false);
}
abstract getProjectName(): string;
getProjectName() {
return this.projectName;
}
abstract getProjectRootPath(): string | undefined;
abstract getTypingOptions(): TypingOptions;
@ -759,31 +762,27 @@ namespace ts.server {
export class InferredProject extends Project {
private static NextId = 1;
/**
* Unique name that identifies this particular inferred project
*/
private readonly inferredProjectName: string;
private static newName = (() => {
let nextId = 1;
return () => {
const id = nextId;
nextId++;
return makeInferredProjectName(id);
}
})();
// Used to keep track of what directories are watched for this project
directoriesWatchedForTsconfig: string[] = [];
constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions) {
super(ProjectKind.Inferred,
super(InferredProject.newName(),
ProjectKind.Inferred,
projectService,
documentRegistry,
/*files*/ undefined,
/*languageServiceEnabled*/ true,
compilerOptions,
/*compileOnSaveEnabled*/ false);
this.inferredProjectName = makeInferredProjectName(InferredProject.NextId);
InferredProject.NextId++;
}
getProjectName() {
return this.inferredProjectName;
}
getProjectRootPath() {
@ -822,7 +821,7 @@ namespace ts.server {
/** Used for configured projects which may have multiple open roots */
openRefCount = 0;
constructor(readonly configFileName: NormalizedPath,
constructor(configFileName: NormalizedPath,
projectService: ProjectService,
documentRegistry: ts.DocumentRegistry,
hasExplicitListOfFiles: boolean,
@ -830,11 +829,15 @@ namespace ts.server {
private wildcardDirectories: Map<WatchDirectoryFlags>,
languageServiceEnabled: boolean,
public compileOnSaveEnabled: boolean) {
super(ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
super(configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
}
getConfigFilePath() {
return this.getProjectName();
}
getProjectRootPath() {
return getDirectoryPath(this.configFileName);
return getDirectoryPath(this.getConfigFilePath());
}
setProjectErrors(projectErrors: Diagnostic[]) {
@ -849,12 +852,8 @@ namespace ts.server {
return this.typingOptions;
}
getProjectName() {
return this.configFileName;
}
watchConfigFile(callback: (project: ConfiguredProject) => void) {
this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, _ => callback(this));
this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), _ => callback(this));
}
watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void) {
@ -872,7 +871,7 @@ namespace ts.server {
return;
}
const directoryToWatch = getDirectoryPath(this.configFileName);
const directoryToWatch = getDirectoryPath(this.getConfigFilePath());
this.projectService.logger.info(`Add recursive watcher for: ${directoryToWatch}`);
this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, path => callback(this, path), /*recursive*/ true);
}
@ -881,7 +880,7 @@ namespace ts.server {
if (!this.wildcardDirectories) {
return;
}
const configDirectoryPath = getDirectoryPath(this.configFileName);
const configDirectoryPath = getDirectoryPath(this.getConfigFilePath());
this.directoriesWatchedForWildcards = reduceProperties(this.wildcardDirectories, (watchers, flag, directory) => {
if (comparePaths(configDirectoryPath, directory, ".", !this.projectService.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) {
const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0;
@ -941,14 +940,14 @@ namespace ts.server {
export class ExternalProject extends Project {
private typingOptions: TypingOptions;
constructor(readonly externalProjectName: string,
constructor(externalProjectName: string,
projectService: ProjectService,
documentRegistry: ts.DocumentRegistry,
compilerOptions: CompilerOptions,
languageServiceEnabled: boolean,
public compileOnSaveEnabled: boolean,
private readonly projectFilePath?: string) {
super(ProjectKind.External, projectService, documentRegistry, /*hasExplicitListOfFiles*/ true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
super(externalProjectName, ProjectKind.External, projectService, documentRegistry, /*hasExplicitListOfFiles*/ true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
}
getProjectRootPath() {
@ -958,7 +957,7 @@ namespace ts.server {
// if the projectFilePath is not given, we make the assumption that the project name
// is the path of the project file. AS the project name is provided by VS, we need to
// normalize slashes before using it as a file name.
return getDirectoryPath(normalizeSlashes(this.externalProjectName));
return getDirectoryPath(normalizeSlashes(this.getProjectName()));
}
getTypingOptions() {
@ -992,9 +991,5 @@ namespace ts.server {
}
this.typingOptions = newTypingOptions;
}
getProjectName() {
return this.externalProjectName;
}
}
}

View File

@ -1,4 +1,4 @@
/* @internal */
/* @internal */
namespace ts {
export interface CodeFix {
errorCodes: number[];
@ -11,6 +11,8 @@ namespace ts {
span: TextSpan;
program: Program;
newLineCharacter: string;
host: LanguageServiceHost;
cancellationToken: CancellationToken;
}
export namespace codefix {

View File

@ -1,2 +1,3 @@
///<reference path='superFixes.ts' />
///<reference path='unusedIdentifierFixes.ts' />
///<reference path='importFixes.ts' />
///<reference path='unusedIdentifierFixes.ts' />

View File

@ -0,0 +1,591 @@
/* @internal */
namespace ts.codefix {
type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport";
interface ImportCodeAction extends CodeAction {
kind: ImportCodeActionKind,
moduleSpecifier?: string
}
enum ModuleSpecifierComparison {
Better,
Equal,
Worse
}
class ImportCodeActionMap {
private symbolIdToActionMap = createMap<ImportCodeAction[]>();
addAction(symbolId: number, newAction: ImportCodeAction) {
if (!newAction) {
return;
}
if (!this.symbolIdToActionMap[symbolId]) {
this.symbolIdToActionMap[symbolId] = [newAction];
return;
}
if (newAction.kind === "CodeChange") {
this.symbolIdToActionMap[symbolId].push(newAction);
return;
}
const updatedNewImports: ImportCodeAction[] = [];
for (const existingAction of this.symbolIdToActionMap[symbolId]) {
if (existingAction.kind === "CodeChange") {
// only import actions should compare
updatedNewImports.push(existingAction);
continue;
}
switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) {
case ModuleSpecifierComparison.Better:
// the new one is not worth considering if it is a new improt.
// However if it is instead a insertion into existing import, the user might want to use
// the module specifier even it is worse by our standards. So keep it.
if (newAction.kind === "NewImport") {
return;
}
case ModuleSpecifierComparison.Equal:
// the current one is safe. But it is still possible that the new one is worse
// than another existing one. For example, you may have new imports from "./foo/bar"
// and "bar", when the new one is "bar/bar2" and the current one is "./foo/bar". The new
// one and the current one are not comparable (one relative path and one absolute path),
// but the new one is worse than the other one, so should not add to the list.
updatedNewImports.push(existingAction);
break;
case ModuleSpecifierComparison.Worse:
// the existing one is worse, remove from the list.
continue;
}
}
// if we reach here, it means the new one is better or equal to all of the existing ones.
updatedNewImports.push(newAction);
this.symbolIdToActionMap[symbolId] = updatedNewImports;
}
addActions(symbolId: number, newActions: ImportCodeAction[]) {
for (const newAction of newActions) {
this.addAction(symbolId, newAction);
}
}
getAllActions() {
let result: ImportCodeAction[] = [];
for (const symbolId in this.symbolIdToActionMap) {
result = concatenate(result, this.symbolIdToActionMap[symbolId]);
}
return result;
}
private compareModuleSpecifiers(moduleSpecifier1: string, moduleSpecifier2: string): ModuleSpecifierComparison {
if (moduleSpecifier1 === moduleSpecifier2) {
return ModuleSpecifierComparison.Equal;
}
// if moduleSpecifier1 (ms1) is a substring of ms2, then it is better
if (moduleSpecifier2.indexOf(moduleSpecifier1) === 0) {
return ModuleSpecifierComparison.Better;
}
if (moduleSpecifier1.indexOf(moduleSpecifier2) === 0) {
return ModuleSpecifierComparison.Worse;
}
// if both are relative paths, and ms1 has fewer levels, then it is better
if (isExternalModuleNameRelative(moduleSpecifier1) && isExternalModuleNameRelative(moduleSpecifier2)) {
const regex = new RegExp(directorySeparator, "g");
const moduleSpecifier1LevelCount = (moduleSpecifier1.match(regex) || []).length;
const moduleSpecifier2LevelCount = (moduleSpecifier2.match(regex) || []).length;
return moduleSpecifier1LevelCount < moduleSpecifier2LevelCount
? ModuleSpecifierComparison.Better
: moduleSpecifier1LevelCount === moduleSpecifier2LevelCount
? ModuleSpecifierComparison.Equal
: ModuleSpecifierComparison.Worse;
}
// the equal cases include when the two specifiers are not comparable.
return ModuleSpecifierComparison.Equal;
}
}
registerCodeFix({
errorCodes: [Diagnostics.Cannot_find_name_0.code],
getCodeActions: (context: CodeFixContext) => {
const sourceFile = context.sourceFile;
const checker = context.program.getTypeChecker();
const allSourceFiles = context.program.getSourceFiles();
const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false;
const token = getTokenAtPosition(sourceFile, context.span.start);
const name = token.getText();
const symbolIdActionMap = new ImportCodeActionMap();
// this is a module id -> module import declaration map
const cachedImportDeclarations = createMap<(ImportDeclaration | ImportEqualsDeclaration)[]>();
let cachedNewImportInsertPosition: number;
const allPotentialModules = checker.getAmbientModules();
for (const otherSourceFile of allSourceFiles) {
if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) {
allPotentialModules.push(otherSourceFile.symbol);
}
}
const currentTokenMeaning = getMeaningFromLocation(token);
for (const moduleSymbol of allPotentialModules) {
context.cancellationToken.throwIfCancellationRequested();
// check the default export
const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol);
if (defaultExport) {
const localSymbol = getLocalSymbolForExportDefault(defaultExport);
if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) {
// check if this symbol is already used
const symbolId = getUniqueSymbolId(localSymbol);
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefaultExport*/ true));
}
}
// check exports with the same name
const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol);
if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName);
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol));
}
}
return symbolIdActionMap.getAllActions();
function getImportDeclarations(moduleSymbol: Symbol) {
const moduleSymbolId = getUniqueSymbolId(moduleSymbol);
if (cachedImportDeclarations[moduleSymbolId]) {
return cachedImportDeclarations[moduleSymbolId];
}
const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = [];
for (const importModuleSpecifier of sourceFile.imports) {
const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier);
if (importSymbol === moduleSymbol) {
existingDeclarations.push(getImportDeclaration(importModuleSpecifier));
}
}
cachedImportDeclarations[moduleSymbolId] = existingDeclarations;
return existingDeclarations;
function getImportDeclaration(moduleSpecifier: LiteralExpression) {
let node: Node = moduleSpecifier;
while (node) {
if (node.kind === SyntaxKind.ImportDeclaration) {
return <ImportDeclaration>node;
}
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
return <ImportEqualsDeclaration>node;
}
node = node.parent;
}
return undefined;
}
}
function getUniqueSymbolId(symbol: Symbol) {
if (symbol.flags & SymbolFlags.Alias) {
return getSymbolId(checker.getAliasedSymbol(symbol));
}
return getSymbolId(symbol);
}
function checkSymbolHasMeaning(symbol: Symbol, meaning: SemanticMeaning) {
const declarations = symbol.getDeclarations();
return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false;
}
function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean): ImportCodeAction[] {
const existingDeclarations = getImportDeclarations(moduleSymbol);
if (existingDeclarations.length > 0) {
// With an existing import statement, there are more than one actions the user can do.
return getCodeActionsForExistingImport(existingDeclarations);
}
else {
return [getCodeActionForNewImport()];
}
function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] {
const actions: ImportCodeAction[] = [];
// It is possible that multiple import statements with the same specifier exist in the file.
// e.g.
//
// import * as ns from "foo";
// import { member1, member2 } from "foo";
//
// member3/**/ <-- cusor here
//
// in this case we should provie 2 actions:
// 1. change "member3" to "ns.member3"
// 2. add "member3" to the second import statement's import list
// and it is up to the user to decide which one fits best.
let namespaceImportDeclaration: ImportDeclaration | ImportEqualsDeclaration;
let namedImportDeclaration: ImportDeclaration;
let existingModuleSpecifier: string;
for (const declaration of declarations) {
if (declaration.kind === SyntaxKind.ImportDeclaration) {
const namedBindings = declaration.importClause && declaration.importClause.namedBindings;
if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) {
// case:
// import * as ns from "foo"
namespaceImportDeclaration = declaration;
}
else {
// cases:
// import default from "foo"
// import { bar } from "foo" or combination with the first one
// import "foo"
namedImportDeclaration = declaration;
}
existingModuleSpecifier = declaration.moduleSpecifier.getText();
}
else {
// case:
// import foo = require("foo")
namespaceImportDeclaration = declaration;
existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration);
}
}
if (namespaceImportDeclaration) {
actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration));
}
if (namedImportDeclaration && namedImportDeclaration.importClause &&
(namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) {
/**
* If the existing import declaration already has a named import list, just
* insert the identifier into that list.
*/
const textChange = getTextChangeForImportClause(namedImportDeclaration.importClause);
const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText());
actions.push(createCodeAction(
Diagnostics.Add_0_to_existing_import_declaration_from_1,
[name, moduleSpecifierWithoutQuotes],
textChange.newText,
textChange.span,
sourceFile.fileName,
"InsertingIntoExistingImport",
moduleSpecifierWithoutQuotes
));
}
else {
// we need to create a new import statement, but the existing module specifier can be reused.
actions.push(getCodeActionForNewImport(existingModuleSpecifier));
}
return actions;
function getModuleSpecifierFromImportEqualsDeclaration(declaration: ImportEqualsDeclaration) {
if (declaration.moduleReference && declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
return declaration.moduleReference.expression.getText();
}
return declaration.moduleReference.getText();
}
function getTextChangeForImportClause(importClause: ImportClause): TextChange {
const newImportText = isDefault ? `default as ${name}` : name;
const importList = <NamedImports>importClause.namedBindings;
// case 1:
// original text: import default from "module"
// change to: import default, { name } from "module"
if (!importList && importClause.name) {
const start = importClause.name.getEnd();
return {
newText: `, { ${newImportText} }`,
span: { start, length: 0 }
};
}
// case 2:
// original text: import {} from "module"
// change to: import { name } from "module"
if (importList.elements.length === 0) {
const start = importList.getStart();
return {
newText: `{ ${newImportText} }`,
span: { start, length: importList.getEnd() - start }
};
}
// case 3:
// original text: import { foo, bar } from "module"
// change to: import { foo, bar, name } from "module"
const insertPoint = importList.elements[importList.elements.length - 1].getEnd();
/**
* If the import list has one import per line, preserve that. Otherwise, insert on same line as last element
* import {
* foo
* } from "./module";
*/
const startLine = getLineOfLocalPosition(sourceFile, importList.getStart());
const endLine = getLineOfLocalPosition(sourceFile, importList.getEnd());
const oneImportPerLine = endLine - startLine > importList.elements.length;
return {
newText: `,${oneImportPerLine ? context.newLineCharacter : " "}${newImportText}`,
span: { start: insertPoint, length: 0 }
};
}
function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction {
let namespacePrefix: string;
if (declaration.kind === SyntaxKind.ImportDeclaration) {
namespacePrefix = (<NamespaceImport>declaration.importClause.namedBindings).name.getText();
}
else {
namespacePrefix = declaration.name.getText();
}
namespacePrefix = stripQuotes(namespacePrefix);
/**
* Cases:
* import * as ns from "mod"
* import default, * as ns from "mod"
* import ns = require("mod")
*
* Because there is no import list, we alter the reference to include the
* namespace instead of altering the import declaration. For example, "foo" would
* become "ns.foo"
*/
return createCodeAction(
Diagnostics.Change_0_to_1,
[name, `${namespacePrefix}.${name}`],
`${namespacePrefix}.`,
{ start: token.getStart(), length: 0 },
sourceFile.fileName,
"CodeChange"
);
}
}
function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction {
if (!cachedNewImportInsertPosition) {
// insert after any existing imports
let lastModuleSpecifierEnd = -1;
for (const moduleSpecifier of sourceFile.imports) {
const end = moduleSpecifier.getEnd();
if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) {
lastModuleSpecifierEnd = end;
}
}
cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart();
}
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport());
const importStatementText = isDefault
? `import ${name} from "${moduleSpecifierWithoutQuotes}"`
: `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`;
// if this file doesn't have any import statements, insert an import statement and then insert a new line
// between the only import statement and user code. Otherwise just insert the statement because chances
// are there are already a new line seperating code and import statements.
const newText = cachedNewImportInsertPosition === sourceFile.getStart()
? `${importStatementText};${context.newLineCharacter}${context.newLineCharacter}`
: `${context.newLineCharacter}${importStatementText};`;
return createCodeAction(
Diagnostics.Import_0_from_1,
[name, `"${moduleSpecifierWithoutQuotes}"`],
newText,
{ start: cachedNewImportInsertPosition, length: 0 },
sourceFile.fileName,
"NewImport",
moduleSpecifierWithoutQuotes
);
function getModuleSpecifierForNewImport() {
const fileName = sourceFile.path;
const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path;
const sourceDirectory = getDirectoryPath(fileName);
const options = context.program.getCompilerOptions();
return tryGetModuleNameFromAmbientModule() ||
tryGetModuleNameFromBaseUrl() ||
tryGetModuleNameFromRootDirs() ||
tryGetModuleNameFromTypeRoots() ||
tryGetModuleNameAsNodeModule() ||
removeFileExtension(getRelativePath(moduleFileName, sourceDirectory));
function tryGetModuleNameFromAmbientModule(): string {
if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) {
return moduleSymbol.name;
}
}
function tryGetModuleNameFromBaseUrl() {
if (!options.baseUrl) {
return undefined;
}
const normalizedBaseUrl = toPath(options.baseUrl, getDirectoryPath(options.baseUrl), getCanonicalFileName);
let relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl);
if (!relativeName) {
return undefined;
}
relativeName = removeExtensionAndIndexPostFix(relativeName);
if (options.paths) {
for (const key in options.paths) {
for (const pattern of options.paths[key]) {
const indexOfStar = pattern.indexOf("*");
if (indexOfStar === 0 && pattern.length === 1) {
continue;
}
else if (indexOfStar !== -1) {
const prefix = pattern.substr(0, indexOfStar);
const suffix = pattern.substr(indexOfStar + 1);
if (relativeName.length >= prefix.length + suffix.length &&
startsWith(relativeName, prefix) &&
endsWith(relativeName, suffix)) {
const matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length);
return key.replace("\*", matchedStar);
}
}
else if (pattern === relativeName) {
return key;
}
}
}
}
return relativeName;
}
function tryGetModuleNameFromRootDirs() {
if (options.rootDirs) {
const normalizedRootDirs = map(options.rootDirs, rootDir => toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName));
const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs);
const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs);
if (normalizedTargetPath !== undefined) {
const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath;
return removeFileExtension(relativePath);
}
}
return undefined;
}
function tryGetModuleNameFromTypeRoots() {
const typeRoots = getEffectiveTypeRoots(options, context.host);
if (typeRoots) {
const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName));
for (const typeRoot of normalizedTypeRoots) {
if (startsWith(moduleFileName, typeRoot)) {
let relativeFileName = moduleFileName.substring(typeRoot.length + 1);
return removeExtensionAndIndexPostFix(relativeFileName);
}
}
}
}
function tryGetModuleNameAsNodeModule() {
if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) {
// nothing to do here
return undefined;
}
const indexOfNodeModules = moduleFileName.indexOf("node_modules");
if (indexOfNodeModules < 0) {
return undefined;
}
let relativeFileName: string;
if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) {
// if node_modules folder is in this folder or any of its parent folder, no need to keep it.
relativeFileName = moduleFileName.substring(indexOfNodeModules + 13 /* "node_modules\".length */);
}
else {
relativeFileName = getRelativePath(moduleFileName, sourceDirectory);
}
relativeFileName = removeFileExtension(relativeFileName);
if (endsWith(relativeFileName, "/index")) {
relativeFileName = getDirectoryPath(relativeFileName);
}
else {
try {
const moduleDirectory = getDirectoryPath(moduleFileName);
const packageJsonContent = JSON.parse(context.host.readFile(combinePaths(moduleDirectory, "package.json")));
if (packageJsonContent) {
const mainFile = packageJsonContent.main || packageJsonContent.typings;
if (mainFile) {
const mainExportFile = toPath(mainFile, moduleDirectory, getCanonicalFileName);
if (removeFileExtension(mainExportFile) === removeFileExtension(moduleFileName)) {
relativeFileName = getDirectoryPath(relativeFileName);
}
}
}
}
catch (e) { }
}
return relativeFileName;
}
}
function getPathRelativeToRootDirs(path: Path, rootDirs: Path[]) {
for (const rootDir of rootDirs) {
const relativeName = tryRemoveParentDirectoryName(path, rootDir);
if (relativeName !== undefined) {
return relativeName;
}
}
return undefined;
}
function removeExtensionAndIndexPostFix(fileName: string) {
fileName = removeFileExtension(fileName);
if (endsWith(fileName, "/index")) {
fileName = fileName.substr(0, fileName.length - 6/* "/index".length */);
}
return fileName;
}
function getRelativePath(path: string, directoryPath: string) {
const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath;
}
function tryRemoveParentDirectoryName(path: Path, parentDirectory: Path) {
const index = path.indexOf(parentDirectory);
if (index === 0) {
return endsWith(parentDirectory, directorySeparator)
? path.substring(parentDirectory.length)
: path.substring(parentDirectory.length + 1);
}
return undefined;
}
}
}
function createCodeAction(
description: DiagnosticMessage,
diagnosticArgs: string[],
newText: string,
span: TextSpan,
fileName: string,
kind: ImportCodeActionKind,
moduleSpecifier?: string): ImportCodeAction {
return {
description: formatMessage.apply(undefined, [undefined, description].concat(<any[]>diagnosticArgs)),
changes: [{ fileName, textChanges: [{ newText, span }] }],
kind,
moduleSpecifier
};
}
}
});
}

View File

@ -1,4 +1,4 @@
/// <reference path="..\compiler\program.ts"/>
/// <reference path="..\compiler\program.ts"/>
/// <reference path="..\compiler\commandLineParser.ts"/>
/// <reference path='types.ts' />
@ -492,6 +492,23 @@ namespace ts {
return ts.getPositionOfLineAndCharacter(this, line, character);
}
public getLineEndOfPosition(pos: number): number {
const { line } = this.getLineAndCharacterOfPosition(pos);
const lineStarts = this.getLineStarts();
let lastCharPos: number;
if (line + 1 >= lineStarts.length) {
lastCharPos = this.getEnd();
}
if (!lastCharPos) {
lastCharPos = lineStarts[line + 1] - 1;
}
const fullText = this.getFullText();
// if the new line is "\r\n", we should return the last non-new-line-character position
return fullText[lastCharPos] === "\n" && fullText[lastCharPos - 1] === "\r" ? lastCharPos - 1 : lastCharPos;
}
public getNamedDeclarations(): Map<Declaration[]> {
if (!this.namedDeclarations) {
this.namedDeclarations = this.computeNamedDeclarations();
@ -1676,7 +1693,9 @@ namespace ts {
sourceFile: sourceFile,
span: span,
program: program,
newLineCharacter: newLineChar
newLineCharacter: newLineChar,
host: host,
cancellationToken: cancellationToken
};
const fixes = codefix.getFixes(context);

View File

@ -53,6 +53,7 @@ namespace ts {
/* @internal */ getNamedDeclarations(): Map<Declaration[]>;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineEndOfPosition(pos: number): number;
getLineStarts(): number[];
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;

View File

@ -13,7 +13,7 @@ var C = (function () {
set: function () {
var v = [];
for (var _i = 0; _i < arguments.length; _i++) {
v[_i - 0] = arguments[_i];
v[_i] = arguments[_i];
}
},
enumerable: true,
@ -23,7 +23,7 @@ var C = (function () {
set: function () {
var v2 = [];
for (var _i = 0; _i < arguments.length; _i++) {
v2[_i - 0] = arguments[_i];
v2[_i] = arguments[_i];
}
},
enumerable: true,

View File

@ -52,14 +52,14 @@ a = function () { return 1; }; // ok, same number of required params
a = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
return 1;
}; // ok, same number of required params
a = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
return 1;
}; // error, type mismatch
@ -72,7 +72,7 @@ a2 = function () { return 1; }; // ok, fewer required params
a2 = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
return 1;
}; // ok, fewer required params

View File

@ -23,7 +23,7 @@ var Derived2 = (function () {
Derived2.prototype.method = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
};
return Derived2;

View File

@ -17,7 +17,7 @@ var Based = (function () {
function Based() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
return Based;

View File

@ -20,7 +20,7 @@ var Base = (function () {
function Base() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
return Base;

View File

@ -20,7 +20,7 @@ var Base = (function () {
function Base() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
return Base;

View File

@ -37,7 +37,7 @@ var f1NoError = function (arguments) {
var f2 = function () {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // No Error
};

View File

@ -118,7 +118,7 @@ var c2 = (function () {
function c2() {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
}

View File

@ -94,7 +94,7 @@ var c3 = (function () {
c3.prototype.foo = function () {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
};

View File

@ -66,7 +66,7 @@ function f1NoError(arguments) {
function f3() {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
}

View File

@ -56,7 +56,7 @@ function foo() {
function f3() {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
}

View File

@ -27,7 +27,7 @@ var f1NoError = function (_i) {
var f2 = function () {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // No Error
};

View File

@ -88,7 +88,7 @@ var c2 = (function () {
function c2() {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
}

View File

@ -70,7 +70,7 @@ var c3 = (function () {
c3.prototype.foo = function () {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
};

View File

@ -48,7 +48,7 @@ function f1NoError(_i) {
function f3() {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
}

View File

@ -39,7 +39,7 @@ function foo() {
function f3() {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
}

View File

@ -14,7 +14,7 @@ var Foo = (function () {
function Foo() {
var args = [];
for (var _a = 0; _a < arguments.length; _a++) {
args[_a - 0] = arguments[_a];
args[_a] = arguments[_a];
}
console.log(_i); // This should result in error
}

View File

@ -297,7 +297,7 @@ var TypeScriptAllInOne;
Program.Main = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
try {
var bfs = new BasicFeatures();

View File

@ -57,21 +57,21 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
(function () {
var numbers = [];
for (var _i = 0; _i < arguments.length; _i++) {
numbers[_i - 0] = arguments[_i];
numbers[_i] = arguments[_i];
}
return numbers.every(function (n) { return n > 0; });
})(5, 6, 7);
(function () {
var mixed = [];
for (var _i = 0; _i < arguments.length; _i++) {
mixed[_i - 0] = arguments[_i];
mixed[_i] = arguments[_i];
}
return mixed.every(function (n) { return !!n; });
})(5, 'oops', 'oh no');
(function () {
var noNumbers = [];
for (var _i = 0; _i < arguments.length; _i++) {
noNumbers[_i - 0] = arguments[_i];
noNumbers[_i] = arguments[_i];
}
return noNumbers.some(function (n) { return n > 0; });
})();

View File

@ -11,7 +11,7 @@ var x: (...y: string[]) => void = function (.../*3*/y) {
var x = function () {
var y = [];
for (var _i = 0; _i < arguments.length; _i++) {
y[_i - 0] = arguments[_i];
y[_i] = arguments[_i];
}
var t = y;
var x2 = t; // This should be error

View File

@ -14,7 +14,7 @@ var f6 = () => { return [<any>10]; }
function f1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
function f2(x) { }

View File

@ -13,13 +13,13 @@ function foo2(...rest: any[]) {
function foo() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
function foo2() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}

View File

@ -10,7 +10,7 @@ export default function f(...args: any[]) {
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -55,31 +55,31 @@ var __spread = (this && this.__spread) || function () {
function a0() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
} // Error, rest parameter must be array type
function a1() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
}
function a2() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
} // Error, rest parameter must be array type
function a3() {
var b = [];
for (var _i = 0; _i < arguments.length; _i++) {
b[_i - 0] = arguments[_i];
b[_i] = arguments[_i];
}
} // Error, can't be optional
function a4() {
var b = [];
for (var _i = 0; _i < arguments.length; _i++) {
b[_i - 0] = arguments[_i];
b[_i] = arguments[_i];
}
} // Error, can't have initializer
function a5(_a) {
@ -98,7 +98,7 @@ var C = (function () {
function C() {
var temp = [];
for (var _i = 0; _i < arguments.length; _i++) {
temp[_i - 0] = arguments[_i];
temp[_i] = arguments[_i];
}
this.temp = temp;
} // Error, rest parameter can't have properties
@ -108,7 +108,7 @@ var C = (function () {
function foo1() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
}
foo1(1, 2, "string", E1.a, E.b); // Error

View File

@ -40,20 +40,20 @@ while (, )
function a5() {
var = [];
for (var _i = 0; _i < arguments.length; _i++) {
[_i - 0] = arguments[_i];
[_i] = arguments[_i];
}
}
while () { }
function a6() {
var public = [];
for (var _i = 0; _i < arguments.length; _i++) {
public[_i - 0] = arguments[_i];
public[_i] = arguments[_i];
}
}
function a7() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
}
a({ "while": 1 });

View File

@ -19,7 +19,7 @@ var TestFile = (function () {
return function () {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
/// <summary>Test summary</summary>
/// <param name="message" type="String" />

View File

@ -23,7 +23,7 @@ var TestFile = (function () {
/// <returns type="Function" />
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
return message + _this.name;
};

View File

@ -92,13 +92,13 @@ var f4 = function (x, y) {
var f5 = function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
};
var f6 = function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
};
var f7 = function (x, y, z) {

View File

@ -32,13 +32,13 @@ var A = (function () {
function A() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
A.prototype.method = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
};
return A;
@ -57,13 +57,13 @@ var B = (function () {
function B() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
B.prototype.method = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
};
return B;

View File

@ -6,7 +6,7 @@ function foo(x: number, y: string, ...rest) { }
function bar() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
function foo(x, y) {

View File

@ -9,7 +9,7 @@ var funcExp3 = (function (...rest) { })()
var funcExp = function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
};
var funcExp1 = function (X) {
@ -21,12 +21,12 @@ var funcExp1 = function (X) {
var funcExp2 = function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
};
var funcExp3 = (function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
})();

View File

@ -13,7 +13,7 @@ var obj2 = {
func: function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
};

View File

@ -24,7 +24,7 @@ var C = (function () {
C.prototype.bar = function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
};
C.prototype.foo = function (x) {
@ -39,13 +39,13 @@ var D = (function () {
function D() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
D.prototype.bar = function () {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
};
D.prototype.foo = function (x) {

View File

@ -11,7 +11,7 @@ function rebase(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
return fn.apply(this, [this].concat(args));
};

View File

@ -236,7 +236,7 @@ var SplatMonster = (function () {
function SplatMonster() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
SplatMonster.prototype.roar = function (name) {

View File

@ -17,7 +17,7 @@ export function f1(d) {
export function f2() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
export default function f3(d) {

View File

@ -16,7 +16,7 @@ var x4= (...a: any[]) { };
foo(function () {
var Far = [];
for (var _i = 0; _i < arguments.length; _i++) {
Far[_i - 0] = arguments[_i];
Far[_i] = arguments[_i];
}
return 0;
});
@ -36,6 +36,6 @@ var x3 = function (a) { };
var x4 = function () {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
};

View File

@ -159,7 +159,7 @@ foo(
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 8;
});
@ -203,7 +203,7 @@ foo(
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 28;
});
@ -226,7 +226,7 @@ false ? function (arg) {
false ? function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 48;
} : null;
@ -247,7 +247,7 @@ false ? (function (arg) {
false ? (function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 58;
}) : null;
@ -268,7 +268,7 @@ false ? null : function (arg) {
false ? null : function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 68;
};
@ -294,7 +294,7 @@ false ? null : function () {
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 96;
}) instanceof Function;
@ -326,13 +326,13 @@ false ? null : function () {
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 0;
}) + '' + (function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 107;
});
@ -354,7 +354,7 @@ false ? null : function () {
function foo() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) {
@ -371,7 +371,7 @@ foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) {
}, function () {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
return 119;
}, function (a, b) {

View File

@ -12,21 +12,21 @@
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 102;
});
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 103;
});
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 104;
});

View File

@ -6,7 +6,7 @@
(function () {
var = [];
for (var _i = 0; _i < arguments.length; _i++) {
[_i - 0] = arguments[_i];
[_i] = arguments[_i];
}
return 105;
});

View File

@ -56,7 +56,7 @@ foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) {
}, function () {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
return 119;
}, function (a, b) {

View File

@ -10,7 +10,7 @@ foo(1, 'bar');
function foo() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
}
;

View File

@ -28,7 +28,7 @@ var A = (function () {
function Choice() {
var v_args = [];
for (var _i = 0; _i < arguments.length; _i++) {
v_args[_i - 0] = arguments[_i];
v_args[_i] = arguments[_i];
}
return new A();
}

View File

@ -16,7 +16,7 @@ var a2Gc = makeArrayG<any[]>(1, ""); // error
function makeArrayG() {
var items = [];
for (var _i = 0; _i < arguments.length; _i++) {
items[_i - 0] = arguments[_i];
items[_i] = arguments[_i];
}
return items;
}

View File

@ -22,7 +22,7 @@ function func2(a, b, c) { }
function func3() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
; // error at "args"

View File

@ -29,9 +29,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -24,7 +24,7 @@ var Base = (function () {
function Base() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
}
return Base;

View File

@ -0,0 +1,15 @@
tests/cases/conformance/types/literal/literalTypesWidenInParameterPosition.ts(4,9): error TS2322: Type '5' is not assignable to type '1'.
==== tests/cases/conformance/types/literal/literalTypesWidenInParameterPosition.ts (1 errors) ====
class D {
readonly noWiden = 1
constructor(readonly widen = 2) {
this.noWiden = 5; // error
~~~~~~~~~~~~
!!! error TS2322: Type '5' is not assignable to type '1'.
this.widen = 6; // ok
}
}
new D(7); // ok

View File

@ -0,0 +1,23 @@
//// [literalTypesWidenInParameterPosition.ts]
class D {
readonly noWiden = 1
constructor(readonly widen = 2) {
this.noWiden = 5; // error
this.widen = 6; // ok
}
}
new D(7); // ok
//// [literalTypesWidenInParameterPosition.js]
var D = (function () {
function D(widen) {
if (widen === void 0) { widen = 2; }
this.widen = widen;
this.noWiden = 1;
this.noWiden = 5; // error
this.widen = 6; // ok
}
return D;
}());
new D(7); // ok

View File

@ -119,7 +119,7 @@ function f(x, y) {
function f2() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
}
var B = (function () {

View File

@ -118,7 +118,7 @@ function f(x, y) {
function f2() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
}
var B = (function () {

View File

@ -59,7 +59,7 @@ function f5(x, y, z) { }
function f6() {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
}
// Implicit-'any'/'any[]' errors for x, r.
@ -82,7 +82,7 @@ var f12 = function (x, y, z) { return ""; };
var f13 = function () {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
return "";
};

View File

@ -107,7 +107,7 @@ var C = (function () {
this.pub_f13 = function () {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
return "";
};
@ -131,7 +131,7 @@ var C = (function () {
this.priv_f13 = function () {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
return "";
};
@ -158,7 +158,7 @@ var C = (function () {
C.prototype.pub_f6 = function () {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
};
// Implicit-'any'/'any[]' errors for x, r.
@ -184,7 +184,7 @@ var C = (function () {
C.prototype.priv_f6 = function () {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
};
// Implicit-'any'/'any[]' errors for x, r.

View File

@ -63,7 +63,7 @@ var M;
function m_f6() {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
}
// Implicit-'any'/'any[]' errors for x and r.
@ -86,7 +86,7 @@ var M;
var m_f13 = function () {
var r = [];
for (var _i = 0; _i < arguments.length; _i++) {
r[_i - 0] = arguments[_i];
r[_i] = arguments[_i];
}
return "";
};

View File

@ -8,7 +8,7 @@ function foo(...rest: number) { // error
function foo() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
var x = rest[0];
return x;

View File

@ -20,9 +20,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -20,9 +20,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -87,9 +87,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -16,9 +16,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -23,9 +23,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -77,9 +77,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -11,9 +11,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -27,9 +27,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -13,7 +13,7 @@ foo([false, 0, ""]);
function foo() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
foo(["", 0, false]);

View File

@ -13,7 +13,7 @@ foo({ x: false, y: 0, z: "" });
function foo() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
foo({ x: "", y: 0, z: false });

View File

@ -24,7 +24,7 @@ var A = (function () {
function Choice() {
var v_args = [];
for (var _i = 0; _i < arguments.length; _i++) {
v_args[_i - 0] = arguments[_i];
v_args[_i] = arguments[_i];
}
return new A();
}

View File

@ -45,7 +45,7 @@ var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
function fun() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
return undefined;
}

View File

@ -10,7 +10,7 @@ var Foo3 = (function () {
function Foo3() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
this.args = args;
}

View File

@ -11,7 +11,7 @@ var C = (function () {
set: function () {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
a[_i] = arguments[_i];
}
},
enumerable: true,

View File

@ -10,7 +10,7 @@ var C = (function () {
C.prototype.foo = function () {
var bar = [];
for (var _i = 0; _i < arguments.length; _i++) {
bar[_i - 0] = arguments[_i];
bar[_i] = arguments[_i];
}
};
return C;

View File

@ -5,7 +5,7 @@
(function () {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
return 102;
});

View File

@ -10,7 +10,7 @@ var C = (function () {
C.prototype.foo = function () {
var bar = [];
for (var _i = 0; _i < arguments.length; _i++) {
bar[_i - 0] = arguments[_i];
bar[_i] = arguments[_i];
}
};
return C;

View File

@ -63,7 +63,7 @@ test(function (t1) { });
test(function () {
var ts = [];
for (var _i = 0; _i < arguments.length; _i++) {
ts[_i - 0] = arguments[_i];
ts[_i] = arguments[_i];
}
});
// source function has rest arg

View File

@ -18,9 +18,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
if (typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
t[p[i]] = s[p[i]];
}
return t;
};

View File

@ -13,7 +13,7 @@ n([4], 'foo');
function f() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
x.forEach(function (n, i) { return void ('item ' + i + ' = ' + n); });
}

View File

@ -6,6 +6,6 @@ function sum (...) {}
function sum() {
var = [];
for (var _i = 0; _i < arguments.length; _i++) {
[_i - 0] = arguments[_i];
[_i] = arguments[_i];
}
}

View File

@ -6,12 +6,12 @@ function f2(...x = []) { }
function f() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
}
function f2() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
x[_i] = arguments[_i];
}
}

View File

@ -8,7 +8,7 @@ var C = (function () {
function C() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
this.rest = rest;
}

View File

@ -33,7 +33,7 @@ var T = (function () {
T.prototype.m = function () {
var p3 = [];
for (var _i = 0; _i < arguments.length; _i++) {
p3[_i - 0] = arguments[_i];
p3[_i] = arguments[_i];
}
};
return T;

Some files were not shown because too many files have changed in this diff Show More