Merge branch 'master' into emitHelper

This commit is contained in:
Ron Buckton
2016-11-08 16:36:31 -08:00
250 changed files with 6755 additions and 2481 deletions
+36 -7
View File
@@ -1,32 +1,38 @@
Alexander <alexander@kuvaev.me># Alexander Kuvaev
AbubakerB <abubaker_bashir@hotmail.com> # Abubaker Bashir
Alexander <alexander@kuvaev.me># Alexander Kuvaev
Adam Freidin <adam.freidin@gmail.com> Adam Freidin <afreidin@adobe.com>
Adi Dahiya <adahiya@palantir.com> Adi Dahiya <adi.dahiya14@gmail.com>
Ahmad Farid <ahfarid@microsoft.com> ahmad-farid <ahfarid@microsoft.com>
Alexander Rusakov <a_s_rusakov@mail.ru>
Alex Eagle <alexeagle@google.com>
Anatoly Ressin <anatoly.ressin@icloud.com>
Anders Hejlsberg <andersh@microsoft.com> unknown <andersh@AndersX1.NOE.Nokia.com> unknown <andersh@andersh-yoga.redmond.corp.microsoft.com>
Andrej Baran <andrej.baran@gmail.com>
Andrew Z Allen <me@andrewzallen.com>
Andy Hanson <anhans@microsoft.com> Andy <anhans@microsoft.com>
Anil Anar <anilanar@hotmail.com>
Anton Tolmachev <myste@mail.ru>
Arnavion <arnavion@gmail.com> # Arnav Singh
Arthur Ozga <aozgaa@umich.edu> Arthur Ozga <t-arthoz@microsoft.com>
Arthur Ozga <aozgaa@umich.edu> Arthur Ozga <t-arthoz@microsoft.com> Arthur Ozga <aozgaa-ms@outlook.com> Arthur Ozga <aozgaa@users.noreply.github.com> Arthur Ozga <arozga@microsoft.com>
Asad Saeeduddin <masaeedu@gmail.com>
Schmavery <avery.schmavery@gmail.com> # Avery Morin
Basarat Ali Syed <basaratali@gmail.com> Basarat Syed <basaratali@gmail.com> basarat <basaratali@gmail.com>
Bill Ticehurst <billti@hotmail.com> Bill Ticehurst <billti@microsoft.com>
Ben Duffield <jebavarde@gmail.com>
Ben Mosher <me@benmosher.com>
Blake Embrey <hello@blakeembrey.com>
Bowden Kelly <wilkelly@microsoft.com>
Brett Mayen <bmayen@midnightsnacks.net>
Bryan Forbes <bryan@reigndropsfall.net>
Caitlin Potter <caitpotter88@gmail.com>
ChrisBubernak <chris.bubernak@gmail.com> unknown <chrbub@chrbub1.redmond.corp.microsoft.com> # Chris Bubernak
Christophe Vidal <kriss@krizalys.com>
Chuck Jazdzewski <chuckj@google.com>
Colby Russell <mr@colbyrussell.com>
Colin Snover <github.com@zetafleet.com>
Cyrus Najmabadi <cyrusn@microsoft.com> CyrusNajmabadi <cyrusn@microsoft.com> unknown <cyrusn@cylap.ntdev.corp.microsoft.com>
Dafrok <o.o@mug.dog> # Dafrok Zhang
Dan Corder <dev@dancorder.com>
Dan Quirk <danquirk@microsoft.com> Dan Quirk <danquirk@users.noreply.github.com> nknown <danquirk@DANQUIRK1.redmond.corp.microsoft.com>
Daniel Rosenwasser <drosen@microsoft.com> Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> Daniel Rosenwasser <DanielRosenwasser@gmail.com> Daniel Rosenwasser <Daniel.Rosenwasser@microsoft.com> Daniel Rosenwasser <DanielRosenwasser@microsoft.com>
@@ -36,17 +42,22 @@ Denis Nedelyaev <denvned@gmail.com>
Dick van den Brink <d_vandenbrink@outlook.com> unknown <d_vandenbrink@outlook.com> unknown <d_vandenbrink@live.com>
Dirk Baeumer <dirkb@microsoft.com> Dirk Bäumer <dirkb@microsoft.com> # Dirk Bäumer
Dirk Holtwick <dirk.holtwick@gmail.com>
Dom Chen <domchen@users.noreply.github.com>
Doug Ilijev <dilijev@users.noreply.github.com>
Erik Edrosa <erik.edrosa@gmail.com>
erictsangx <erictsangx@gmail.com> # Eric Tsang
Ethan Rubio <ethanrubio@users.noreply.github.com>
Evan Martin <martine@danga.com>
Evan Sebastian <evanlhoini@gmail.com>
Eyas <eyas.sharaiha@gmail.com> # Eyas Sharaiha
Fabian Cook <faybecook@gmail.com>
falsandtru <falsandtru@users.noreply.github.com> # @falsandtru
Frank Wallis <fwallis@outlook.com>
František Žiačik <fziacik@gratex.com> František Žiačik <ziacik@gmail.com>
František Žiacik <fziacik@gratex.com> František Žiacik <ziacik@gmail.com>
Gabe Moothart <gmoothart@gmail.com>
Gabriel Isenberg <gisenberg@gmail.com>
Gilad Peleg <giladp007@gmail.com>
Godfrey Chan <godfreykfc@gmail.com>
Graeme Wicksted <graeme.wicksted@gmail.com>
Guillaume Salles <guillaume.salles@me.com>
Guy Bedford <guybedford@gmail.com> guybedford <guybedford@gmail.com>
@@ -55,6 +66,7 @@ Iain Monro <iain.monro@softwire.com>
Ingvar Stepanyan <me@rreverser.com>
impinball <impinball@gmail.com> # Isiah Meadows
Ivo Gabe de Wolff <ivogabe@ivogabe.nl>
Jakub Młokosiewicz <hckr@users.noreply.github.com>
James Whitney <james@whitney.io>
Jason Freeman <jfreeman@microsoft.com> Jason Freeman <JsonFreeman@users.noreply.github.com>
Jason Killian <jkillian@palantir.com>
@@ -69,11 +81,14 @@ Jonathan Park <jpark@daptiv.com>
Jonathan Turner <jont@microsoft.com> Jonathan Turner <probata@hotmail.com>
Jonathan Toland <toland@dnalot.com>
Jesse Schalken <me@jesseschalken.com>
Josh Abernathy <joshaber@gmail.com> joshaber <joshaber@gmail.com>
Josh Kalderimis <josh.kalderimis@gmail.com>
Josh Soref <jsoref@users.noreply.github.com>
Juan Luis Boya García <ntrrgc@gmail.com>
Julian Williams <julianjw92@gmail.com>
Herrington Darkholme <nonamesheep1@gmail.com>
Justin Bay <justin.bay@outlook.com>
Justin Johansson <thebabellion@gmail.com>
Herrington Darkholme <nonamesheep1@gmail.com> (´·?·`) <HerringtonDarkholme@users.noreply.github.com> # Herrington Darkholme
Kagami Sascha Rosylight <saschanaz@outlook.com> SaschaNaz <saschanaz@outlook.com>
Kanchalai Tanglertsampan <yuisu@microsoft.com> Yui <yuit@users.noreply.github.com>
Kanchalai Tanglertsampan <yuisu@microsoft.com> Yui T <yuisu@microsoft.com>
@@ -82,23 +97,29 @@ Kanchalai Tanglertsampan <yuisu@microsoft.com> Yui <yuisu@microsoft.com>
Kanchalai Tanglertsampan <yuisu@microsoft.com> yui T <yuisu@microsoft.com>
Keith Mashinter <kmashint@yahoo.com> kmashint <kmashint@yahoo.com>
Ken Howard <ken@simplicatedweb.com>
Kevin Lang <klang2012@gmail.com>
kimamula <kenji.imamula@gmail.com> # Kenji Imamula
Kyle Kelley <rgbkrk@gmail.com>
Lorant Pinter <lorant.pinter@prezi.com>
Lucien Greathouse <me@lpghatguy.com>
Lukas Elmer <lukas.elmer@gmail.com> Lukas Elmer <lukas.elmer@renuo.ch>
Martin Vseticka <vseticka.martin@gmail.com> Martin Všeticka <vseticka.martin@gmail.com> MartyIX <vseticka.martin@gmail.com>
gcnew <gcnew@abv.bg> # Marin Marinov
vvakame <vvakame+dev@gmail.com> # Masahiro Wakame
Matt McCutchen <rmccutch@mit.edu>
Max Deepfield <maxdeepfield@absolutefreakout.com>
Micah Zoltu <micah@zoltu.net>
Michael <maykelchiche@gmail.com>
Mohamed Hegazy <mhegazy@microsoft.com>
Nathan Shively-Sanders <nathansa@microsoft.com>
Nathan Yee <ny.nathan.yee@gmail.com>
Nima Zahedi <nima.zahedee@gmail.com>
Noah Chen <nchen@palantir.com>
Noj Vek <nojvek@gmail.com>
mihailik <mihailik@gmail.com> # Oleg Mihailik
Oleksandr Chekhovskyi <oleksandr.chekhovskyi@hansoft.com>
Paul van Brenk <paul.van.brenk@microsoft.com> Paul van Brenk <paul.van.brenk@outlook.com> unknown <paul.van.brenk@microsoft.com> unknown <paul.van.brenk@microsoft.com> unknown <pvanbren@pvbvsproai.redmond.corp.microsoft.com>
Omer Sheikh <ojsheikh@gmail.com>
Oskar Segersva¨rd <oskar.segersvard@widespace.com>
pcan <piero.cangianiello@gmail.com> # Piero Cangianiello
pcbro <2bux89+dk3zspjmuh16o@sharklasers.com> # @pcbro
@@ -109,21 +130,26 @@ progre <djyayutto@gmail.com> # @progre
Prayag Verma <prayag.verma@gmail.com>
Punya Biswal <pbiswal@palantir.com>
Rado Kirov <radokirov@google.com>
Ron Buckton <rbuckton@microsoft.com> Ron Buckton <ron.buckton@microsoft.com>
Ron Buckton <rbuckton@microsoft.com> Ron Buckton <ron.buckton@microsoft.com> rbuckton <rbuckton@chronicles.org>
Rostislav Galimsky <rostgal@gmail.com>
Richard Knoll <riknoll@users.noreply.github.com> Richard Knoll <riknoll@microsoft.com>
Rowan Wyborn <rwyborn@internode.on.net>
Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com> Ryan Cavanaugh <ryan.cavanaugh@microsoft.com> Ryan Cavanaugh <ryanca@microsoft.com>
Ryohei Ikegami <iofg2100@gmail.com>
Sarangan Rajamanickam <sarajama@microsoft.com>
Sébastien Arod <sebastien.arod@gmail.com>
Sergey Shandar <sergey-shandar@users.noreply.github.com>
Sheetal Nandi <shkamat@microsoft.com>
Shengping Zhong <zhongsp@users.noreply.github.com>
shyyko.serhiy@gmail.com <shyyko.serhiy@gmail.com> # Shyyko Serhiy
Sam El-Husseini <samelh@microsoft.com>
Simon Hürlimann <simon.huerlimann@cyt.ch>
Slawomir Sadziak <slsadzia@microsoft.com>
Solal Pirelli <solal.pirelli@gmail.com>
Stan Thomas <stmsdn@norvil.net>
Stanislav Sysoev <d4rkr00t@gmail.com>
Steve Lucco <steveluc@users.noreply.github.com> steveluc <steveluc@microsoft.com>
Sudheesh Singanamalla <sudheesh1995@outlook.com>
Tarik <tarik@pushmote.com> # Tarik Ozket
Tetsuharu OHZEKI <saneyuki.snyk@gmail.com> # Tetsuharu Ohzeki
Tien Nguyen <tihoanh@microsoft.com> tien <hoanhtien@users.noreply.github.com> unknown <tihoanh@microsoft.com> #Tien Hoanhtien
@@ -133,6 +159,7 @@ Tingan Ho <tingan87@gmail.com>
togru <v3nomzxgt8@gmail.com> # togru
Tomas Grubliauskas <tgrubliauskas@gmail.com>
ToddThomson <achilles@telus.net> # Todd Thomson
Torben Fitschen <torben.fitschen@mayflower.de>
TruongSinh Tran-Nguyen <i@truongsinh.pro>
vilicvane <i@vilic.info> # Vilic Vane
Vladimir Matveev <vladima@microsoft.com> vladima <vladima@microsoft.com> v2m <desco.by@gmail.com>
@@ -140,7 +167,9 @@ Wesley Wigham <t-weswig@microsoft.com> Wesley Wigham <wwigham@gmail.com>
York Yao <plantain-00@users.noreply.github.com> york yao <yaoao12306@outlook.com> yaoyao <yaoyao12306@163.com>
Yuichi Nukiyama <oscar.wilde84@hotmail.co.jp> YuichiNukiyama <oscar.wilde84@hotmail.co.jp>
Zev Spitz <shivisi@etrog.net.il>
Zhengbo Li <zhengbli@microsoft.com> zhengbli <zhengbli@microsoft.com> Zhengbo Li <Zhengbo Li> Zhengbo Li <zhengbli@mirosoft.com> tinza123 <li.zhengbo@outlook.com> unknown <zhengbli@zhengblit430.redmond.corp.microsoft.com> Zhengbo Li <Zhengbo Li>
Zhengbo Li <zhengbli@microsoft.com> zhengbli <zhengbli@microsoft.com> Zhengbo Li <Zhengbo Li> Zhengbo Li <zhengbli@mirosoft.com> tinza123 <li.zhengbo@outlook.com> unknown <zhengbli@zhengblit430.redmond.corp.microsoft.com> Zhengbo Li <Zhengbo Li> zhengbli <zhengli@microsoft.com>
zhongsp <patrick.zhongsp@gmail.com> # Patrick Zhong
T18970237136 <T18970237136@users.noreply.github.com> # @T18970237136
JBerger <JBerger@melco.com>
JBerger <JBerger@melco.com>
bootstraponline <code@bootstraponline.com> # @bootstraponline
yortus <yortus@gmail.com> # @yortus
+31 -1
View File
@@ -5,7 +5,10 @@ TypeScript is authored by:
* Ahmad Farid
* Alex Eagle
* Alexander Kuvaev
* Alexander Rusakov
* Anatoly Ressin
* Anders Hejlsberg
* Andrej Baran
* Andrew Z Allen
* Andy Hanson
* Anil Anar
@@ -16,17 +19,21 @@ TypeScript is authored by:
* Avery Morin
* Basarat Ali Syed
* Ben Duffield
* Ben Mosher
* Bill Ticehurst
* Blake Embrey
* @bootstraponline
* Bowden Kelly
* Brett Mayen
* Bryan Forbes
* Caitlin Potter
* Chris Bubernak
* Christophe Vidal
* Chuck Jazdzewski
* Colby Russell
* Colin Snover
* Cyrus Najmabadi
* Dafrok Zhang
* Dan Corder
* Dan Quirk
* Daniel Rosenwasser
@@ -36,17 +43,22 @@ TypeScript is authored by:
* Dick van den Brink
* Dirk Bäumer
* Dirk Holtwick
* Dom Chen
* Doug Ilijev
* Eric Tsang
* Erik Edrosa
* Ethan Rubio
* Evan Martin
* Evan Sebastian
* Eyas Sharaiha
* Fabian Cook
* @falsandtru
* Frank Wallis
* František Žiačik
* František Žiacik
* Gabe Moothart
* Gabriel Isenberg
* Gilad Peleg
* Godfrey Chan
* Graeme Wicksted
* Guillaume Salles
* Guy Bedford
@@ -56,6 +68,7 @@ TypeScript is authored by:
* Ingvar Stepanyan
* Isiah Meadows
* Ivo Gabe de Wolff
* Jakub Młokosiewicz
* James Whitney
* Jason Freeman
* Jason Killian
@@ -71,30 +84,39 @@ TypeScript is authored by:
* Jonathan Park
* Jonathan Toland
* Jonathan Turner
* Josh Abernathy
* Josh Kalderimis
* Josh Soref
* Juan Luis Boya García
* Julian Williams
* Justin Bay
* Justin Johansson
* Kagami Sascha Rosylight
* Kanchalai Tanglertsampan
* Keith Mashinter
* Ken Howard
* Kenji Imamula
* Kevin Lang
* Kyle Kelley
* Lorant Pinter
* Lucien Greathouse
* Lukas Elmer
* Marin Marinov
* Martin Vseticka
* Masahiro Wakame
* Matt McCutchen
* Max Deepfield
* Micah Zoltu
* Michael
* Mohamed Hegazy
* Nathan Shively-Sanders
* Nathan Yee
* Nima Zahedi
* Noah Chen
* Noj Vek
* Oleg Mihailik
* Oleksandr Chekhovskyi
* Omer Sheikh
* Oskar Segersva¨rd
* Patrick Zhong
* Paul van Brenk
@@ -109,21 +131,27 @@ TypeScript is authored by:
* Rado Kirov
* Richard Knoll
* Ron Buckton
* Rostislav Galimsky
* Rowan Wyborn
* Ryan Cavanaugh
* Ryohei Ikegami
* Sam El-Husseini
* Sarangan Rajamanickam
* Sergey Shandar
* Sheetal Nandi
* Shengping Zhong
* Shyyko Serhiy
* Simon Hürlimann
* Slawomir Sadziak
* Solal Pirelli
* Stan Thomas
* Stanislav Sysoev
* Steve Lucco
* Sudheesh Singanamalla
* Sébastien Arod
* @T18970237136
* Tarik Ozket
* Tetsuharu Ohzeki
* Tien Hoanhtien
* Tim Perry
* Tim Viiding-Spader
@@ -131,11 +159,13 @@ TypeScript is authored by:
* Todd Thomson
* togru
* Tomas Grubliauskas
* Torben Fitschen
* TruongSinh Tran-Nguyen
* Vilic Vane
* Vladimir Matveev
* Wesley Wigham
* York Yao
* @yortus
* Yuichi Nukiyama
* Zev Spitz
* Zhengbo Li
+2
View File
@@ -171,6 +171,7 @@ var servicesSources = [
var serverCoreSources = [
"types.d.ts",
"shared.ts",
"utilities.ts",
"scriptVersionCache.ts",
"typingsCache.ts",
@@ -193,6 +194,7 @@ var cancellationTokenSources = [
var typingsInstallerSources = [
"../types.d.ts",
"../shared.ts",
"typingsInstaller.ts",
"nodeTypingsInstaller.ts"
].map(function (f) {
+1 -1
View File
@@ -76,7 +76,7 @@
"travis-fold": "latest",
"ts-node": "latest",
"tsd": "latest",
"tslint": "next",
"tslint": "4.0.0-dev.0",
"typescript": "next"
},
"scripts": {
+82 -8
View File
@@ -499,8 +499,8 @@ namespace ts {
const saveReturnTarget = currentReturnTarget;
const saveActiveLabels = activeLabels;
const saveHasExplicitReturn = hasExplicitReturn;
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !!getImmediatelyInvokedFunctionExpression(node);
// An IIFE is considered part of the containing control flow. Return statements behave
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasModifier(node, ModifierFlags.Async) && !!getImmediatelyInvokedFunctionExpression(node);
// A non-async IIFE is considered part of the containing control flow. Return statements behave
// similarly to break statements that exit to a label just past the statement body.
if (isIIFE) {
currentReturnTarget = createBranchLabel();
@@ -560,6 +560,7 @@ namespace ts {
skipTransformFlagAggregation = true;
bindChildrenWorker(node);
skipTransformFlagAggregation = false;
subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
}
else {
const savedSubtreeTransformFlags = subtreeTransformFlags;
@@ -892,8 +893,13 @@ namespace ts {
function bindDoStatement(node: DoStatement): void {
const preDoLabel = createLoopLabel();
const preConditionLabel = createBranchLabel();
const postDoLabel = createBranchLabel();
const enclosingLabeledStatement = node.parent.kind === SyntaxKind.LabeledStatement
? lastOrUndefined(activeLabels)
: undefined;
// if do statement is wrapped in labeled statement then target labels for break/continue with or without
// label should be the same
const preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel();
const postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel();
addAntecedent(preDoLabel, currentFlow);
currentFlow = preDoLabel;
bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
@@ -1111,8 +1117,11 @@ namespace ts {
if (!activeLabel.referenced && !options.allowUnusedLabels) {
file.bindDiagnostics.push(createDiagnosticForNode(node.label, Diagnostics.Unused_label));
}
addAntecedent(postStatementLabel, currentFlow);
currentFlow = finishFlowLabel(postStatementLabel);
if (!node.statement || node.statement.kind !== SyntaxKind.DoStatement) {
// do statement sets current flow inside bindDoStatement
addAntecedent(postStatementLabel, currentFlow);
currentFlow = finishFlowLabel(postStatementLabel);
}
}
function bindDestructuringTargetFlow(node: Expression) {
@@ -1201,9 +1210,9 @@ namespace ts {
}
else {
forEachChild(node, bind);
if (operator === SyntaxKind.EqualsToken && !isAssignmentTarget(node)) {
if (isAssignmentOperator(operator) && !isAssignmentTarget(node)) {
bindAssignmentTargetFlow(node.left);
if (node.left.kind === SyntaxKind.ElementAccessExpression) {
if (operator === SyntaxKind.EqualsToken && node.left.kind === SyntaxKind.ElementAccessExpression) {
const elementAccess = <ElementAccessExpression>node.left;
if (isNarrowableOperand(elementAccess.expression)) {
currentFlow = createFlowArrayMutation(currentFlow, node);
@@ -1226,9 +1235,11 @@ namespace ts {
const postExpressionLabel = createBranchLabel();
bindCondition(node.condition, trueLabel, falseLabel);
currentFlow = finishFlowLabel(trueLabel);
bind(node.questionToken);
bind(node.whenTrue);
addAntecedent(postExpressionLabel, currentFlow);
currentFlow = finishFlowLabel(falseLabel);
bind(node.colonToken);
bind(node.whenFalse);
addAntecedent(postExpressionLabel, currentFlow);
currentFlow = finishFlowLabel(postExpressionLabel);
@@ -3089,6 +3100,8 @@ namespace ts {
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ThisType:
case SyntaxKind.TypeOperator:
case SyntaxKind.IndexedAccessType:
case SyntaxKind.LiteralType:
// Types and signatures are TypeScript syntax, and exclude all other facts.
transformFlags = TransformFlags.AssertTypeScript;
@@ -3194,4 +3207,65 @@ namespace ts {
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
return transformFlags & ~excludeFlags;
}
/**
* Gets the transform flags to exclude when unioning the transform flags of a subtree.
*
* NOTE: This needs to be kept up-to-date with the exclusions used in `computeTransformFlagsForNode`.
* For performance reasons, `computeTransformFlagsForNode` uses local constant values rather
* than calling this function.
*/
/* @internal */
export function getTransformFlagsSubtreeExclusions(kind: SyntaxKind) {
if (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) {
return TransformFlags.TypeExcludes;
}
switch (kind) {
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.ArrayLiteralExpression:
return TransformFlags.ArrayLiteralOrCallOrNewExcludes;
case SyntaxKind.ModuleDeclaration:
return TransformFlags.ModuleExcludes;
case SyntaxKind.Parameter:
return TransformFlags.ParameterExcludes;
case SyntaxKind.ArrowFunction:
return TransformFlags.ArrowFunctionExcludes;
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
return TransformFlags.FunctionExcludes;
case SyntaxKind.VariableDeclarationList:
return TransformFlags.VariableDeclarationListExcludes;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
return TransformFlags.ClassExcludes;
case SyntaxKind.Constructor:
return TransformFlags.ConstructorExcludes;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return TransformFlags.MethodOrAccessorExcludes;
case SyntaxKind.AnyKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.NeverKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.TypeParameter:
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
return TransformFlags.TypeExcludes;
case SyntaxKind.ObjectLiteralExpression:
return TransformFlags.ObjectLiteralExcludes;
default:
return TransformFlags.NodeExcludes;
}
}
}
+471 -386
View File
File diff suppressed because it is too large Load Diff
+21 -9
View File
@@ -1008,9 +1008,7 @@ namespace ts {
function convertTypingOptionsFromJsonWorker(jsonOptions: any,
basePath: string, errors: Diagnostic[], configFileName?: string): TypingOptions {
const options: TypingOptions = getBaseFileName(configFileName) === "jsconfig.json"
? { enableAutoDiscovery: true, include: [], exclude: [] }
: { enableAutoDiscovery: false, include: [], exclude: [] };
const options: TypingOptions = { enableAutoDiscovery: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
convertOptionsFromJson(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors);
return options;
}
@@ -1263,12 +1261,13 @@ namespace ts {
/**
* Gets directories in a set of include patterns that should be watched for changes.
*/
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean) {
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): Map<WatchDirectoryFlags> {
// We watch a directory recursively if it contains a wildcard anywhere in a directory segment
// of the pattern:
//
// /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder recursively
// /a/b/*/d - Watch /a/b recursively to catch any d in any immediate subfolder, even if a new subfolder is added
// /a/b - Watch /a/b recursively to catch changes to anything in any recursive subfoler
//
// We watch a directory without recursion if it contains a wildcard in the file segment of
// the pattern:
@@ -1281,15 +1280,14 @@ namespace ts {
if (include !== undefined) {
const recursiveKeys: string[] = [];
for (const file of include) {
const name = normalizePath(combinePaths(path, file));
if (excludeRegex && excludeRegex.test(name)) {
const spec = normalizePath(combinePaths(path, file));
if (excludeRegex && excludeRegex.test(spec)) {
continue;
}
const match = wildcardDirectoryPattern.exec(name);
const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
if (match) {
const key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase();
const flags = watchRecursivePattern.test(name) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None;
const { key, flags } = match;
const existingFlags = wildcardDirectories[key];
if (existingFlags === undefined || existingFlags < flags) {
wildcardDirectories[key] = flags;
@@ -1313,6 +1311,20 @@ namespace ts {
return wildcardDirectories;
}
function getWildcardDirectoryFromSpec(spec: string, useCaseSensitiveFileNames: boolean): { key: string, flags: WatchDirectoryFlags } | undefined {
const match = wildcardDirectoryPattern.exec(spec);
if (match) {
return {
key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(),
flags: watchRecursivePattern.test(spec) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None
};
}
if (isImplicitGlob(spec)) {
return { key: spec, flags: WatchDirectoryFlags.Recursive };
}
return undefined;
}
/**
* Determines whether a literal or wildcard file has already been included that has a higher
* extension priority.
+140 -78
View File
@@ -446,8 +446,8 @@ namespace ts {
}
export function concatenate<T>(array1: T[], array2: T[]): T[] {
if (!array2 || !array2.length) return array1;
if (!array1 || !array1.length) return array2;
if (!some(array2)) return array1;
if (!some(array1)) return array2;
return [...array1, ...array2];
}
@@ -527,6 +527,27 @@ namespace ts {
return result || array;
}
/**
* Gets the relative complement of `arrayA` with respect to `b`, returning the elements that
* are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted
* based on the provided comparer.
*/
export function relativeComplement<T>(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer: (x: T, y: T) => Comparison = compareValues, offsetA = 0, offsetB = 0): T[] | undefined {
if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) return arrayB;
const result: T[] = [];
outer: for (; offsetB < arrayB.length; offsetB++) {
inner: for (; offsetA < arrayA.length; offsetA++) {
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case Comparison.LessThan: break inner;
case Comparison.EqualTo: continue outer;
case Comparison.GreaterThan: continue inner;
}
}
result.push(arrayB[offsetB]);
}
return result;
}
export function sum(array: any[], prop: string): number {
let result = 0;
for (const v of array) {
@@ -636,12 +657,12 @@ namespace ts {
* @param array A sorted array whose first element must be no larger than number
* @param number The value to be searched for in the array.
*/
export function binarySearch<T>(array: T[], value: T, comparer?: (v1: T, v2: T) => number): number {
export function binarySearch<T>(array: T[], value: T, comparer?: (v1: T, v2: T) => number, offset?: number): number {
if (!array || array.length === 0) {
return -1;
}
let low = 0;
let low = offset || 0;
let high = array.length - 1;
comparer = comparer !== undefined
? comparer
@@ -1116,6 +1137,18 @@ namespace ts {
};
}
export function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic {
return {
file: undefined,
start: undefined,
length: undefined,
code: chain.code,
category: chain.category,
messageText: chain.next ? chain : chain.messageText
};
}
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage): DiagnosticMessageChain {
let text = getLocaleSpecificMessage(message);
@@ -1322,7 +1355,7 @@ namespace ts {
*/
export function getDirectoryPath(path: Path): Path;
export function getDirectoryPath(path: string): string;
export function getDirectoryPath(path: string): any {
export function getDirectoryPath(path: string): string {
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
}
@@ -1582,6 +1615,10 @@ namespace ts {
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
export function hasExtension(fileName: string): boolean {
return getBaseFileName(fileName).indexOf(".") >= 0;
}
export function fileExtensionIs(path: string, extension: string): boolean {
return path.length > extension.length && endsWith(path, extension);
}
@@ -1627,73 +1664,21 @@ namespace ts {
let pattern = "";
let hasWrittenSubpattern = false;
spec: for (const spec of specs) {
for (const spec of specs) {
if (!spec) {
continue;
}
let subpattern = "";
let hasRecursiveDirectoryWildcard = false;
let hasWrittenComponent = false;
const components = getNormalizedPathComponents(spec, basePath);
if (usage !== "exclude" && components[components.length - 1] === "**") {
continue spec;
}
// getNormalizedPathComponents includes the separator for the root component.
// We need to remove to create our regex correctly.
components[0] = removeTrailingDirectorySeparator(components[0]);
let optionalCount = 0;
for (let component of components) {
if (component === "**") {
if (hasRecursiveDirectoryWildcard) {
continue spec;
}
subpattern += doubleAsteriskRegexFragment;
hasRecursiveDirectoryWildcard = true;
hasWrittenComponent = true;
}
else {
if (usage === "directories") {
subpattern += "(";
optionalCount++;
}
if (hasWrittenComponent) {
subpattern += directorySeparator;
}
if (usage !== "exclude") {
// The * and ? wildcards should not match directories or files that start with . if they
// appear first in a component. Dotted directories and files can be included explicitly
// like so: **/.*/.*
if (component.charCodeAt(0) === CharacterCodes.asterisk) {
subpattern += "([^./]" + singleAsteriskRegexFragment + ")?";
component = component.substr(1);
}
else if (component.charCodeAt(0) === CharacterCodes.question) {
subpattern += "[^./]";
component = component.substr(1);
}
}
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
hasWrittenComponent = true;
}
}
while (optionalCount > 0) {
subpattern += ")?";
optionalCount--;
const subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter);
if (subPattern === undefined) {
continue;
}
if (hasWrittenSubpattern) {
pattern += "|";
}
pattern += "(" + subpattern + ")";
pattern += "(" + subPattern + ")";
hasWrittenSubpattern = true;
}
@@ -1701,7 +1686,83 @@ namespace ts {
return undefined;
}
return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$");
// If excluding, match "foo/bar/baz...", but if including, only allow "foo".
const terminator = usage === "exclude" ? "($|/)" : "$";
return `^(${pattern})${terminator}`;
}
/**
* An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension,
* and does not contain any glob characters itself.
*/
export function isImplicitGlob(lastPathComponent: string): boolean {
return !/[.*?]/.test(lastPathComponent);
}
function getSubPatternFromSpec(spec: string, basePath: string, usage: "files" | "directories" | "exclude", singleAsteriskRegexFragment: string, doubleAsteriskRegexFragment: string, replaceWildcardCharacter: (match: string) => string): string | undefined {
let subpattern = "";
let hasRecursiveDirectoryWildcard = false;
let hasWrittenComponent = false;
const components = getNormalizedPathComponents(spec, basePath);
const lastComponent = lastOrUndefined(components);
if (usage !== "exclude" && lastComponent === "**") {
return undefined;
}
// getNormalizedPathComponents includes the separator for the root component.
// We need to remove to create our regex correctly.
components[0] = removeTrailingDirectorySeparator(components[0]);
if (isImplicitGlob(lastComponent)) {
components.push("**", "*");
}
let optionalCount = 0;
for (let component of components) {
if (component === "**") {
if (hasRecursiveDirectoryWildcard) {
return undefined;
}
subpattern += doubleAsteriskRegexFragment;
hasRecursiveDirectoryWildcard = true;
}
else {
if (usage === "directories") {
subpattern += "(";
optionalCount++;
}
if (hasWrittenComponent) {
subpattern += directorySeparator;
}
if (usage !== "exclude") {
// The * and ? wildcards should not match directories or files that start with . if they
// appear first in a component. Dotted directories and files can be included explicitly
// like so: **/.*/.*
if (component.charCodeAt(0) === CharacterCodes.asterisk) {
subpattern += "([^./]" + singleAsteriskRegexFragment + ")?";
component = component.substr(1);
}
else if (component.charCodeAt(0) === CharacterCodes.question) {
subpattern += "[^./]";
component = component.substr(1);
}
}
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
}
hasWrittenComponent = true;
}
while (optionalCount > 0) {
subpattern += ")?";
optionalCount--;
}
return subpattern;
}
function replaceWildCardCharacterFiles(match: string) {
@@ -1788,6 +1849,7 @@ namespace ts {
function getBasePaths(path: string, includes: string[], useCaseSensitiveFileNames: boolean) {
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
const basePaths: string[] = [path];
if (includes) {
// Storage for literal base paths amongst the include patterns.
const includeBasePaths: string[] = [];
@@ -1795,14 +1857,8 @@ namespace ts {
// We also need to check the relative paths by converting them to absolute and normalizing
// in case they escape the base path (e.g "..\somedirectory")
const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
const includeBasePath = wildcardOffset < 0
? removeTrailingDirectorySeparator(getDirectoryPath(absolute))
: absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
// Append the literal and canonical candidate base paths.
includeBasePaths.push(includeBasePath);
includeBasePaths.push(getIncludeBasePath(absolute));
}
// Sort the offsets array using either the literal or canonical path representations.
@@ -1810,21 +1866,27 @@ namespace ts {
// Iterate over each include base path and include unique base paths that are not a
// subpath of an existing base path
include: for (let i = 0; i < includeBasePaths.length; i++) {
const includeBasePath = includeBasePaths[i];
for (let j = 0; j < basePaths.length; j++) {
if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) {
continue include;
}
for (const includeBasePath of includeBasePaths) {
if (ts.every(basePaths, basePath => !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames))) {
basePaths.push(includeBasePath);
}
basePaths.push(includeBasePath);
}
}
return basePaths;
}
function getIncludeBasePath(absolute: string): string {
const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
if (wildcardOffset < 0) {
// No "*" or "?" in the path
return !hasExtension(absolute)
? absolute
: removeTrailingDirectorySeparator(getDirectoryPath(absolute));
}
return absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
}
export function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind {
// Using scriptKind as a condition handles both:
// - 'scriptKind' is unspecified and thus it is `undefined`
+17
View File
@@ -413,6 +413,10 @@ namespace ts {
return emitIntersectionType(<IntersectionTypeNode>type);
case SyntaxKind.ParenthesizedType:
return emitParenType(<ParenthesizedTypeNode>type);
case SyntaxKind.TypeOperator:
return emitTypeOperator(<TypeOperatorNode>type);
case SyntaxKind.IndexedAccessType:
return emitPropertyAccessType(<IndexedAccessTypeNode>type);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
return emitSignatureDeclarationWithJsDocComments(<FunctionOrConstructorTypeNode>type);
@@ -506,6 +510,19 @@ namespace ts {
write(")");
}
function emitTypeOperator(type: TypeOperatorNode) {
write(tokenToString(type.operator));
write(" ");
emitType(type.type);
}
function emitPropertyAccessType(node: IndexedAccessTypeNode) {
emitType(node.objectType);
write("[");
emitType(node.indexType);
write("]");
}
function emitTypeLiteral(type: TypeLiteralNode) {
write("{");
if (type.members.length) {
+54 -22
View File
@@ -163,7 +163,7 @@
"category": "Error",
"code": 1054
},
"Type '{0}' is not a valid async function return type.": {
"Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.": {
"category": "Error",
"code": 1055
},
@@ -1071,7 +1071,7 @@
"category": "Error",
"code": 2356
},
"The operand of an increment or decrement operator must be a variable, property or indexer.": {
"The operand of an increment or decrement operator must be a variable or a property access.": {
"category": "Error",
"code": 2357
},
@@ -1099,7 +1099,7 @@
"category": "Error",
"code": 2363
},
"Invalid left-hand side of assignment expression.": {
"The left-hand side of an assignment expression must be a variable or a property access.": {
"category": "Error",
"code": 2364
},
@@ -1259,7 +1259,7 @@
"category": "Error",
"code": 2405
},
"Invalid left-hand side in 'for...in' statement.": {
"The left-hand side of a 'for...in' statement must be a variable or a property access.": {
"category": "Error",
"code": 2406
},
@@ -1411,14 +1411,6 @@
"category": "Error",
"code": 2448
},
"The operand of an increment or decrement operator cannot be a constant or a read-only property.": {
"category": "Error",
"code": 2449
},
"Left-hand side of assignment expression cannot be a constant or a read-only property.": {
"category": "Error",
"code": 2450
},
"Cannot redeclare block-scoped variable '{0}'.": {
"category": "Error",
"code": 2451
@@ -1551,15 +1543,7 @@
"category": "Error",
"code": 2484
},
"The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.": {
"category": "Error",
"code": 2485
},
"The left-hand side of a 'for...in' statement cannot be a constant or a read-only property.": {
"category": "Error",
"code": 2486
},
"Invalid left-hand side in 'for...of' statement.": {
"The left-hand side of a 'for...of' statement must be a variable or a property access.": {
"category": "Error",
"code": 2487
},
@@ -1747,6 +1731,34 @@
"category": "Error",
"code": 2535
},
"Type '{0}' is not constrained to 'keyof {1}'.": {
"category": "Error",
"code": 2536
},
"Type '{0}' has no matching index signature for type '{1}'.": {
"category": "Error",
"code": 2537
},
"Type '{0}' cannot be used as an index type.": {
"category": "Error",
"code": 2538
},
"Cannot assign to '{0}' because it is not a variable.": {
"category": "Error",
"code": 2539
},
"Cannot assign to '{0}' because it is a constant or a read-only property.": {
"category": "Error",
"code": 2540
},
"The target of an assignment must be a variable or a property access.": {
"category": "Error",
"code": 2541
},
"Index signature in type '{0}' only permits reading.": {
"category": "Error",
"code": 2542
},
"JSX element attributes type '{0}' may not be a union type.": {
"category": "Error",
"code": 2600
@@ -1839,6 +1851,10 @@
"category": "Error",
"code": 2664
},
"Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented.": {
"category": "Error",
"code": 2665
},
"Exports and export assignments are not permitted in module augmentations.": {
"category": "Error",
"code": 2666
@@ -1963,6 +1979,10 @@
"category": "Error",
"code": 2696
},
"An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": {
"category": "Error",
"code": 2697
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@@ -2869,6 +2889,14 @@
"category": "Error",
"code": 6143
},
"Module '{0}' was resolved as locally declared ambient module in file '{1}'.": {
"category": "Message",
"code": 6144
},
"Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified.": {
"category": "Message",
"code": 6145
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7005
@@ -2905,7 +2933,7 @@
"category": "Error",
"code": 7016
},
"Index signature of object type implicitly has an 'any' type.": {
"Element implicitly has an 'any' type because type '{0}' has no index signature.": {
"category": "Error",
"code": 7017
},
@@ -3130,5 +3158,9 @@
"Implement inherited abstract class": {
"category": "Message",
"code": 90007
},
"Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig": {
"category": "Error",
"code": 90009
}
}
+17
View File
@@ -418,6 +418,10 @@ namespace ts {
return emitExpressionWithTypeArguments(<ExpressionWithTypeArguments>node);
case SyntaxKind.ThisType:
return emitThisType();
case SyntaxKind.TypeOperator:
return emitTypeOperator(<TypeOperatorNode>node);
case SyntaxKind.IndexedAccessType:
return emitPropertyAccessType(<IndexedAccessTypeNode>node);
case SyntaxKind.LiteralType:
return emitLiteralType(<LiteralTypeNode>node);
@@ -909,6 +913,19 @@ namespace ts {
write("this");
}
function emitTypeOperator(node: TypeOperatorNode) {
writeTokenText(node.operator);
write(" ");
emit(node.type);
}
function emitPropertyAccessType(node: IndexedAccessTypeNode) {
emit(node.objectType);
write("[");
emit(node.indexType);
write("]");
}
function emitLiteralType(node: LiteralTypeNode) {
emitExpression(node.literal);
}
+6 -3
View File
@@ -2,12 +2,15 @@
/// <reference path="diagnosticInformationMap.generated.ts" />
namespace ts {
function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
function trace(host: ModuleResolutionHost): void {
/* @internal */
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
export function trace(host: ModuleResolutionHost): void {
host.trace(formatMessage.apply(undefined, arguments));
}
function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean {
/* @internal */
export function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean {
return compilerOptions.traceResolution && host.trace !== undefined;
}
+35 -6
View File
@@ -134,7 +134,11 @@ namespace ts {
case SyntaxKind.IntersectionType:
return visitNodes(cbNodes, (<UnionOrIntersectionTypeNode>node).types);
case SyntaxKind.ParenthesizedType:
return visitNode(cbNode, (<ParenthesizedTypeNode>node).type);
case SyntaxKind.TypeOperator:
return visitNode(cbNode, (<ParenthesizedTypeNode | TypeOperatorNode>node).type);
case SyntaxKind.IndexedAccessType:
return visitNode(cbNode, (<IndexedAccessTypeNode>node).objectType) ||
visitNode(cbNode, (<IndexedAccessTypeNode>node).indexType);
case SyntaxKind.LiteralType:
return visitNode(cbNode, (<LiteralTypeNode>node).literal);
case SyntaxKind.ObjectBindingPattern:
@@ -2519,14 +2523,39 @@ namespace ts {
function parseArrayTypeOrHigher(): TypeNode {
let type = parseNonArrayType();
while (!scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.OpenBracketToken)) {
parseExpected(SyntaxKind.CloseBracketToken);
const node = <ArrayTypeNode>createNode(SyntaxKind.ArrayType, type.pos);
node.elementType = type;
type = finishNode(node);
if (isStartOfType()) {
const node = <IndexedAccessTypeNode>createNode(SyntaxKind.IndexedAccessType, type.pos);
node.objectType = type;
node.indexType = parseType();
parseExpected(SyntaxKind.CloseBracketToken);
type = finishNode(node);
}
else {
const node = <ArrayTypeNode>createNode(SyntaxKind.ArrayType, type.pos);
node.elementType = type;
parseExpected(SyntaxKind.CloseBracketToken);
type = finishNode(node);
}
}
return type;
}
function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword) {
const node = <TypeOperatorNode>createNode(SyntaxKind.TypeOperator);
parseExpected(operator);
node.operator = operator;
node.type = parseTypeOperatorOrHigher();
return finishNode(node);
}
function parseTypeOperatorOrHigher(): TypeNode {
switch (token()) {
case SyntaxKind.KeyOfKeyword:
return parseTypeOperator(SyntaxKind.KeyOfKeyword);
}
return parseArrayTypeOrHigher();
}
function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode {
let type = parseConstituentType();
if (token() === operator) {
@@ -2543,7 +2572,7 @@ namespace ts {
}
function parseIntersectionTypeOrHigher(): TypeNode {
return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseArrayTypeOrHigher, SyntaxKind.AmpersandToken);
return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseTypeOperatorOrHigher, SyntaxKind.AmpersandToken);
}
function parseUnionTypeOrHigher(): TypeNode {
+201 -44
View File
@@ -239,11 +239,11 @@ namespace ts {
const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
const fileName = diagnostic.file.fileName;
const relativeFileName = convertToRelativePath(fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName));
output += `${ relativeFileName }(${ line + 1 },${ character + 1 }): `;
output += `${relativeFileName}(${line + 1},${character + 1}): `;
}
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }${ host.getNewLine() }`;
output += `${category} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())}${host.getNewLine()}`;
}
return output;
}
@@ -420,6 +420,7 @@ namespace ts {
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
isSourceFileFromExternalLibrary,
dropDiagnosticsProducingTypeChecker
};
@@ -462,6 +463,130 @@ namespace ts {
return classifiableNames;
}
interface OldProgramState {
program: Program;
file: SourceFile;
modifiedFilePaths: Path[];
}
function resolveModuleNamesReusingOldState(moduleNames: string[], containingFile: string, file: SourceFile, oldProgramState?: OldProgramState) {
if (!oldProgramState && !file.ambientModuleNames.length) {
// if old program state is not supplied and file does not contain locally defined ambient modules
// then the best we can do is fallback to the default logic
return resolveModuleNamesWorker(moduleNames, containingFile);
}
// at this point we know that either
// - file has local declarations for ambient modules
// OR
// - old program state is available
// OR
// - both of items above
// With this it is possible that we can tell how some module names from the initial list will be resolved
// without doing actual resolution (in particular if some name was resolved to ambient module).
// Such names should be excluded from the list of module names that will be provided to `resolveModuleNamesWorker`
// since we don't want to resolve them again.
// this is a list of modules for which we cannot predict resolution so they should be actually resolved
let unknownModuleNames: string[];
// this is a list of combined results assembles from predicted and resolved results.
// Order in this list matches the order in the original list of module names `moduleNames` which is important
// so later we can split results to resolutions of modules and resolutions of module augmentations.
let result: ResolvedModuleFull[];
// a transient placeholder that is used to mark predicted resolution in the result list
const predictedToResolveToAmbientModuleMarker: ResolvedModuleFull = <any>{};
for (let i = 0; i < moduleNames.length; i++) {
const moduleName = moduleNames[i];
// module name is known to be resolved to ambient module if
// - module name is contained in the list of ambient modules that are locally declared in the file
// - in the old program module name was resolved to ambient module whose declaration is in non-modified file
// (so the same module declaration will land in the new program)
let isKnownToResolveToAmbientModule = false;
if (contains(file.ambientModuleNames, moduleName)) {
isKnownToResolveToAmbientModule = true;
if (isTraceEnabled(options, host)) {
trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile);
}
}
else {
isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState);
}
if (isKnownToResolveToAmbientModule) {
if (!unknownModuleNames) {
// found a first module name for which result can be prediced
// this means that this module name should not be passed to `resolveModuleNamesWorker`.
// We'll use a separate list for module names that are definitely unknown.
result = new Array(moduleNames.length);
// copy all module names that appear before the current one in the list
// since they are known to be unknown
unknownModuleNames = moduleNames.slice(0, i);
}
// mark prediced resolution in the result list
result[i] = predictedToResolveToAmbientModuleMarker;
}
else if (unknownModuleNames) {
// found unknown module name and we are already using separate list for those - add it to the list
unknownModuleNames.push(moduleName);
}
}
if (!unknownModuleNames) {
// we've looked throught the list but have not seen any predicted resolution
// use default logic
return resolveModuleNamesWorker(moduleNames, containingFile);
}
const resolutions = unknownModuleNames.length
? resolveModuleNamesWorker(unknownModuleNames, containingFile)
: emptyArray;
// combine results of resolutions and predicted results
let j = 0;
for (let i = 0; i < result.length; i++) {
if (result[i] == predictedToResolveToAmbientModuleMarker) {
result[i] = undefined;
}
else {
result[i] = resolutions[j];
j++;
}
}
Debug.assert(j === resolutions.length);
return result;
function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState?: OldProgramState): boolean {
if (!oldProgramState) {
return false;
}
const resolutionToFile = getResolvedModule(oldProgramState.file, moduleName);
if (resolutionToFile) {
// module used to be resolved to file - ignore it
return false;
}
const ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName);
if (!(ambientModule && ambientModule.declarations)) {
return false;
}
// at least one of declarations should come from non-modified source file
const firstUnmodifiedFile = forEach(ambientModule.declarations, d => {
const f = getSourceFileOfNode(d);
return !contains(oldProgramState.modifiedFilePaths, f.path) && f;
});
if (!firstUnmodifiedFile) {
return false;
}
if (isTraceEnabled(options, host)) {
trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName);
}
return true;
}
}
function tryReuseStructureFromOldProgram(): boolean {
if (!oldProgram) {
return false;
@@ -489,7 +614,7 @@ namespace ts {
// check if program source files has changed in the way that can affect structure of the program
const newSourceFiles: SourceFile[] = [];
const filePaths: Path[] = [];
const modifiedSourceFiles: SourceFile[] = [];
const modifiedSourceFiles: { oldFile: SourceFile, newFile: SourceFile }[] = [];
for (const oldSourceFile of oldProgram.getSourceFiles()) {
let newSourceFile = host.getSourceFileByPath
@@ -532,29 +657,8 @@ namespace ts {
return false;
}
const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
if (resolveModuleNamesWorker) {
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath);
// ensure that module resolution results are still correct
const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
if (resolveTypeReferenceDirectiveNamesWorker) {
const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, x => x.fileName);
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath);
// ensure that types resolutions are still correct
const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
// pass the cache of module/types resolutions from the old source file
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
modifiedSourceFiles.push(newSourceFile);
// tentatively approve the file
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
}
else {
// file has no changes - use it as is
@@ -565,6 +669,33 @@ namespace ts {
newSourceFiles.push(newSourceFile);
}
const modifiedFilePaths = modifiedSourceFiles.map(f => f.newFile.path);
// try to verify results of module resolution
for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
if (resolveModuleNamesWorker) {
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths });
// ensure that module resolution results are still correct
const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
if (resolveTypeReferenceDirectiveNamesWorker) {
const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, x => x.fileName);
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath);
// ensure that types resolutions are still correct
const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
// pass the cache of module/types resolutions from the old source file
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
}
// update fileName -> file mapping
for (let i = 0, len = newSourceFiles.length; i < len; i++) {
filesByName.set(filePaths[i], newSourceFiles[i]);
@@ -574,7 +705,7 @@ namespace ts {
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
for (const modifiedFile of modifiedSourceFiles) {
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
}
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
oldProgram.structureIsReused = true;
@@ -592,13 +723,17 @@ namespace ts {
getSourceFile: program.getSourceFile,
getSourceFileByPath: program.getSourceFileByPath,
getSourceFiles: program.getSourceFiles,
isSourceFileFromExternalLibrary: (file: SourceFile) => !!sourceFilesFoundSearchingNodeModules[file.path],
isSourceFileFromExternalLibrary,
writeFile: writeFileCallback || (
(fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)),
isEmitBlocked,
};
}
function isSourceFileFromExternalLibrary(file: SourceFile): boolean {
return sourceFilesFoundSearchingNodeModules[file.path];
}
function getDiagnosticsProducingTypeChecker() {
return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ true));
}
@@ -719,6 +854,14 @@ namespace ts {
}
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
// For JavaScript files, we report semantic errors for using TypeScript-only
// constructs from within a JavaScript file as syntactic errors.
if (isSourceFileJavaScript(sourceFile)) {
if (!sourceFile.additionalSyntacticDiagnostics) {
sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile);
}
return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
}
return sourceFile.parseDiagnostics;
}
@@ -751,12 +894,10 @@ namespace ts {
Debug.assert(!!sourceFile.bindDiagnostics);
const bindDiagnostics = sourceFile.bindDiagnostics;
// For JavaScript files, we don't want to report the normal typescript semantic errors.
// Instead, we just report errors for using TypeScript-only constructs from within a
// JavaScript file.
const checkDiagnostics = isSourceFileJavaScript(sourceFile) ?
getJavaScriptSemanticDiagnosticsForFile(sourceFile) :
typeChecker.getDiagnostics(sourceFile, cancellationToken);
// For JavaScript files, we don't want to report semantic errors.
// Instead, we'll report errors for using TypeScript-only constructs from within a
// JavaScript file when we get syntactic diagnostics for the file.
const checkDiagnostics = isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken);
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
@@ -764,7 +905,7 @@ namespace ts {
});
}
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
return runWithCancellationToken(() => {
const diagnostics: Diagnostic[] = [];
walk(sourceFile);
@@ -965,10 +1106,6 @@ namespace ts {
return sortAndDeduplicateDiagnostics(allDiagnostics);
}
function hasExtension(fileName: string): boolean {
return getBaseFileName(fileName).indexOf(".") >= 0;
}
function processRootFile(fileName: string, isDefaultLib: boolean) {
processSourceFile(normalizePath(fileName), isDefaultLib);
}
@@ -992,9 +1129,11 @@ namespace ts {
const isJavaScriptFile = isSourceFileJavaScript(file);
const isExternalModuleFile = isExternalModule(file);
const isDtsFile = isDeclarationFile(file);
let imports: LiteralExpression[];
let moduleAugmentations: LiteralExpression[];
let ambientModules: string[];
// If we are importing helpers, we need to add a synthetic reference to resolve the
// helpers library.
@@ -1016,6 +1155,7 @@ namespace ts {
file.imports = imports || emptyArray;
file.moduleAugmentations = moduleAugmentations || emptyArray;
file.ambientModuleNames = ambientModules || emptyArray;
return;
@@ -1051,6 +1191,10 @@ namespace ts {
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
}
else if (!inAmbientModule) {
if (isDtsFile) {
// for global .d.ts files record name of ambient module
(ambientModules || (ambientModules = [])).push(moduleName.text);
}
// An AmbientExternalModuleDeclaration declares an external module.
// This type of declaration is permitted only in the global module.
// The StringLiteral must specify a top - level external module name.
@@ -1296,7 +1440,7 @@ namespace ts {
if (file.imports.length || file.moduleAugmentations.length) {
file.resolvedModules = createMap<ResolvedModuleFull>();
const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file);
Debug.assert(resolutions.length === moduleNames.length);
for (let i = 0; i < moduleNames.length; i++) {
const resolution = resolutions[i];
@@ -1546,13 +1690,24 @@ namespace ts {
const emitFilePath = toPath(emitFileName, currentDirectory, getCanonicalFileName);
// Report error if the output overwrites input file
if (filesByName.contains(emitFilePath)) {
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
blockEmittingOfFile(emitFileName);
}
else {
let chain: DiagnosticMessageChain;
if (!options.configFilePath) {
// The program is from either an inferred project or an external project
chain = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig);
}
chain = chainDiagnosticMessages(chain, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
blockEmittingOfFile(emitFileName, createCompilerDiagnosticFromMessageChain(chain));
}
}
// Report error if multiple files write into same file
if (emitFilesSeen.contains(emitFilePath)) {
// Already seen the same emit file - report error
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
blockEmittingOfFile(emitFileName, createCompilerDiagnostic(Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
}
else {
emitFilesSeen.set(emitFilePath, true);
@@ -1561,9 +1716,11 @@ namespace ts {
}
}
function createEmitBlockingDiagnostics(emitFileName: string, message: DiagnosticMessage) {
function blockEmittingOfFile(emitFileName: string, diag?: Diagnostic) {
hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
programDiagnostics.add(createCompilerDiagnostic(message, emitFileName));
if (diag) {
programDiagnostics.add(diag);
}
}
}
+1
View File
@@ -90,6 +90,7 @@ namespace ts {
"instanceof": SyntaxKind.InstanceOfKeyword,
"interface": SyntaxKind.InterfaceKeyword,
"is": SyntaxKind.IsKeyword,
"keyof": SyntaxKind.KeyOfKeyword,
"let": SyntaxKind.LetKeyword,
"module": SyntaxKind.ModuleKeyword,
"namespace": SyntaxKind.NamespaceKeyword,
+9 -4
View File
@@ -17,7 +17,11 @@ namespace ts {
readFile(path: string, encoding?: string): string;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
/**
* @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that
* use native OS file watching
*/
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
resolvePath(path: string): string;
fileExists(path: string): boolean;
@@ -439,6 +443,7 @@ namespace ts {
return filter<string>(_fs.readdirSync(path), dir => fileSystemEntryExists(combinePaths(path, dir), FileSystemEntryKind.Directory));
}
const noOpFileWatcher: FileWatcher = { close: noop };
const nodeSystem: System = {
args: process.argv.slice(2),
newLine: _os.EOL,
@@ -448,7 +453,7 @@ namespace ts {
},
readFile,
writeFile,
watchFile: (fileName, callback) => {
watchFile: (fileName, callback, pollingInterval) => {
if (useNonPollingWatchers) {
const watchedFile = watchedFileSet.addFile(fileName, callback);
return {
@@ -456,7 +461,7 @@ namespace ts {
};
}
else {
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
_fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged);
return {
close: () => _fs.unwatchFile(fileName, fileChanged)
};
@@ -475,7 +480,7 @@ namespace ts {
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
let options: any;
if (!directoryExists(directoryName)) {
return;
return noOpFileWatcher;
}
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
+4
View File
@@ -328,6 +328,8 @@ namespace ts {
case SyntaxKind.IntersectionType:
case SyntaxKind.ParenthesizedType:
case SyntaxKind.ThisType:
case SyntaxKind.TypeOperator:
case SyntaxKind.IndexedAccessType:
case SyntaxKind.LiteralType:
// TypeScript type nodes are elided.
@@ -1744,6 +1746,8 @@ namespace ts {
}
// Fallthrough
case SyntaxKind.TypeQuery:
case SyntaxKind.TypeOperator:
case SyntaxKind.IndexedAccessType:
case SyntaxKind.TypeLiteral:
case SyntaxKind.AnyKeyword:
case SyntaxKind.ThisType:
+47 -11
View File
@@ -168,6 +168,7 @@ namespace ts {
DeclareKeyword,
GetKeyword,
IsKeyword,
KeyOfKeyword,
ModuleKeyword,
NamespaceKeyword,
NeverKeyword,
@@ -216,6 +217,8 @@ namespace ts {
IntersectionType,
ParenthesizedType,
ThisType,
TypeOperator,
IndexedAccessType,
LiteralType,
// Binding patterns
ObjectBindingPattern,
@@ -883,6 +886,18 @@ namespace ts {
type: TypeNode;
}
export interface TypeOperatorNode extends TypeNode {
kind: SyntaxKind.TypeOperator;
operator: SyntaxKind.KeyOfKeyword;
type: TypeNode;
}
export interface IndexedAccessTypeNode extends TypeNode {
kind: SyntaxKind.IndexedAccessType;
objectType: TypeNode;
indexType: TypeNode;
}
export interface LiteralTypeNode extends TypeNode {
kind: SyntaxKind.LiteralType;
literal: Expression;
@@ -954,10 +969,6 @@ namespace ts {
operator: PostfixUnaryOperator;
}
export interface PostfixExpression extends UnaryExpression {
_postfixExpressionBrand: any;
}
export interface LeftHandSideExpression extends IncrementExpression {
_leftHandSideExpressionBrand: any;
}
@@ -2089,6 +2100,9 @@ namespace ts {
// as well as code diagnostics).
/* @internal */ parseDiagnostics: Diagnostic[];
// Stores additional file level diagnostics reported by the program
/* @internal */ additionalSyntacticDiagnostics?: Diagnostic[];
// File level diagnostics reported by the binder.
/* @internal */ bindDiagnostics: Diagnostic[];
@@ -2104,6 +2118,7 @@ namespace ts {
/* @internal */ imports: LiteralExpression[];
/* @internal */ moduleAugmentations: LiteralExpression[];
/* @internal */ patternAmbientModules?: PatternAmbientModule[];
/* @internal */ ambientModuleNames: string[];
}
export interface ScriptReferenceHost {
@@ -2191,6 +2206,7 @@ namespace ts {
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
/* @internal */ getResolvedTypeReferenceDirectives(): Map<ResolvedTypeReferenceDirective>;
/* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean;
// For testing purposes only.
/* @internal */ structureIsReused?: boolean;
}
@@ -2296,6 +2312,8 @@ namespace ts {
isOptionalParameter(node: ParameterDeclaration): boolean;
getAmbientModules(): Symbol[];
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
// Should not be called directly. Should only be accessed through the Program instance.
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
/* @internal */ getGlobalDiagnostics(): Diagnostic[];
@@ -2678,14 +2696,16 @@ namespace ts {
Object = 1 << 15, // Object type
Union = 1 << 16, // Union (T | U)
Intersection = 1 << 17, // Intersection (T & U)
Index = 1 << 18, // keyof T
IndexedAccess = 1 << 19, // T[K]
/* @internal */
FreshLiteral = 1 << 18, // Fresh literal type
FreshLiteral = 1 << 20, // Fresh literal type
/* @internal */
ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type
ContainsWideningType = 1 << 21, // Type is or contains undefined or null widening type
/* @internal */
ContainsObjectLiteral = 1 << 20, // Type is or contains object literal type
ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type
/* @internal */
ContainsAnyFunctionType = 1 << 21, // Type is or contains object literal type
ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type
/* @internal */
Nullable = Undefined | Null,
@@ -2704,11 +2724,11 @@ namespace ts {
EnumLike = Enum | EnumLiteral,
UnionOrIntersection = Union | Intersection,
StructuredType = Object | Union | Intersection,
StructuredOrTypeParameter = StructuredType | TypeParameter,
StructuredOrTypeParameter = StructuredType | TypeParameter | Index,
// 'Narrowable' types are types where narrowing actually narrows.
// This *should* be every type other than null, undefined, void, and never
Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol,
Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol,
NotUnionOrUnit = Any | ESSymbol | Object,
/* @internal */
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
@@ -2871,9 +2891,22 @@ namespace ts {
/* @internal */
resolvedApparentType: Type;
/* @internal */
resolvedIndexType: IndexType;
/* @internal */
resolvedIndexedAccessTypes: IndexedAccessType[];
/* @internal */
isThisType?: boolean;
}
export interface IndexType extends Type {
type: TypeParameter;
}
export interface IndexedAccessType extends Type {
objectType: Type;
indexType: TypeParameter;
}
export const enum SignatureKind {
Call,
Construct,
@@ -2905,6 +2938,8 @@ namespace ts {
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
/* @internal */
typePredicate?: TypePredicate;
/* @internal */
instantiations?: Map<Signature>; // Generic signature instantiation cache
}
export const enum IndexKind {
@@ -2922,7 +2957,6 @@ namespace ts {
export interface TypeMapper {
(t: TypeParameter): Type;
mappedTypes?: Type[]; // Types mapped by this mapper
targetTypes?: Type[]; // Types substituted for mapped types
instantiations?: Type[]; // Cache of instantiations created using this type mapper.
context?: InferenceContext; // The inference context this mapper was created from.
// Only inference mappers have this set (in createInferenceMapper).
@@ -3040,6 +3074,7 @@ namespace ts {
moduleResolution?: ModuleResolutionKind;
newLine?: NewLineKind;
noEmit?: boolean;
/*@internal*/noEmitOverwritenFiles?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
@@ -3156,6 +3191,7 @@ namespace ts {
Pretty,
}
/** Either a parsed command line or a parsed tsconfig.json */
export interface ParsedCommandLine {
options: CompilerOptions;
typingOptions?: TypingOptions;
+67 -32
View File
@@ -388,8 +388,8 @@ namespace ts {
}
/** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */
export function isUntypedModuleSymbol(moduleSymbol: Symbol): boolean {
return !moduleSymbol.valueDeclaration || isShorthandAmbientModule(moduleSymbol.valueDeclaration);
export function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean {
return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
}
function isShorthandAmbientModule(node: Node): boolean {
@@ -470,6 +470,17 @@ namespace ts {
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
}
export function entityNameToString(name: EntityNameOrEntityNameExpression): string {
switch (name.kind) {
case SyntaxKind.Identifier:
return getFullWidth(name) === 0 ? unescapeIdentifier((<Identifier>name).text) : getTextOfNode(name);
case SyntaxKind.QualifiedName:
return entityNameToString((<QualifiedName>name).left) + "." + entityNameToString((<QualifiedName>name).right);
case SyntaxKind.PropertyAccessExpression:
return entityNameToString((<PropertyAccessEntityNameExpression>name).expression) + "." + entityNameToString((<PropertyAccessEntityNameExpression>name).name);
}
}
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic {
const sourceFile = getSourceFileOfNode(node);
const span = getErrorSpanForNode(sourceFile, node);
@@ -1028,17 +1039,19 @@ namespace ts {
}
export function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression {
if (node) {
switch (node.kind) {
case SyntaxKind.TypeReference:
return (<TypeReferenceNode>node).typeName;
case SyntaxKind.ExpressionWithTypeArguments:
Debug.assert(isEntityNameExpression((<ExpressionWithTypeArguments>node).expression));
return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression;
case SyntaxKind.Identifier:
case SyntaxKind.QualifiedName:
return (<EntityName><Node>node);
}
switch (node.kind) {
case SyntaxKind.TypeReference:
case SyntaxKind.JSDocTypeReference:
return (<TypeReferenceNode>node).typeName;
case SyntaxKind.ExpressionWithTypeArguments:
return isEntityNameExpression((<ExpressionWithTypeArguments>node).expression)
? <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression
: undefined;
case SyntaxKind.Identifier:
case SyntaxKind.QualifiedName:
return (<EntityName><Node>node);
}
return undefined;
@@ -1592,29 +1605,51 @@ namespace ts {
return node && node.dotDotDotToken !== undefined;
}
export const enum AssignmentKind {
None, Definite, Compound
}
export function getAssignmentTargetKind(node: Node): AssignmentKind {
let parent = node.parent;
while (true) {
switch (parent.kind) {
case SyntaxKind.BinaryExpression:
const binaryOperator = (<BinaryExpression>parent).operatorToken.kind;
return isAssignmentOperator(binaryOperator) && (<BinaryExpression>parent).left === node ?
binaryOperator === SyntaxKind.EqualsToken ? AssignmentKind.Definite : AssignmentKind.Compound :
AssignmentKind.None;
case SyntaxKind.PrefixUnaryExpression:
case SyntaxKind.PostfixUnaryExpression:
const unaryOperator = (<PrefixUnaryExpression | PostfixUnaryExpression>parent).operator;
return unaryOperator === SyntaxKind.PlusPlusToken || unaryOperator === SyntaxKind.MinusMinusToken ? AssignmentKind.Compound : AssignmentKind.None;
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
return (<ForInStatement | ForOfStatement>parent).initializer === node ? AssignmentKind.Definite : AssignmentKind.None;
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.SpreadElementExpression:
node = parent;
break;
case SyntaxKind.ShorthandPropertyAssignment:
if ((<ShorthandPropertyAssignment>parent).name !== node) {
return AssignmentKind.None;
}
// Fall through
case SyntaxKind.PropertyAssignment:
node = parent.parent;
break;
default:
return AssignmentKind.None;
}
parent = node.parent;
}
}
// A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property
// assignment in an object literal that is an assignment target, or if it is parented by an array literal that is
// an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'.
export function isAssignmentTarget(node: Node): boolean {
while (node.parent.kind === SyntaxKind.ParenthesizedExpression) {
node = node.parent;
}
while (true) {
const parent = node.parent;
if (parent.kind === SyntaxKind.ArrayLiteralExpression || parent.kind === SyntaxKind.SpreadElementExpression) {
node = parent;
continue;
}
if (parent.kind === SyntaxKind.PropertyAssignment || parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
node = parent.parent;
continue;
}
return parent.kind === SyntaxKind.BinaryExpression &&
isAssignmentOperator((<BinaryExpression>parent).operatorToken.kind) &&
(<BinaryExpression>parent).left === node ||
(parent.kind === SyntaxKind.ForInStatement || parent.kind === SyntaxKind.ForOfStatement) &&
(<ForInStatement | ForOfStatement>parent).initializer === node;
}
return getAssignmentTargetKind(node) !== AssignmentKind.None;
}
export function isNodeDescendantOf(node: Node, ancestor: Node): boolean {
+2 -60
View File
@@ -553,6 +553,7 @@ namespace ts {
return undefined;
}
aggregateTransformFlags(node);
const visited = visitor(node);
if (visited === node) {
return node;
@@ -621,6 +622,7 @@ namespace ts {
// Visit each original node.
for (let i = 0; i < count; i++) {
const node = nodes[i + start];
aggregateTransformFlags(node);
const visited = node !== undefined ? visitor(node) : undefined;
if (updated !== undefined || visited === undefined || visited !== node) {
if (updated === undefined) {
@@ -1315,66 +1317,6 @@ namespace ts {
return transformFlags | aggregateTransformFlagsForNode(child);
}
/**
* Gets the transform flags to exclude when unioning the transform flags of a subtree.
*
* NOTE: This needs to be kept up-to-date with the exclusions used in `computeTransformFlagsForNode`.
* For performance reasons, `computeTransformFlagsForNode` uses local constant values rather
* than calling this function.
*/
function getTransformFlagsSubtreeExclusions(kind: SyntaxKind) {
if (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) {
return TransformFlags.TypeExcludes;
}
switch (kind) {
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.ArrayLiteralExpression:
return TransformFlags.ArrayLiteralOrCallOrNewExcludes;
case SyntaxKind.ModuleDeclaration:
return TransformFlags.ModuleExcludes;
case SyntaxKind.Parameter:
return TransformFlags.ParameterExcludes;
case SyntaxKind.ArrowFunction:
return TransformFlags.ArrowFunctionExcludes;
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
return TransformFlags.FunctionExcludes;
case SyntaxKind.VariableDeclarationList:
return TransformFlags.VariableDeclarationListExcludes;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
return TransformFlags.ClassExcludes;
case SyntaxKind.Constructor:
return TransformFlags.ConstructorExcludes;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return TransformFlags.MethodOrAccessorExcludes;
case SyntaxKind.AnyKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.NeverKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.TypeParameter:
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
return TransformFlags.TypeExcludes;
case SyntaxKind.ObjectLiteralExpression:
return TransformFlags.ObjectLiteralExcludes;
default:
return TransformFlags.NodeExcludes;
}
}
export namespace Debug {
export const failNotOptional = shouldAssert(AssertionLevel.Normal)
? (message?: string) => assert(false, message || "Node not optional.")
+21 -2
View File
@@ -1026,7 +1026,7 @@ namespace FourSlash {
ts.displayPartsToString(help.suffixDisplayParts), expected);
}
public verifyCurrentParameterIsletiable(isVariable: boolean) {
public verifyCurrentParameterIsVariable(isVariable: boolean) {
const signature = this.getActiveSignatureHelpItem();
assert.isOk(signature);
assert.equal(isVariable, signature.isVariadic);
@@ -1053,6 +1053,10 @@ namespace FourSlash {
assert.equal(this.getActiveSignatureHelpItem().parameters.length, expectedCount);
}
public verifyCurrentSignatureHelpIsVariadic(expected: boolean) {
assert.equal(this.getActiveSignatureHelpItem().isVariadic, expected);
}
public verifyCurrentSignatureHelpDocComment(docComment: string) {
const actualDocComment = this.getActiveSignatureHelpItem().documentation;
assert.equal(ts.displayPartsToString(actualDocComment), docComment, this.assertionMessageAtLastKnownMarker("current signature help doc comment"));
@@ -1253,7 +1257,18 @@ namespace FourSlash {
resultString += "Diagnostics:" + Harness.IO.newLine();
const diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram());
for (const diagnostic of diagnostics) {
resultString += " " + diagnostic.messageText + Harness.IO.newLine();
if (typeof diagnostic.messageText !== "string") {
let chainedMessage = <ts.DiagnosticMessageChain>diagnostic.messageText;
let indentation = " ";
while (chainedMessage) {
resultString += indentation + chainedMessage.messageText + Harness.IO.newLine();
chainedMessage = chainedMessage.next;
indentation = indentation + " ";
}
}
else {
resultString += " " + diagnostic.messageText + Harness.IO.newLine();
}
}
}
@@ -3220,6 +3235,10 @@ namespace FourSlashInterface {
this.state.verifySignatureHelpCount(expected);
}
public signatureHelpCurrentArgumentListIsVariadic(expected: boolean) {
this.state.verifyCurrentSignatureHelpIsVariadic(expected);
}
public signatureHelpArgumentCountIs(expected: number) {
this.state.verifySignatureHelpArgumentCount(expected);
}
+15 -8
View File
@@ -1029,7 +1029,7 @@ namespace Harness {
},
realpath: realPathMap && ((f: string) => {
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
return realPathMap.contains(path) ? realPathMap.get(path) : path;
return realPathMap.get(path) || path;
}),
directoryExists: dir => {
let path = ts.toPath(dir, currentDirectory, getCanonicalFileName);
@@ -1037,13 +1037,7 @@ namespace Harness {
if (path[path.length - 1] === "/") {
path = <ts.Path>path.substr(0, path.length - 1);
}
let exists = false;
fileMap.forEachValue(key => {
if (key.indexOf(path) === 0 && key[path.length] === "/") {
exists = true;
}
});
return exists;
return mapHasFileInDirectory(path, fileMap) || mapHasFileInDirectory(path, realPathMap);
},
getDirectories: d => {
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);
@@ -1064,6 +1058,19 @@ namespace Harness {
};
}
function mapHasFileInDirectory(directoryPath: ts.Path, map: ts.FileMap<any>): boolean {
if (!map) {
return false;
}
let exists = false;
map.forEachValue(fileName => {
if (!exists && ts.startsWith(fileName, directoryPath) && fileName[directoryPath.length] === "/") {
exists = true;
}
});
return exists;
}
interface HarnessOptions {
useCaseSensitiveFileNames?: boolean;
includeBuiltFile?: string;
+4
View File
@@ -720,6 +720,10 @@ namespace Harness.LanguageService {
clearImmediate(timeoutId: any): void {
clearImmediate(timeoutId);
}
createHash(s: string) {
return s;
}
}
export class ServerLanguageServiceAdapter implements LanguageServiceAdapter {
+11 -26
View File
@@ -22,33 +22,17 @@ namespace ts {
newLine: "\r\n",
useCaseSensitiveFileNames: false,
write: noop,
readFile: (path: string): string => {
return path in fileMap ? fileMap[path].content : undefined;
},
writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => {
return ts.notImplemented();
},
resolvePath: (_path: string): string => {
return ts.notImplemented();
},
fileExists: (path: string): boolean => {
return path in fileMap;
},
directoryExists: (path: string): boolean => {
return existingDirectories[path] || false;
},
readFile: path => path in fileMap ? fileMap[path].content : undefined,
writeFile: notImplemented,
resolvePath: notImplemented,
fileExists: path => path in fileMap,
directoryExists: path => existingDirectories[path] || false,
createDirectory: noop,
getExecutingFilePath: (): string => {
return "";
},
getCurrentDirectory: (): string => {
return "";
},
getExecutingFilePath: () => "",
getCurrentDirectory: () => "",
getDirectories: () => [],
getEnvironmentVariable: () => "",
readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => {
return ts.notImplemented();
},
readDirectory: notImplemented,
exit: noop,
watchFile: () => ({
close: noop
@@ -58,8 +42,9 @@ namespace ts {
}),
setTimeout,
clearTimeout,
setImmediate,
clearImmediate
setImmediate: typeof setImmediate !== "undefined" ? setImmediate : action => setTimeout(action, 0),
clearImmediate: typeof clearImmediate !== "undefined" ? clearImmediate : clearTimeout,
createHash: s => s
};
}
+17 -7
View File
@@ -44,10 +44,10 @@ namespace ts {
// NOTE: 'reusedElements' is the expected count of elements reused from the old tree to the new
// tree. It may change as we tweak the parser. If the count increases then that should always
// be a good thing. If it decreases, that's not great (less reusability), but that may be
// unavoidable. If it does decrease an investigation should be done to make sure that things
// be a good thing. If it decreases, that's not great (less reusability), but that may be
// unavoidable. If it does decrease an investigation should be done to make sure that things
// are still ok and we're still appropriately reusing most of the tree.
function compareTrees(oldText: IScriptSnapshot, newText: IScriptSnapshot, textChangeRange: TextChangeRange, expectedReusedElements: number, oldTree?: SourceFile): SourceFile {
function compareTrees(oldText: IScriptSnapshot, newText: IScriptSnapshot, textChangeRange: TextChangeRange, expectedReusedElements: number, oldTree?: SourceFile) {
oldTree = oldTree || createTree(oldText, /*version:*/ ".");
Utils.assertInvariants(oldTree, /*parent:*/ undefined);
@@ -76,7 +76,7 @@ namespace ts {
assert.equal(actualReusedCount, expectedReusedElements, actualReusedCount + " !== " + expectedReusedElements);
}
return incrementalNewTree;
return { oldTree, newTree, incrementalNewTree };
}
function reusedElements(oldNode: SourceFile, newNode: SourceFile): number {
@@ -103,7 +103,7 @@ namespace ts {
for (let i = 0; i < repeat; i++) {
const oldText = ScriptSnapshot.fromString(source);
const newTextAndChange = withDelete(oldText, index, 1);
const newTree = compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, -1, oldTree);
const newTree = compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, -1, oldTree).incrementalNewTree;
source = newTextAndChange.text.getText(0, newTextAndChange.text.getLength());
oldTree = newTree;
@@ -116,7 +116,7 @@ namespace ts {
for (let i = 0; i < repeat; i++) {
const oldText = ScriptSnapshot.fromString(source);
const newTextAndChange = withInsert(oldText, index + i, toInsert.charAt(i));
const newTree = compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, -1, oldTree);
const newTree = compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, -1, oldTree).incrementalNewTree;
source = newTextAndChange.text.getText(0, newTextAndChange.text.getLength());
oldTree = newTree;
@@ -639,7 +639,7 @@ module m3 { }\
});
it("Unterminated comment after keyword converted to identifier", () => {
// 'public' as a keyword should be incrementally unusable (because it has an
// 'public' as a keyword should be incrementally unusable (because it has an
// unterminated comment). When we convert it to an identifier, that shouldn't
// change anything, and we should still get the same errors.
const source = "return; a.public /*";
@@ -796,6 +796,16 @@ module m3 { }\
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
});
it("Reuse transformFlags of subtree during bind", () => {
const source = `class Greeter { constructor(element: HTMLElement) { } }`;
const oldText = ScriptSnapshot.fromString(source);
const newTextAndChange = withChange(oldText, 15, 0, "\n");
const { oldTree, incrementalNewTree } = compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, -1);
bindSourceFile(oldTree, {});
bindSourceFile(incrementalNewTree, {});
assert.equal(oldTree.transformFlags, incrementalNewTree.transformFlags);
});
// Simulated typing tests.
it("Type extends clause 1", () => {
+75 -153
View File
@@ -91,6 +91,12 @@ namespace ts {
const defaultExcludes = ["node_modules", "bower_components", "jspm_packages"];
function assertParsed(actual: ts.ParsedCommandLine, expected: ts.ParsedCommandLine): void {
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
}
describe("matchFiles", () => {
describe("with literal file list", () => {
it("without exclusions", () => {
@@ -110,9 +116,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("missing files are still present", () => {
const json = {
@@ -131,9 +135,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("are not removed due to excludes", () => {
const json = {
@@ -155,9 +157,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
});
@@ -179,9 +179,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with non .ts file extensions are excluded", () => {
const json = {
@@ -200,9 +198,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with missing files are excluded", () => {
const json = {
@@ -221,9 +217,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with literal excludes", () => {
const json = {
@@ -244,9 +238,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with wildcard excludes", () => {
const json = {
@@ -274,9 +266,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with recursive excludes", () => {
const json = {
@@ -303,9 +293,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with case sensitive exclude", () => {
const json = {
@@ -325,9 +313,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseSensitiveHost, caseSensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with common package folders and no exclusions", () => {
const json = {
@@ -349,9 +335,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with common package folders and exclusions", () => {
const json = {
@@ -378,9 +362,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with common package folders and empty exclude", () => {
const json = {
@@ -406,9 +388,7 @@ namespace ts {
wildcardDirectories: {},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
});
@@ -432,9 +412,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("`*` matches only ts files", () => {
const json = {
@@ -455,9 +433,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("`?` matches only a single character", () => {
const json = {
@@ -477,9 +453,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with recursive directory", () => {
const json = {
@@ -501,9 +475,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with multiple recursive directories", () => {
const json = {
@@ -527,9 +499,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("case sensitive", () => {
const json = {
@@ -548,9 +518,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseSensitiveHost, caseSensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with missing files are excluded", () => {
const json = {
@@ -570,9 +538,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("always include literal files", () => {
const json = {
@@ -597,9 +563,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("exclude folders", () => {
const json = {
@@ -624,9 +588,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with common package folders and no exclusions", () => {
const json = {
@@ -645,9 +607,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with common package folders and exclusions", () => {
const json = {
@@ -671,9 +631,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with common package folders and empty exclude", () => {
const json = {
@@ -696,9 +654,7 @@ namespace ts {
},
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("exclude .js files when allowJs=false", () => {
const json = {
@@ -723,9 +679,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("include .js files when allowJs=true", () => {
const json = {
@@ -750,9 +704,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("include explicitly listed .min.js files when allowJs=true", () => {
const json = {
@@ -777,9 +729,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("include paths outside of the project", () => {
const json = {
@@ -803,9 +753,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("include paths outside of the project using relative paths", () => {
const json = {
@@ -828,9 +776,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("exclude paths outside of the project using relative paths", () => {
const json = {
@@ -851,9 +797,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("include files with .. in their name", () => {
const json = {
@@ -873,9 +817,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("exclude files with .. in their name", () => {
const json = {
@@ -897,9 +839,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with jsx=none, allowJs=false", () => {
const json = {
@@ -922,9 +862,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with jsx=preserve, allowJs=false", () => {
const json = {
@@ -949,9 +887,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with jsx=none, allowJs=true", () => {
const json = {
@@ -976,9 +912,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with jsx=preserve, allowJs=true", () => {
const json = {
@@ -1005,9 +939,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("exclude .min.js files using wildcards", () => {
const json = {
@@ -1034,9 +966,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
describe("with trailing recursive directory", () => {
it("in includes", () => {
@@ -1056,9 +986,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("in excludes", () => {
const json = {
@@ -1079,9 +1007,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
});
describe("with multiple recursive directory patterns", () => {
@@ -1102,9 +1028,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("in excludes", () => {
const json = {
@@ -1131,9 +1055,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
});
@@ -1155,9 +1077,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("in includes after a subdirectory", () => {
@@ -1177,9 +1097,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("in excludes immediately after", () => {
@@ -1207,9 +1125,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("in excludes after a subdirectory", () => {
@@ -1237,9 +1153,25 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
});
describe("with implicit globbification", () => {
it("Expands 'z' to 'z/**/*'", () => {
const json = {
include: ["z"]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [ "a.ts", "aba.ts", "abz.ts", "b.ts", "bba.ts", "bbz.ts" ].map(x => `c:/dev/z/${x}`),
wildcardDirectories: {
"c:/dev/z": ts.WatchDirectoryFlags.Recursive
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
assertParsed(actual, expected);
});
});
});
@@ -1264,9 +1196,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
describe("that are explicitly included", () => {
it("without wildcards", () => {
@@ -1286,9 +1216,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with recursive wildcards that match directories", () => {
const json = {
@@ -1310,9 +1238,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with recursive wildcards that match nothing", () => {
const json = {
@@ -1334,9 +1260,7 @@ namespace ts {
}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
it("with wildcard excludes that implicitly exclude dotted files", () => {
const json = {
@@ -1357,9 +1281,7 @@ namespace ts {
wildcardDirectories: {}
};
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
assert.deepEqual(actual.fileNames, expected.fileNames);
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
assert.deepEqual(actual.errors, expected.errors);
assertParsed(actual, expected);
});
});
});
+64
View File
@@ -1065,5 +1065,69 @@ import b = require("./moduleB");
assert.equal(diagnostics2.length, 1, "expected one diagnostic");
assert.equal(diagnostics1[0].messageText, diagnostics2[0].messageText, "expected one diagnostic");
});
it ("Modules in the same .d.ts file are preferred to external files", () => {
const f = {
name: "/a/b/c/c/app.d.ts",
content: `
declare module "fs" {
export interface Stat { id: number }
}
declare module "fs-client" {
import { Stat } from "fs";
export function foo(): Stat;
}`
};
const file = createSourceFile(f.name, f.content, ScriptTarget.ES2015);
const compilerHost: CompilerHost = {
fileExists : fileName => fileName === file.fileName,
getSourceFile: fileName => fileName === file.fileName ? file : undefined,
getDefaultLibFileName: () => "lib.d.ts",
writeFile: notImplemented,
getCurrentDirectory: () => "/",
getDirectories: () => [],
getCanonicalFileName: f => f.toLowerCase(),
getNewLine: () => "\r\n",
useCaseSensitiveFileNames: () => false,
readFile: fileName => fileName === file.fileName ? file.text : undefined,
resolveModuleNames() {
assert(false, "resolveModuleNames should not be called");
return undefined;
}
};
createProgram([f.name], {}, compilerHost);
});
it ("Modules in .ts file are not checked in the same file", () => {
const f = {
name: "/a/b/c/c/app.ts",
content: `
declare module "fs" {
export interface Stat { id: number }
}
declare module "fs-client" {
import { Stat } from "fs";
export function foo(): Stat;
}`
};
const file = createSourceFile(f.name, f.content, ScriptTarget.ES2015);
const compilerHost: CompilerHost = {
fileExists : fileName => fileName === file.fileName,
getSourceFile: fileName => fileName === file.fileName ? file : undefined,
getDefaultLibFileName: () => "lib.d.ts",
writeFile: notImplemented,
getCurrentDirectory: () => "/",
getDirectories: () => [],
getCanonicalFileName: f => f.toLowerCase(),
getNewLine: () => "\r\n",
useCaseSensitiveFileNames: () => false,
readFile: fileName => fileName === file.fileName ? file.text : undefined,
resolveModuleNames(moduleNames: string[], _containingFile: string) {
assert.deepEqual(moduleNames, ["fs"]);
return [undefined];
}
};
createProgram([f.name], {}, compilerHost);
});
});
}
+130 -6
View File
@@ -22,6 +22,11 @@ namespace ts {
interface ProgramWithSourceTexts extends Program {
sourceTexts?: NamedSourceText[];
host: TestCompilerHost;
}
interface TestCompilerHost extends CompilerHost {
getTrace(): string[];
}
class SourceText implements IScriptSnapshot {
@@ -101,10 +106,21 @@ namespace ts {
return file;
}
function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget): CompilerHost {
const files = arrayToMap(texts, t => t.name, t => createSourceFileWithText(t.name, t.text, target));
function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget, oldProgram?: ProgramWithSourceTexts): TestCompilerHost {
const files = arrayToMap(texts, t => t.name, t => {
if (oldProgram) {
const oldFile = <SourceFileWithText>oldProgram.getSourceFile(t.name);
if (oldFile && oldFile.sourceText.getVersion() === t.text.getVersion()) {
return oldFile;
}
}
return createSourceFileWithText(t.name, t.text, target);
});
const trace: string[] = [];
return {
trace: s => trace.push(s),
getTrace: () => trace,
getSourceFile(fileName): SourceFile {
return files[fileName];
},
@@ -130,23 +146,25 @@ namespace ts {
fileExists: fileName => fileName in files,
readFile: fileName => {
return fileName in files ? files[fileName].text : undefined;
}
},
};
}
function newProgram(texts: NamedSourceText[], rootNames: string[], options: CompilerOptions): Program {
function newProgram(texts: NamedSourceText[], rootNames: string[], options: CompilerOptions): ProgramWithSourceTexts {
const host = createTestCompilerHost(texts, options.target);
const program = <ProgramWithSourceTexts>createProgram(rootNames, options, host);
program.sourceTexts = texts;
program.host = host;
return program;
}
function updateProgram(oldProgram: Program, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void) {
function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void) {
const texts: NamedSourceText[] = (<ProgramWithSourceTexts>oldProgram).sourceTexts.slice(0);
updater(texts);
const host = createTestCompilerHost(texts, options.target);
const host = createTestCompilerHost(texts, options.target, oldProgram);
const program = <ProgramWithSourceTexts>createProgram(rootNames, options, host, oldProgram);
program.sourceTexts = texts;
program.host = host;
return program;
}
@@ -355,6 +373,112 @@ namespace ts {
assert.isTrue(!program_3.structureIsReused);
checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }));
});
it("can reuse ambient module declarations from non-modified files", () => {
const files = [
{ name: "/a/b/app.ts", text: SourceText.New("", "import * as fs from 'fs'", "") },
{ name: "/a/b/node.d.ts", text: SourceText.New("", "", "declare module 'fs' {}") }
];
const options = { target: ScriptTarget.ES2015, traceResolution: true };
const program = newProgram(files, files.map(f => f.name), options);
assert.deepEqual(program.host.getTrace(),
[
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs.ts' does not exist.",
"File '/a/node_modules/@types/fs.tsx' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs.ts' does not exist.",
"File '/node_modules/@types/fs.tsx' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs/index.ts' does not exist.",
"File '/node_modules/@types/fs/index.tsx' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========",
], "should look for 'fs'");
const program_2 = updateProgram(program, program.getRootFileNames(), options, f => {
f[0].text = f[0].text.updateProgram("var x = 1;");
});
assert.deepEqual(program_2.host.getTrace(), [
"Module 'fs' was resolved as ambient module declared in '/a/b/node.d.ts' since this file was not modified."
], "should reuse 'fs' since node.d.ts was not changed");
const program_3 = updateProgram(program_2, program_2.getRootFileNames(), options, f => {
f[0].text = f[0].text.updateProgram("var y = 1;");
f[1].text = f[1].text.updateProgram("declare var process: any");
});
assert.deepEqual(program_3.host.getTrace(),
[
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs.ts' does not exist.",
"File '/a/node_modules/@types/fs.tsx' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs.ts' does not exist.",
"File '/node_modules/@types/fs.tsx' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs/index.ts' does not exist.",
"File '/node_modules/@types/fs/index.tsx' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========",
], "should look for 'fs' again since node.d.ts was changed");
});
});
describe("host is optional", () => {
+4 -2
View File
@@ -24,7 +24,8 @@ namespace ts.server {
setTimeout() { return 0; },
clearTimeout: noop,
setImmediate: () => 0,
clearImmediate: noop
clearImmediate: noop,
createHash: s => s
};
const nullCancellationToken: HostCancellationToken = { isCancellationRequested: () => false };
const mockLogger: Logger = {
@@ -150,7 +151,8 @@ namespace ts.server {
target: ScriptTarget.ES5,
jsx: JsxEmit.React,
newLine: NewLineKind.LineFeed,
moduleResolution: ModuleResolutionKind.NodeJs
moduleResolution: ModuleResolutionKind.NodeJs,
allowNonTsExtensions: true // injected by tsserver
});
});
});
+124 -19
View File
@@ -18,7 +18,6 @@ namespace ts.projectSystem {
};
export interface PostExecAction {
readonly requestKind: TI.RequestKind;
readonly success: boolean;
readonly callback: TI.RequestCompletedAction;
}
@@ -47,9 +46,14 @@ namespace ts.projectSystem {
export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller {
protected projectService: server.ProjectService;
constructor(readonly globalTypingsCacheLocation: string, throttleLimit: number, readonly installTypingHost: server.ServerHost, log?: TI.Log) {
super(globalTypingsCacheLocation, safeList.path, throttleLimit, log);
this.init();
constructor(
readonly globalTypingsCacheLocation: string,
throttleLimit: number,
installTypingHost: server.ServerHost,
readonly typesRegistry = createMap<void>(),
telemetryEnabled?: boolean,
log?: TI.Log) {
super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, telemetryEnabled, log);
}
safeFileList = safeList.path;
@@ -63,9 +67,8 @@ namespace ts.projectSystem {
}
}
checkPendingCommands(expected: TI.RequestKind[]) {
assert.equal(this.postExecActions.length, expected.length, `Expected ${expected.length} post install actions`);
this.postExecActions.forEach((act, i) => assert.equal(act.requestKind, expected[i], "Unexpected post install action"));
checkPendingCommands(expectedCount: number) {
assert.equal(this.postExecActions.length, expectedCount, `Expected ${expectedCount} post install actions`);
}
onProjectClosed() {
@@ -79,15 +82,8 @@ namespace ts.projectSystem {
return this.installTypingHost;
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
switch (requestKind) {
case TI.NpmViewRequest:
case TI.NpmInstallRequest:
break;
default:
assert.isTrue(false, `request ${requestKind} is not supported`);
}
this.addPostExecAction(requestKind, "success", cb);
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
this.addPostExecAction("success", cb);
}
sendResponse(response: server.SetTypings | server.InvalidateCachedTypings) {
@@ -99,12 +95,11 @@ namespace ts.projectSystem {
this.install(request);
}
addPostExecAction(requestKind: TI.RequestKind, stdout: string | string[], cb: TI.RequestCompletedAction) {
addPostExecAction(stdout: string | string[], cb: TI.RequestCompletedAction) {
const out = typeof stdout === "string" ? stdout : createNpmPackageJsonString(stdout);
const action: PostExecAction = {
success: !!out,
callback: cb,
requestKind
callback: cb
};
this.postExecActions.push(action);
}
@@ -439,6 +434,10 @@ namespace ts.projectSystem {
};
}
createHash(s: string): string {
return s;
}
triggerDirectoryWatcherCallback(directoryName: string, fileName: string): void {
const path = this.toPath(directoryName);
const callbacks = this.watchedDirectories[path];
@@ -1969,6 +1968,33 @@ namespace ts.projectSystem {
projectService.checkNumberOfProjects({ configuredProjects: 1 });
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, libES2015Promise.path, app.path]);
});
it("should handle non-existing directories in config file", () => {
const f = {
path: "/a/src/app.ts",
content: "let x = 1;"
};
const config = {
path: "/a/tsconfig.json",
content: JSON.stringify({
compilerOptions: {},
include: [
"src/**/*",
"notexistingfolder/*"
]
})
};
const host = createServerHost([f, config]);
const projectService = createProjectService(host);
projectService.openClientFile(f.path);
projectService.checkNumberOfProjects({ configuredProjects: 1 });
projectService.closeClientFile(f.path);
projectService.checkNumberOfProjects({ configuredProjects: 0 });
projectService.openClientFile(f.path);
projectService.checkNumberOfProjects({ configuredProjects: 1 });
});
});
describe("prefer typings to js", () => {
@@ -2227,6 +2253,27 @@ namespace ts.projectSystem {
assert.equal(diags.length, 0);
});
it("should property handle missing config files", () => {
const f1 = {
path: "/a/b/app.ts",
content: "let x = 1"
};
const config = {
path: "/a/b/tsconfig.json",
content: "{}"
};
const projectName = "project1";
const host = createServerHost([f1]);
const projectService = createProjectService(host);
projectService.openExternalProject({ rootFiles: toExternalFiles([f1.path, config.path]), options: {}, projectFileName: projectName });
// should have one external project since config file is missing
projectService.checkNumberOfProjects({ externalProjects: 1 });
host.reloadFS([f1, config]);
projectService.openExternalProject({ rootFiles: toExternalFiles([f1.path, config.path]), options: {}, projectFileName: projectName });
projectService.checkNumberOfProjects({ configuredProjects: 1 });
});
});
describe("add the missing module file for inferred project", () => {
@@ -2471,4 +2518,62 @@ namespace ts.projectSystem {
});
});
describe("Inferred projects", () => {
it("should support files without extensions", () => {
const f = {
path: "/a/compile",
content: "let x = 1"
};
const host = createServerHost([f]);
const session = createSession(host);
session.executeCommand(<server.protocol.SetCompilerOptionsForInferredProjectsRequest>{
seq: 1,
type: "request",
command: "compilerOptionsForInferredProjects",
arguments: {
options: {
allowJs: true
}
}
});
session.executeCommand(<server.protocol.OpenRequest>{
seq: 2,
type: "request",
command: "open",
arguments: {
file: f.path,
fileContent: f.content,
scriptKindName: "JS"
}
});
const projectService = session.getProjectService();
checkNumberOfProjects(projectService, { inferredProjects: 1 });
checkProjectActualFiles(projectService.inferredProjects[0], [f.path]);
});
});
describe("No overwrite emit error", () => {
it("for inferred project", () => {
const f1 = {
path: "/a/b/f1.js",
content: "function test1() { }"
};
const host = createServerHost([f1, libFile]);
const session = createSession(host);
openFilesForSession([f1], session);
const projectService = session.getProjectService();
checkNumberOfProjects(projectService, { inferredProjects: 1 });
const projectName = projectService.inferredProjects[0].getProjectName();
const diags = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
type: "request",
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
seq: 2,
arguments: { projectFileName: projectName }
}).response;
assert.isTrue(diags.length === 0);
});
});
}
+140 -121
View File
@@ -8,44 +8,44 @@ namespace ts.projectSystem {
interface InstallerParams {
globalTypingsCacheLocation?: string;
throttleLimit?: number;
typesRegistry?: Map<void>;
}
function createTypesRegistry(...list: string[]): Map<void> {
const map = createMap<void>();
for (const l of list) {
map[l] = undefined;
}
return map;
}
class Installer extends TestTypingsInstaller {
constructor(host: server.ServerHost, p?: InstallerParams, log?: TI.Log) {
constructor(host: server.ServerHost, p?: InstallerParams, telemetryEnabled?: boolean, log?: TI.Log) {
super(
(p && p.globalTypingsCacheLocation) || "/a/data",
(p && p.throttleLimit) || 5,
host,
(p && p.typesRegistry),
telemetryEnabled,
log);
}
installAll(expectedView: typeof TI.NpmViewRequest[], expectedInstall: typeof TI.NpmInstallRequest[]) {
this.checkPendingCommands(expectedView);
this.executePendingCommands();
this.checkPendingCommands(expectedInstall);
installAll(expectedCount: number) {
this.checkPendingCommands(expectedCount);
this.executePendingCommands();
}
}
describe("typingsInstaller", () => {
function executeCommand(self: Installer, host: TestServerHost, installedTypings: string[], typingFiles: FileOrFolder[], requestKind: TI.RequestKind, cb: TI.RequestCompletedAction): void {
switch (requestKind) {
case TI.NpmInstallRequest:
self.addPostExecAction(requestKind, installedTypings, success => {
for (const file of typingFiles) {
host.createFileOrFolder(file, /*createParentDirectory*/ true);
}
cb(success);
});
break;
case TI.NpmViewRequest:
self.addPostExecAction(requestKind, installedTypings, cb);
break;
default:
assert.isTrue(false, `unexpected request kind ${requestKind}`);
break;
function executeCommand(self: Installer, host: TestServerHost, installedTypings: string[], typingFiles: FileOrFolder[], cb: TI.RequestCompletedAction): void {
self.addPostExecAction(installedTypings, success => {
for (const file of typingFiles) {
host.createFileOrFolder(file, /*createParentDirectory*/ true);
}
}
cb(success);
});
}
describe("typingsInstaller", () => {
it("configured projects (typings installed) 1", () => {
const file1 = {
path: "/a/b/app.js",
@@ -79,12 +79,12 @@ namespace ts.projectSystem {
const host = createServerHost([file1, tsconfig, packageJson]);
const installer = new (class extends Installer {
constructor() {
super(host);
super(host, { typesRegistry: createTypesRegistry("jquery") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jquery];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -95,7 +95,7 @@ namespace ts.projectSystem {
const p = projectService.configuredProjects[0];
checkProjectActualFiles(p, [file1.path]);
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
installer.installAll(/*expectedCount*/ 1);
checkNumberOfProjects(projectService, { configuredProjects: 1 });
checkProjectActualFiles(p, [file1.path, jquery.path]);
@@ -123,12 +123,12 @@ namespace ts.projectSystem {
const host = createServerHost([file1, packageJson]);
const installer = new (class extends Installer {
constructor() {
super(host);
super(host, { typesRegistry: createTypesRegistry("jquery") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jquery];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -139,7 +139,7 @@ namespace ts.projectSystem {
const p = projectService.inferredProjects[0];
checkProjectActualFiles(p, [file1.path]);
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
installer.installAll(/*expectedCount*/ 1);
checkNumberOfProjects(projectService, { inferredProjects: 1 });
checkProjectActualFiles(p, [file1.path, jquery.path]);
@@ -167,7 +167,7 @@ namespace ts.projectSystem {
options: {},
rootFiles: [toExternalFile(file1.path)]
});
installer.checkPendingCommands([]);
installer.checkPendingCommands(/*expectedCount*/ 0);
// by default auto discovery will kick in if project contain only .js/.d.ts files
// in this case project contain only ts files - no auto discovery
projectService.checkNumberOfProjects({ externalProjects: 1 });
@@ -181,7 +181,7 @@ namespace ts.projectSystem {
const host = createServerHost([file1]);
const installer = new (class extends Installer {
constructor() {
super(host);
super(host, { typesRegistry: createTypesRegistry("jquery") });
}
enqueueInstallTypingsRequest() {
assert(false, "auto discovery should not be enabled");
@@ -196,7 +196,7 @@ namespace ts.projectSystem {
rootFiles: [toExternalFile(file1.path)],
typingOptions: { include: ["jquery"] }
});
installer.checkPendingCommands([]);
installer.checkPendingCommands(/*expectedCount*/ 0);
// by default auto discovery will kick in if project contain only .js/.d.ts files
// in this case project contain only ts files - no auto discovery even if typing options is set
projectService.checkNumberOfProjects({ externalProjects: 1 });
@@ -215,16 +215,16 @@ namespace ts.projectSystem {
let enqueueIsCalled = false;
const installer = new (class extends Installer {
constructor() {
super(host);
super(host, { typesRegistry: createTypesRegistry("jquery") });
}
enqueueInstallTypingsRequest(project: server.Project, typingOptions: TypingOptions, unresolvedImports: server.SortedReadonlyArray<string>) {
enqueueIsCalled = true;
super.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports);
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/jquery"];
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/node"];
const typingFiles = [jquery];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -234,11 +234,11 @@ namespace ts.projectSystem {
projectFileName,
options: {},
rootFiles: [toExternalFile(file1.path)],
typingOptions: { enableAutoDiscovery: true, include: ["node"] }
typingOptions: { enableAutoDiscovery: true, include: ["jquery"] }
});
assert.isTrue(enqueueIsCalled, "expected enqueueIsCalled to be true");
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
installer.installAll(/*expectedCount*/ 1);
// autoDiscovery is set in typing options - use it even if project contains only .ts files
projectService.checkNumberOfProjects({ externalProjects: 1 });
@@ -273,12 +273,12 @@ namespace ts.projectSystem {
const host = createServerHost([file1, file2, file3]);
const installer = new (class extends Installer {
constructor() {
super(host);
super(host, { typesRegistry: createTypesRegistry("lodash", "react") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/lodash", "@types/react"];
const typingFiles = [lodash, react];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -295,7 +295,7 @@ namespace ts.projectSystem {
projectService.checkNumberOfProjects({ externalProjects: 1 });
checkProjectActualFiles(p, [file1.path, file2.path, file3.path]);
installer.installAll([TI.NpmViewRequest, TI.NpmViewRequest], [TI.NpmInstallRequest], );
installer.installAll(/*expectedCount*/ 1);
checkNumberOfProjects(projectService, { externalProjects: 1 });
checkProjectActualFiles(p, [file1.path, file2.path, file3.path, lodash.path, react.path]);
@@ -317,16 +317,16 @@ namespace ts.projectSystem {
let enqueueIsCalled = false;
const installer = new (class extends Installer {
constructor() {
super(host);
super(host, { typesRegistry: createTypesRegistry("jquery") });
}
enqueueInstallTypingsRequest(project: server.Project, typingOptions: TypingOptions, unresolvedImports: server.SortedReadonlyArray<string>) {
enqueueIsCalled = true;
super.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports);
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings: string[] = [];
const typingFiles: FileOrFolder[] = [];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -343,7 +343,7 @@ namespace ts.projectSystem {
projectService.checkNumberOfProjects({ externalProjects: 1 });
checkProjectActualFiles(p, [file1.path, file2.path]);
installer.checkPendingCommands([]);
installer.checkPendingCommands(/*expectedCount*/ 0);
checkNumberOfProjects(projectService, { externalProjects: 1 });
checkProjectActualFiles(p, [file1.path, file2.path]);
@@ -396,12 +396,12 @@ namespace ts.projectSystem {
const host = createServerHost([file1, file2, file3, packageJson]);
const installer = new (class extends Installer {
constructor() {
super(host);
super(host, { typesRegistry: createTypesRegistry("jquery", "commander", "moment", "express") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment"];
const typingFiles = [commander, express, jquery, moment];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -418,10 +418,7 @@ namespace ts.projectSystem {
projectService.checkNumberOfProjects({ externalProjects: 1 });
checkProjectActualFiles(p, [file1.path, file2.path, file3.path]);
installer.installAll(
[TI.NpmViewRequest, TI.NpmViewRequest, TI.NpmViewRequest, TI.NpmViewRequest],
[TI.NpmInstallRequest]
);
installer.installAll(/*expectedCount*/ 1);
checkNumberOfProjects(projectService, { externalProjects: 1 });
checkProjectActualFiles(p, [file1.path, file2.path, file3.path, commander.path, express.path, jquery.path, moment.path]);
@@ -475,11 +472,11 @@ namespace ts.projectSystem {
const host = createServerHost([lodashJs, commanderJs, file3, packageJson]);
const installer = new (class extends Installer {
constructor() {
super(host, { throttleLimit: 3 });
super(host, { throttleLimit: 3, typesRegistry: createTypesRegistry("commander", "express", "jquery", "moment", "lodash") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment", "@types/lodash"];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -495,18 +492,7 @@ namespace ts.projectSystem {
const p = projectService.externalProjects[0];
projectService.checkNumberOfProjects({ externalProjects: 1 });
checkProjectActualFiles(p, [lodashJs.path, commanderJs.path, file3.path]);
// expected 3 view requests in the queue
installer.checkPendingCommands([TI.NpmViewRequest, TI.NpmViewRequest, TI.NpmViewRequest]);
assert.equal(installer.pendingRunRequests.length, 2, "expected 2 pending requests");
// push view requests
installer.executePendingCommands();
// expected 2 remaining view requests in the queue
installer.checkPendingCommands([TI.NpmViewRequest, TI.NpmViewRequest]);
// push view requests
installer.executePendingCommands();
// expected one install request
installer.checkPendingCommands([TI.NpmInstallRequest]);
installer.checkPendingCommands(/*expectedCount*/ 1);
installer.executePendingCommands();
// expected all typings file to exist
for (const f of typingFiles) {
@@ -565,22 +551,17 @@ namespace ts.projectSystem {
const host = createServerHost([lodashJs, commanderJs, file3]);
const installer = new (class extends Installer {
constructor() {
super(host, { throttleLimit: 3 });
super(host, { throttleLimit: 1, typesRegistry: createTypesRegistry("commander", "jquery", "lodash", "cordova", "gulp", "grunt") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
if (requestKind === TI.NpmInstallRequest) {
let typingFiles: (FileOrFolder & { typings: string })[] = [];
if (args.indexOf("@types/commander") >= 0) {
typingFiles = [commander, jquery, lodash, cordova];
}
else {
typingFiles = [grunt, gulp];
}
executeCommand(this, host, typingFiles.map(f => f.typings), typingFiles, requestKind, cb);
installWorker(_requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
let typingFiles: (FileOrFolder & { typings: string })[] = [];
if (args.indexOf("@types/commander") >= 0) {
typingFiles = [commander, jquery, lodash, cordova];
}
else {
executeCommand(this, host, [], [], requestKind, cb);
typingFiles = [grunt, gulp];
}
executeCommand(this, host, typingFiles.map(f => f.typings), typingFiles, cb);
}
})();
@@ -594,8 +575,8 @@ namespace ts.projectSystem {
typingOptions: { include: ["jquery", "cordova"] }
});
installer.checkPendingCommands([TI.NpmViewRequest, TI.NpmViewRequest, TI.NpmViewRequest]);
assert.equal(installer.pendingRunRequests.length, 1, "expect one throttled request");
installer.checkPendingCommands(/*expectedCount*/ 1);
assert.equal(installer.pendingRunRequests.length, 0, "expect no throttled requests");
// Create project #2 with 2 typings
const projectFileName2 = "/a/app/test2.csproj";
@@ -605,7 +586,7 @@ namespace ts.projectSystem {
rootFiles: [toExternalFile(file3.path)],
typingOptions: { include: ["grunt", "gulp"] }
});
assert.equal(installer.pendingRunRequests.length, 3, "expect three throttled request");
assert.equal(installer.pendingRunRequests.length, 1, "expect one throttled request");
const p1 = projectService.externalProjects[0];
const p2 = projectService.externalProjects[1];
@@ -613,18 +594,14 @@ namespace ts.projectSystem {
checkProjectActualFiles(p1, [lodashJs.path, commanderJs.path, file3.path]);
checkProjectActualFiles(p2, [file3.path]);
installer.executePendingCommands();
// expected one view request from the first project and two - from the second one
installer.checkPendingCommands([TI.NpmViewRequest, TI.NpmViewRequest, TI.NpmViewRequest]);
// expected one install request from the second project
installer.checkPendingCommands(/*expectedCount*/ 1);
assert.equal(installer.pendingRunRequests.length, 0, "expected no throttled requests");
installer.executePendingCommands();
// should be two install requests from both projects
installer.checkPendingCommands([TI.NpmInstallRequest, TI.NpmInstallRequest]);
installer.executePendingCommands();
checkProjectActualFiles(p1, [lodashJs.path, commanderJs.path, file3.path, commander.path, jquery.path, lodash.path, cordova.path]);
checkProjectActualFiles(p2, [file3.path, grunt.path, gulp.path]);
});
@@ -653,12 +630,12 @@ namespace ts.projectSystem {
const host = createServerHost([app, jsconfig, jquery, jqueryPackage]);
const installer = new (class extends Installer {
constructor() {
super(host, { globalTypingsCacheLocation: "/tmp" });
super(host, { globalTypingsCacheLocation: "/tmp", typesRegistry: createTypesRegistry("jquery") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jqueryDTS];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -669,7 +646,7 @@ namespace ts.projectSystem {
const p = projectService.configuredProjects[0];
checkProjectActualFiles(p, [app.path]);
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
installer.installAll(/*expectedCount*/ 1);
checkNumberOfProjects(projectService, { configuredProjects: 1 });
checkProjectActualFiles(p, [app.path, jqueryDTS.path]);
@@ -699,12 +676,12 @@ namespace ts.projectSystem {
const host = createServerHost([app, jsconfig, bowerJson]);
const installer = new (class extends Installer {
constructor() {
super(host, { globalTypingsCacheLocation: "/tmp" });
super(host, { globalTypingsCacheLocation: "/tmp", typesRegistry: createTypesRegistry("jquery") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jqueryDTS];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
@@ -715,7 +692,7 @@ namespace ts.projectSystem {
const p = projectService.configuredProjects[0];
checkProjectActualFiles(p, [app.path]);
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
installer.installAll(/*expectedCount*/ 1);
checkNumberOfProjects(projectService, { configuredProjects: 1 });
checkProjectActualFiles(p, [app.path, jqueryDTS.path]);
@@ -742,23 +719,23 @@ namespace ts.projectSystem {
const host = createServerHost([f, brokenPackageJson]);
const installer = new (class extends Installer {
constructor() {
super(host, { globalTypingsCacheLocation: cachePath });
super(host, { globalTypingsCacheLocation: cachePath, typesRegistry: createTypesRegistry("commander") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/commander"];
const typingFiles = [commander];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
const service = createProjectService(host, { typingsInstaller: installer });
service.openClientFile(f.path);
installer.checkPendingCommands([]);
installer.checkPendingCommands(/*expectedCount*/ 0);
host.reloadFS([f, fixedPackageJson]);
host.triggerFileWatcherCallback(fixedPackageJson.path, /*removed*/ false);
// expected one view and one install request
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
// expected install request
installer.installAll(/*expectedCount*/ 1);
service.checkNumberOfProjects({ inferredProjects: 1 });
checkProjectActualFiles(service.inferredProjects[0], [f.path, commander.path]);
@@ -783,12 +760,12 @@ namespace ts.projectSystem {
const host = createServerHost([file]);
const installer = new (class extends Installer {
constructor() {
super(host, { globalTypingsCacheLocation: cachePath });
super(host, { globalTypingsCacheLocation: cachePath, typesRegistry: createTypesRegistry("node", "commander") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/node", "@types/commander"];
const typingFiles = [node, commander];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
executeCommand(this, host, installedTypings, typingFiles, cb);
}
})();
const service = createProjectService(host, { typingsInstaller: installer });
@@ -797,7 +774,7 @@ namespace ts.projectSystem {
service.checkNumberOfProjects({ inferredProjects: 1 });
checkProjectActualFiles(service.inferredProjects[0], [file.path]);
installer.installAll([TI.NpmViewRequest, TI.NpmViewRequest], [TI.NpmInstallRequest]);
installer.installAll(/*expectedCount*/1);
assert.isTrue(host.fileExists(node.path), "typings for 'node' should be created");
assert.isTrue(host.fileExists(commander.path), "typings for 'commander' should be created");
@@ -822,14 +799,10 @@ namespace ts.projectSystem {
const host = createServerHost([f1]);
const installer = new (class extends Installer {
constructor() {
super(host, { globalTypingsCacheLocation: "/tmp" });
super(host, { globalTypingsCacheLocation: "/tmp", typesRegistry: createTypesRegistry("foo") });
}
executeRequest(requestKind: TI.RequestKind, _requestId: number, args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
if (requestKind === TI.NpmViewRequest) {
// args should have only non-scoped packages - scoped packages are not yet supported
assert.deepEqual(args, ["foo"]);
}
executeCommand(this, host, ["foo"], [], requestKind, cb);
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
executeCommand(this, host, ["foo"], [], cb);
}
})();
const projectService = createProjectService(host, { typingsInstaller: installer });
@@ -844,7 +817,7 @@ namespace ts.projectSystem {
["foo", "foo", "foo", "@bar/router", "@bar/common", "@bar/common"]
);
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
installer.installAll(/*expectedCount*/ 1);
});
it("cached unresolved typings are not recomputed if program structure did not change", () => {
@@ -934,16 +907,16 @@ namespace ts.projectSystem {
const host = createServerHost([f1, packageJson]);
const installer = new (class extends Installer {
constructor() {
super(host, { globalTypingsCacheLocation: "/tmp" }, { isEnabled: () => true, writeLine: msg => messages.push(msg) });
super(host, { globalTypingsCacheLocation: "/tmp" }, /*telemetryEnabled*/ false, { isEnabled: () => true, writeLine: msg => messages.push(msg) });
}
executeRequest() {
installWorker(_requestId: number, _args: string[], _cwd: string, _cb: server.typingsInstaller.RequestCompletedAction) {
assert(false, "runCommand should not be invoked");
}
})();
const projectService = createProjectService(host, { typingsInstaller: installer });
projectService.openClientFile(f1.path);
installer.checkPendingCommands([]);
installer.checkPendingCommands(/*expectedCount*/ 0);
assert.isTrue(messages.indexOf("Package name '; say Hello from TypeScript! #' contains non URI safe characters") > 0, "should find package with invalid name");
});
});
@@ -978,4 +951,50 @@ namespace ts.projectSystem {
assert.deepEqual(result.newTypingNames, ["bar"]);
});
});
describe("telemetry events", () => {
it ("should be received", () => {
const f1 = {
path: "/a/app.js",
content: ""
};
const package = {
path: "/a/package.json",
content: JSON.stringify({ dependencies: { "commander": "1.0.0" } })
};
const cachePath = "/a/cache/";
const commander = {
path: cachePath + "node_modules/@types/commander/index.d.ts",
content: "export let x: number"
};
const host = createServerHost([f1, package]);
let seenTelemetryEvent = false;
const installer = new (class extends Installer {
constructor() {
super(host, { globalTypingsCacheLocation: cachePath, typesRegistry: createTypesRegistry("commander") }, /*telemetryEnabled*/ true);
}
installWorker(_requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/commander"];
const typingFiles = [commander];
executeCommand(this, host, installedTypings, typingFiles, cb);
}
sendResponse(response: server.SetTypings | server.InvalidateCachedTypings | server.TypingsInstallEvent) {
if (response.kind === server.EventInstall) {
assert.deepEqual(response.packagesToInstall, ["@types/commander"]);
seenTelemetryEvent = true;
return;
}
super.sendResponse(response);
}
})();
const projectService = createProjectService(host, { typingsInstaller: installer });
projectService.openClientFile(f1.path);
installer.installAll(/*expectedCount*/ 1);
assert.isTrue(seenTelemetryEvent);
checkNumberOfProjects(projectService, { inferredProjects: 1 });
checkProjectActualFiles(projectService.inferredProjects[0], [f1.path, commander.path]);
});
});
}
+14 -10
View File
@@ -1679,6 +1679,7 @@ interface CSSStyleDeclaration {
writingMode: string | null;
zIndex: string | null;
zoom: string | null;
resize: string | null;
getPropertyPriority(propertyName: string): string;
getPropertyValue(propertyName: string): string;
item(index: number): string;
@@ -1748,6 +1749,7 @@ declare var CanvasGradient: {
}
interface CanvasPattern {
setTransform(matrix: SVGMatrix): void;
}
declare var CanvasPattern: {
@@ -2173,7 +2175,7 @@ interface DataTransfer {
effectAllowed: string;
readonly files: FileList;
readonly items: DataTransferItemList;
readonly types: DOMStringList;
readonly types: string[];
clearData(format?: string): boolean;
getData(format: string): string;
setData(format: string, data: string): boolean;
@@ -8602,7 +8604,7 @@ interface MouseEvent extends UIEvent {
readonly x: number;
readonly y: number;
getModifierState(keyArg: string): boolean;
initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void;
initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget | null): void;
}
declare var MouseEvent: {
@@ -8715,6 +8717,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte
readonly plugins: PluginArray;
readonly pointerEnabled: boolean;
readonly webdriver: boolean;
readonly hardwareConcurrency: number;
getGamepads(): Gamepad[];
javaEnabled(): boolean;
msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void;
@@ -8732,18 +8735,18 @@ interface Node extends EventTarget {
readonly attributes: NamedNodeMap;
readonly baseURI: string | null;
readonly childNodes: NodeList;
readonly firstChild: Node;
readonly lastChild: Node;
readonly firstChild: Node | null;
readonly lastChild: Node | null;
readonly localName: string | null;
readonly namespaceURI: string | null;
readonly nextSibling: Node;
readonly nextSibling: Node | null;
readonly nodeName: string;
readonly nodeType: number;
nodeValue: string | null;
readonly ownerDocument: Document;
readonly parentElement: HTMLElement;
readonly parentNode: Node;
readonly previousSibling: Node;
readonly parentElement: HTMLElement | null;
readonly parentNode: Node | null;
readonly previousSibling: Node | null;
textContent: string | null;
appendChild(newChild: Node): Node;
cloneNode(deep?: boolean): Node;
@@ -12853,7 +12856,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
readonly devicePixelRatio: number;
readonly doNotTrack: string;
readonly document: Document;
event: Event;
event: Event | undefined;
readonly external: External;
readonly frameElement: Element;
readonly frames: Window;
@@ -13155,6 +13158,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
readonly upload: XMLHttpRequestUpload;
withCredentials: boolean;
msCaching?: string;
readonly responseURL: string;
abort(): void;
getAllResponseHeaders(): string;
getResponseHeader(header: string): string | null;
@@ -14301,7 +14305,7 @@ declare var defaultStatus: string;
declare var devicePixelRatio: number;
declare var doNotTrack: string;
declare var document: Document;
declare var event: Event;
declare var event: Event | undefined;
declare var external: External;
declare var frameElement: Element;
declare var frames: Window;
+2
View File
@@ -740,6 +740,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
readonly upload: XMLHttpRequestUpload;
withCredentials: boolean;
msCaching?: string;
readonly responseURL: string;
abort(): void;
getAllResponseHeaders(): string;
getResponseHeader(header: string): string | null;
@@ -902,6 +903,7 @@ declare var WorkerLocation: {
}
interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine {
readonly hardwareConcurrency: number;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
+1 -12
View File
@@ -5,15 +5,6 @@
namespace ts.server {
interface Hash {
update(data: any, input_encoding?: string): Hash;
digest(encoding: string): any;
}
const crypto: {
createHash(algorithm: string): Hash
} = require("crypto");
export function shouldEmitFile(scriptInfo: ScriptInfo) {
return !scriptInfo.hasMixedContent;
}
@@ -49,9 +40,7 @@ namespace ts.server {
}
private computeHash(text: string): string {
return crypto.createHash("md5")
.update(text)
.digest("base64");
return this.project.projectService.host.createHash(text);
}
private getSourceFile(): SourceFile {
+10 -3
View File
@@ -250,6 +250,8 @@ namespace ts.server {
readonly typingsInstaller: ITypingsInstaller = nullTypingsInstaller,
private readonly eventHandler?: ProjectServiceEventHandler) {
Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService");
this.toCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
this.directoryWatchers = new DirectoryWatchers(this);
this.throttledOperations = new ThrottledOperations(host);
@@ -286,10 +288,10 @@ namespace ts.server {
return;
}
switch (response.kind) {
case "set":
case ActionSet:
this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.unresolvedImports, response.typings);
break;
case "invalidate":
case ActionInvalidate:
this.typingsCache.deleteTypingsForProject(response.projectName);
break;
}
@@ -298,6 +300,9 @@ namespace ts.server {
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void {
this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions);
// always set 'allowNonTsExtensions' for inferred projects since user cannot configure it from the outside
// previously we did not expose a way for user to change these settings and this option was enabled by default
this.compilerOptionsForInferredProjects.allowNonTsExtensions = true;
this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave;
for (const proj of this.inferredProjects) {
proj.setCompilerOptions(this.compilerOptionsForInferredProjects);
@@ -1285,7 +1290,9 @@ namespace ts.server {
for (const file of proj.rootFiles) {
const normalized = toNormalizedPath(file.fileName);
if (getBaseFileName(normalized) === "tsconfig.json") {
(tsConfigFiles || (tsConfigFiles = [])).push(normalized);
if (this.host.fileExists(normalized)) {
(tsConfigFiles || (tsConfigFiles = [])).push(normalized);
}
}
else {
rootFiles.push(file);
+5
View File
@@ -13,6 +13,7 @@ namespace ts.server {
private readonly resolveModuleName: typeof resolveModuleName;
readonly trace: (s: string) => void;
readonly realpath?: (path: string) => string;
constructor(private readonly host: ServerHost, private readonly project: Project, private readonly cancellationToken: HostCancellationToken) {
this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames);
@@ -39,6 +40,10 @@ namespace ts.server {
}
return primaryResult;
};
if (this.host.realpath) {
this.realpath = path => this.host.realpath(path);
}
}
public startRecordingFilesWithChangedResolutions() {
+13 -3
View File
@@ -161,6 +161,10 @@ namespace ts.server {
this.compilerOptions.allowNonTsExtensions = true;
}
if (this.projectKind === ProjectKind.Inferred) {
this.compilerOptions.noEmitOverwritenFiles = true;
}
if (languageServiceEnabled) {
this.enableLanguageService();
}
@@ -297,7 +301,7 @@ namespace ts.server {
return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles);
}
getFileNames() {
getFileNames(excludeFilesFromExternalLibraries?: boolean) {
if (!this.program) {
return [];
}
@@ -313,8 +317,14 @@ namespace ts.server {
}
return rootFiles;
}
const sourceFiles = this.program.getSourceFiles();
return sourceFiles.map(sourceFile => asNormalizedPath(sourceFile.fileName));
const result: NormalizedPath[] = [];
for (const f of this.program.getSourceFiles()) {
if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) {
continue;
}
result.push(asNormalizedPath(f.fileName));
}
return result;
}
getAllEmittableFiles() {
+26
View File
@@ -2057,6 +2057,32 @@ namespace ts.server.protocol {
childItems?: NavigationTree[];
}
export type TelemetryEventName = "telemetry";
export interface TelemetryEvent extends Event {
event: TelemetryEventName;
body: TelemetryEventBody;
}
export interface TelemetryEventBody {
telemetryEventName: string;
payload: any;
}
export type TypingsInstalledTelemetryEventName = "typingsInstalled";
export interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody {
telemetryEventName: TypingsInstalledTelemetryEventName;
payload: TypingsInstalledTelemetryEventPayload;
}
export interface TypingsInstalledTelemetryEventPayload {
/**
* Comma separated list of installed typing packages
*/
installedPackages: string;
}
export interface NavBarResponse extends Response {
body?: NavigationBarItem[];
}
+54 -23
View File
@@ -1,4 +1,5 @@
/// <reference types="node" />
/// <reference path="shared.ts" />
/// <reference path="session.ts" />
// used in fs.writeSync
/* tslint:disable:no-null-keyword */
@@ -196,8 +197,10 @@ namespace ts.server {
private socket: NodeSocket;
private projectService: ProjectService;
private throttledOperations: ThrottledOperations;
private telemetrySender: EventSender;
constructor(
private readonly telemetryEnabled: boolean,
private readonly logger: server.Logger,
host: ServerHost,
eventPort: number,
@@ -226,15 +229,22 @@ namespace ts.server {
this.socket.write(formatMessage({ seq, type: "event", event, body }, this.logger, Buffer.byteLength, this.newLine), "utf8");
}
setTelemetrySender(telemetrySender: EventSender) {
this.telemetrySender = telemetrySender;
}
attach(projectService: ProjectService) {
this.projectService = projectService;
if (this.logger.hasLevel(LogLevel.requestTime)) {
this.logger.info("Binding...");
}
const args: string[] = ["--globalTypingsCacheLocation", this.globalTypingsCacheLocation];
const args: string[] = [Arguments.GlobalCacheLocation, this.globalTypingsCacheLocation];
if (this.telemetryEnabled) {
args.push(Arguments.EnableTelemetry);
}
if (this.logger.loggingEnabled() && this.logger.getLogFileName()) {
args.push("--logFile", combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`));
args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`));
}
const execArgv: string[] = [];
{
@@ -280,12 +290,25 @@ namespace ts.server {
});
}
private handleMessage(response: SetTypings | InvalidateCachedTypings) {
private handleMessage(response: SetTypings | InvalidateCachedTypings | TypingsInstallEvent) {
if (this.logger.hasLevel(LogLevel.verbose)) {
this.logger.info(`Received response: ${JSON.stringify(response)}`);
}
if (response.kind === EventInstall) {
if (this.telemetrySender) {
const body: protocol.TypingsInstalledTelemetryEventBody = {
telemetryEventName: "typingsInstalled",
payload: {
installedPackages: response.packagesToInstall.join(",")
}
};
const eventName: protocol.TelemetryEventName = "telemetry";
this.telemetrySender.event(body, eventName);
}
return;
}
this.projectService.updateTypingsForProject(response);
if (response.kind == "set" && this.socket) {
if (response.kind == ActionSet && this.socket) {
this.sendEvent(0, "setTypings", response);
}
}
@@ -300,18 +323,25 @@ namespace ts.server {
useSingleInferredProject: boolean,
disableAutomaticTypingAcquisition: boolean,
globalTypingsCacheLocation: string,
telemetryEnabled: boolean,
logger: server.Logger) {
super(
host,
cancellationToken,
useSingleInferredProject,
disableAutomaticTypingAcquisition
? nullTypingsInstaller
: new NodeTypingsInstaller(logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine),
Buffer.byteLength,
process.hrtime,
logger,
canUseEvents);
const typingsInstaller = disableAutomaticTypingAcquisition
? undefined
: new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine);
super(
host,
cancellationToken,
useSingleInferredProject,
typingsInstaller || nullTypingsInstaller,
Buffer.byteLength,
process.hrtime,
logger,
canUseEvents);
if (telemetryEnabled && typingsInstaller) {
typingsInstaller.setTelemetrySender(this);
}
}
exit() {
@@ -538,17 +568,17 @@ namespace ts.server {
let eventPort: number;
{
const index = sys.args.indexOf("--eventPort");
if (index >= 0 && index < sys.args.length - 1) {
const v = parseInt(sys.args[index + 1]);
if (!isNaN(v)) {
eventPort = v;
}
const str = findArgument("--eventPort");
const v = str && parseInt(str);
if (!isNaN(v)) {
eventPort = v;
}
}
const useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0;
const disableAutomaticTypingAcquisition = sys.args.indexOf("--disableAutomaticTypingAcquisition") >= 0;
const useSingleInferredProject = hasArgument("--useSingleInferredProject");
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
const telemetryEnabled = hasArgument(Arguments.EnableTelemetry);
const ioSession = new IOSession(
sys,
cancellationToken,
@@ -557,6 +587,7 @@ namespace ts.server {
useSingleInferredProject,
disableAutomaticTypingAcquisition,
getGlobalTypingsCacheLocation(),
telemetryEnabled,
logger);
process.on("uncaughtException", function (err: Error) {
ioSession.logError(err, "unknown");
+5 -1
View File
@@ -73,6 +73,10 @@ namespace ts.server {
project: Project;
}
export interface EventSender {
event(payload: any, eventName: string): void;
}
function allEditsBeforePos(edits: ts.TextChange[], pos: number) {
for (const edit of edits) {
if (textSpanEnd(edit.span) >= pos) {
@@ -165,7 +169,7 @@ namespace ts.server {
return `Content-Length: ${1 + len}\r\n\r\n${json}${newLine}`;
}
export class Session {
export class Session implements EventSender {
private readonly gcTimer: GcTimer;
protected projectService: ProjectService;
private errorTimer: any; /*NodeJS.Timer | number*/
+24
View File
@@ -0,0 +1,24 @@
/// <reference path="types.d.ts" />
namespace ts.server {
export const ActionSet: ActionSet = "action::set";
export const ActionInvalidate: ActionInvalidate = "action::invalidate";
export const EventInstall: EventInstall = "event::install";
export namespace Arguments {
export const GlobalCacheLocation = "--globalTypingsCacheLocation";
export const LogFile = "--logFile";
export const EnableTelemetry = "--enableTelemetry";
}
export function hasArgument(argumentName: string) {
return sys.args.indexOf(argumentName) >= 0;
}
export function findArgument(argumentName: string) {
const index = sys.args.indexOf(argumentName);
return index >= 0 && index < sys.args.length - 1
? sys.args[index + 1]
: undefined;
}
}
+1
View File
@@ -18,6 +18,7 @@
"files": [
"../services/shims.ts",
"../services/utilities.ts",
"shared.ts",
"utilities.ts",
"scriptVersionCache.ts",
"scriptInfo.ts",
+1
View File
@@ -15,6 +15,7 @@
"files": [
"../services/shims.ts",
"../services/utilities.ts",
"shared.ts",
"utilities.ts",
"scriptVersionCache.ts",
"scriptInfo.ts",
+19 -9
View File
@@ -41,28 +41,38 @@ declare namespace ts.server {
readonly kind: "closeProject";
}
export type SetRequest = "set";
export type InvalidateRequest = "invalidate";
export type ActionSet = "action::set";
export type ActionInvalidate = "action::invalidate";
export type EventInstall = "event::install";
export interface TypingInstallerResponse {
readonly projectName: string;
readonly kind: SetRequest | InvalidateRequest;
readonly kind: ActionSet | ActionInvalidate | EventInstall;
}
export interface SetTypings extends TypingInstallerResponse {
export interface ProjectResponse extends TypingInstallerResponse {
readonly projectName: string;
}
export interface SetTypings extends ProjectResponse {
readonly typingOptions: ts.TypingOptions;
readonly compilerOptions: ts.CompilerOptions;
readonly typings: string[];
readonly unresolvedImports: SortedReadonlyArray<string>;
readonly kind: SetRequest;
readonly kind: ActionSet;
}
export interface InvalidateCachedTypings extends TypingInstallerResponse {
readonly kind: InvalidateRequest;
export interface InvalidateCachedTypings extends ProjectResponse {
readonly kind: ActionInvalidate;
}
export interface TypingsInstallEvent extends TypingInstallerResponse {
readonly packagesToInstall: ReadonlyArray<string>;
readonly kind: EventInstall;
}
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
writeFile(path: string, content: string): void;
createDirectory(path: string): void;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher;
}
}
@@ -33,42 +33,81 @@ namespace ts.server.typingsInstaller {
}
}
type HttpGet = {
(url: string, callback: (response: HttpResponse) => void): NodeJS.EventEmitter;
};
interface HttpResponse extends NodeJS.ReadableStream {
statusCode: number;
statusMessage: string;
destroy(): void;
interface TypesRegistryFile {
entries: MapLike<void>;
}
function loadTypesRegistryFile(typesRegistryFilePath: string, host: InstallTypingHost, log: Log): Map<void> {
if (!host.fileExists(typesRegistryFilePath)) {
if (log.isEnabled()) {
log.writeLine(`Types registry file '${typesRegistryFilePath}' does not exist`);
}
return createMap<void>();
}
try {
const content = <TypesRegistryFile>JSON.parse(host.readFile(typesRegistryFilePath));
return createMap<void>(content.entries);
}
catch (e) {
if (log.isEnabled()) {
log.writeLine(`Error when loading types registry file '${typesRegistryFilePath}': ${(<Error>e).message}, ${(<Error>e).stack}`);
}
return createMap<void>();
}
}
const TypesRegistryPackageName = "types-registry";
function getTypesRegistryFileLocation(globalTypingsCacheLocation: string): string {
return combinePaths(normalizeSlashes(globalTypingsCacheLocation), `node_modules/${TypesRegistryPackageName}/index.json`);
}
type Exec = {
(command: string, options: { cwd: string }, callback?: (error: Error, stdout: string, stderr: string) => void): any
};
type ExecSync = {
(command: string, options: { cwd: string, stdio: "ignore" }): any
};
export class NodeTypingsInstaller extends TypingsInstaller {
private readonly exec: Exec;
private readonly httpGet: HttpGet;
private readonly npmPath: string;
readonly installTypingHost: InstallTypingHost = sys;
readonly typesRegistry: Map<void>;
constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) {
constructor(globalTypingsCacheLocation: string, throttleLimit: number, telemetryEnabled: boolean, log: Log) {
super(
sys,
globalTypingsCacheLocation,
toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
throttleLimit,
telemetryEnabled,
log);
if (this.log.isEnabled()) {
this.log.writeLine(`Process id: ${process.pid}`);
}
this.npmPath = getNPMLocation(process.argv[0]);
this.exec = require("child_process").exec;
this.httpGet = require("http").get;
let execSync: ExecSync;
({ exec: this.exec, execSync } = require("child_process"));
this.ensurePackageDirectoryExists(globalTypingsCacheLocation);
try {
if (this.log.isEnabled()) {
this.log.writeLine(`Updating ${TypesRegistryPackageName} npm package...`);
}
execSync(`${this.npmPath} install ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" });
}
catch (e) {
if (this.log.isEnabled()) {
this.log.writeLine(`Error updating ${TypesRegistryPackageName} package: ${(<Error>e).message}`);
}
}
this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), this.installTypingHost, this.log);
}
init() {
super.init();
listen() {
process.on("message", (req: DiscoverTypings | CloseProject) => {
switch (req.kind) {
case "discover":
@@ -90,66 +129,26 @@ namespace ts.server.typingsInstaller {
}
}
protected executeRequest(requestKind: RequestKind, requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void {
protected installWorker(requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void {
if (this.log.isEnabled()) {
this.log.writeLine(`#${requestId} executing ${requestKind}, arguments'${JSON.stringify(args)}'.`);
}
switch (requestKind) {
case NpmViewRequest: {
// const command = `${self.npmPath} view @types/${typing} --silent name`;
// use http request to global npm registry instead of running npm view
Debug.assert(args.length === 1);
const url = `http://registry.npmjs.org/@types%2f${args[0]}`;
const start = Date.now();
this.httpGet(url, response => {
let ok = false;
if (this.log.isEnabled()) {
this.log.writeLine(`${requestKind} #${requestId} request to ${url}:: status code ${response.statusCode}, status message '${response.statusMessage}', took ${Date.now() - start} ms`);
}
switch (response.statusCode) {
case 200: // OK
case 301: // redirect - Moved - treat package as present
case 302: // redirect - Found - treat package as present
ok = true;
break;
}
response.destroy();
onRequestCompleted(ok);
}).on("error", (err: Error) => {
if (this.log.isEnabled()) {
this.log.writeLine(`${requestKind} #${requestId} query to npm registry failed with error ${err.message}, stack ${err.stack}`);
}
onRequestCompleted(/*success*/ false);
});
}
break;
case NpmInstallRequest: {
const command = `${this.npmPath} install ${args.join(" ")} --save-dev`;
const start = Date.now();
this.exec(command, { cwd }, (_err, stdout, stderr) => {
if (this.log.isEnabled()) {
this.log.writeLine(`${requestKind} #${requestId} took: ${Date.now() - start} ms${sys.newLine}stdout: ${stdout}${sys.newLine}stderr: ${stderr}`);
}
// treat any output on stdout as success
onRequestCompleted(!!stdout);
});
}
break;
default:
Debug.assert(false, `Unknown request kind ${requestKind}`);
this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(args)}'.`);
}
const command = `${this.npmPath} install ${args.join(" ")} --save-dev`;
const start = Date.now();
this.exec(command, { cwd }, (_err, stdout, stderr) => {
if (this.log.isEnabled()) {
this.log.writeLine(`npm install #${requestId} took: ${Date.now() - start} ms${sys.newLine}stdout: ${stdout}${sys.newLine}stderr: ${stderr}`);
}
// treat any output on stdout as success
onRequestCompleted(!!stdout);
});
}
}
function findArgument(argumentName: string) {
const index = sys.args.indexOf(argumentName);
return index >= 0 && index < sys.args.length - 1
? sys.args[index + 1]
: undefined;
}
const logFilePath = findArgument(server.Arguments.LogFile);
const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation);
const telemetryEnabled = hasArgument(server.Arguments.EnableTelemetry);
const logFilePath = findArgument("--logFile");
const globalTypingsCacheLocation = findArgument("--globalTypingsCacheLocation");
const log = new FileLog(logFilePath);
if (log.isEnabled()) {
process.on("uncaughtException", (e: Error) => {
@@ -162,6 +161,6 @@ namespace ts.server.typingsInstaller {
}
process.exit(0);
});
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, /*throttleLimit*/5, log);
installer.init();
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, /*throttleLimit*/5, telemetryEnabled, log);
installer.listen();
}
@@ -17,6 +17,7 @@
},
"files": [
"../types.d.ts",
"../shared.ts",
"typingsInstaller.ts",
"nodeTypingsInstaller.ts"
]
+56 -81
View File
@@ -2,6 +2,7 @@
/// <reference path="../../compiler/moduleNameResolver.ts" />
/// <reference path="../../services/jsTyping.ts"/>
/// <reference path="../types.d.ts"/>
/// <reference path="../shared.ts"/>
namespace ts.server.typingsInstaller {
interface NpmConfig {
@@ -63,14 +64,8 @@ namespace ts.server.typingsInstaller {
return PackageNameValidationResult.Ok;
}
export const NpmViewRequest: "npm view" = "npm view";
export const NpmInstallRequest: "npm install" = "npm install";
export type RequestKind = typeof NpmViewRequest | typeof NpmInstallRequest;
export type RequestCompletedAction = (success: boolean) => void;
type PendingRequest = {
requestKind: RequestKind;
requestId: number;
args: string[];
cwd: string;
@@ -87,19 +82,18 @@ namespace ts.server.typingsInstaller {
private installRunCount = 1;
private inFlightRequestCount = 0;
abstract readonly installTypingHost: InstallTypingHost;
abstract readonly typesRegistry: Map<void>;
constructor(
readonly installTypingHost: InstallTypingHost,
readonly globalCachePath: string,
readonly safeListPath: Path,
readonly throttleLimit: number,
readonly telemetryEnabled: boolean,
protected readonly log = nullLog) {
if (this.log.isEnabled()) {
this.log.writeLine(`Global cache location '${globalCachePath}', safe file path '${safeListPath}'`);
}
}
init() {
this.processCacheLocation(this.globalCachePath);
}
@@ -224,7 +218,7 @@ namespace ts.server.typingsInstaller {
this.knownCachesSet[cacheLocation] = true;
}
private filterTypings(typingsToInstall: string[]) {
private filterAndMapToScopedName(typingsToInstall: string[]) {
if (typingsToInstall.length === 0) {
return typingsToInstall;
}
@@ -235,7 +229,14 @@ namespace ts.server.typingsInstaller {
}
const validationResult = validatePackageName(typing);
if (validationResult === PackageNameValidationResult.Ok) {
result.push(typing);
if (typing in this.typesRegistry) {
result.push(`@types/${typing}`);
}
else {
if (this.log.isEnabled()) {
this.log.writeLine(`Entry for package '${typing}' does not exist in local types registry - skipping...`);
}
}
}
else {
// add typing name to missing set so we won't process it again
@@ -267,19 +268,8 @@ namespace ts.server.typingsInstaller {
return result;
}
private installTypings(req: DiscoverTypings, cachePath: string, currentlyCachedTypings: string[], typingsToInstall: string[]) {
if (this.log.isEnabled()) {
this.log.writeLine(`Installing typings ${JSON.stringify(typingsToInstall)}`);
}
typingsToInstall = this.filterTypings(typingsToInstall);
if (typingsToInstall.length === 0) {
if (this.log.isEnabled()) {
this.log.writeLine(`All typings are known to be missing or invalid - no need to go any further`);
}
return;
}
const npmConfigPath = combinePaths(cachePath, "package.json");
protected ensurePackageDirectoryExists(directory: string) {
const npmConfigPath = combinePaths(directory, "package.json");
if (this.log.isEnabled()) {
this.log.writeLine(`Npm config file: ${npmConfigPath}`);
}
@@ -287,23 +277,50 @@ namespace ts.server.typingsInstaller {
if (this.log.isEnabled()) {
this.log.writeLine(`Npm config file: '${npmConfigPath}' is missing, creating new one...`);
}
this.ensureDirectoryExists(cachePath, this.installTypingHost);
this.ensureDirectoryExists(directory, this.installTypingHost);
this.installTypingHost.writeFile(npmConfigPath, "{}");
}
}
private installTypings(req: DiscoverTypings, cachePath: string, currentlyCachedTypings: string[], typingsToInstall: string[]) {
if (this.log.isEnabled()) {
this.log.writeLine(`Installing typings ${JSON.stringify(typingsToInstall)}`);
}
const scopedTypings = this.filterAndMapToScopedName(typingsToInstall);
if (scopedTypings.length === 0) {
if (this.log.isEnabled()) {
this.log.writeLine(`All typings are known to be missing or invalid - no need to go any further`);
}
return;
}
this.ensurePackageDirectoryExists(cachePath);
const requestId = this.installRunCount;
this.installRunCount++;
this.installTypingsAsync(requestId, scopedTypings, cachePath, ok => {
if (this.telemetryEnabled) {
this.sendResponse(<TypingsInstallEvent>{
kind: EventInstall,
packagesToInstall: scopedTypings
});
}
if (!ok) {
return;
}
this.runInstall(cachePath, typingsToInstall, installedTypings => {
// TODO: watch project directory
if (this.log.isEnabled()) {
this.log.writeLine(`Requested to install typings ${JSON.stringify(typingsToInstall)}, installed typings ${JSON.stringify(installedTypings)}`);
this.log.writeLine(`Requested to install typings ${JSON.stringify(scopedTypings)}, installed typings ${JSON.stringify(scopedTypings)}`);
}
const installedPackages: Map<true> = createMap<true>();
const installedTypingFiles: string[] = [];
for (const t of installedTypings) {
for (const t of scopedTypings) {
const packageName = getBaseFileName(t);
if (!packageName) {
continue;
}
installedPackages[packageName] = true;
const typingFile = typingToFileName(cachePath, packageName, this.installTypingHost);
if (!typingFile) {
continue;
@@ -316,53 +333,11 @@ namespace ts.server.typingsInstaller {
if (this.log.isEnabled()) {
this.log.writeLine(`Installed typing files ${JSON.stringify(installedTypingFiles)}`);
}
for (const toInstall of typingsToInstall) {
if (!installedPackages[toInstall]) {
if (this.log.isEnabled()) {
this.log.writeLine(`New missing typing package '${toInstall}'`);
}
this.missingTypingsSet[toInstall] = true;
}
}
this.sendResponse(this.createSetTypings(req, currentlyCachedTypings.concat(installedTypingFiles)));
});
}
private runInstall(cachePath: string, typingsToInstall: string[], postInstallAction: (installedTypings: string[]) => void): void {
const requestId = this.installRunCount;
this.installRunCount++;
let execInstallCmdCount = 0;
const filteredTypings: string[] = [];
for (const typing of typingsToInstall) {
filterExistingTypings(this, typing);
}
function filterExistingTypings(self: TypingsInstaller, typing: string) {
self.execAsync(NpmViewRequest, requestId, [typing], cachePath, ok => {
if (ok) {
filteredTypings.push(typing);
}
execInstallCmdCount++;
if (execInstallCmdCount === typingsToInstall.length) {
installFilteredTypings(self, filteredTypings);
}
});
}
function installFilteredTypings(self: TypingsInstaller, filteredTypings: string[]) {
if (filteredTypings.length === 0) {
postInstallAction([]);
return;
}
const scopedTypings = filteredTypings.map(t => "@types/" + t);
self.execAsync(NpmInstallRequest, requestId, scopedTypings, cachePath, ok => {
postInstallAction(ok ? scopedTypings : []);
});
}
}
private ensureDirectoryExists(directory: string, host: InstallTypingHost): void {
const directoryName = getDirectoryPath(directory);
if (!host.directoryExists(directoryName)) {
@@ -389,10 +364,10 @@ namespace ts.server.typingsInstaller {
this.log.writeLine(`Got FS notification for ${f}, handler is already invoked '${isInvoked}'`);
}
if (!isInvoked) {
this.sendResponse({ projectName: projectName, kind: "invalidate" });
this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate });
isInvoked = true;
}
});
}, /*pollingInterval*/ 2000);
watchers.push(w);
}
this.projectWatchers[projectName] = watchers;
@@ -405,12 +380,12 @@ namespace ts.server.typingsInstaller {
compilerOptions: request.compilerOptions,
typings,
unresolvedImports: request.unresolvedImports,
kind: "set"
kind: server.ActionSet
};
}
private execAsync(requestKind: RequestKind, requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void {
this.pendingRunRequests.unshift({ requestKind, requestId, args, cwd, onRequestCompleted });
private installTypingsAsync(requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void {
this.pendingRunRequests.unshift({ requestId, args, cwd, onRequestCompleted });
this.executeWithThrottling();
}
@@ -418,7 +393,7 @@ namespace ts.server.typingsInstaller {
while (this.inFlightRequestCount < this.throttleLimit && this.pendingRunRequests.length) {
this.inFlightRequestCount++;
const request = this.pendingRunRequests.pop();
this.executeRequest(request.requestKind, request.requestId, request.args, request.cwd, ok => {
this.installWorker(request.requestId, request.args, request.cwd, ok => {
this.inFlightRequestCount--;
request.onRequestCompleted(ok);
this.executeWithThrottling();
@@ -426,7 +401,7 @@ namespace ts.server.typingsInstaller {
}
}
protected abstract executeRequest(requestKind: RequestKind, requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void;
protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings): void;
protected abstract installWorker(requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void;
protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | TypingsInstallEvent): void;
}
}
+3 -1
View File
@@ -1,4 +1,5 @@
/// <reference path="types.d.ts" />
/// <reference path="shared.ts" />
namespace ts.server {
export enum LogLevel {
@@ -10,6 +11,7 @@ namespace ts.server {
export const emptyArray: ReadonlyArray<any> = [];
export interface Logger {
close(): void;
hasLevel(level: LogLevel): boolean;
@@ -48,7 +50,7 @@ namespace ts.server {
export function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
return {
projectName: project.getProjectName(),
fileNames: project.getFileNames(),
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true),
compilerOptions: project.getCompilerOptions(),
typingOptions,
unresolvedImports,
+1 -1
View File
@@ -88,7 +88,7 @@ namespace ts.JsTyping {
exclude = typingOptions.exclude || [];
const possibleSearchDirs = map(fileNames, getDirectoryPath);
if (projectRootPath !== undefined) {
if (projectRootPath) {
possibleSearchDirs.push(projectRootPath);
}
searchDirs = deduplicate(possibleSearchDirs);
+1 -2
View File
@@ -48,7 +48,6 @@ namespace ts {
public jsDocComments: JSDoc[];
public original: Node;
public transformFlags: TransformFlags;
public excludeTransformFlags: TransformFlags;
private _children: Node[];
constructor(kind: SyntaxKind, pos: number, end: number) {
@@ -56,7 +55,6 @@ namespace ts {
this.end = end;
this.flags = NodeFlags.None;
this.transformFlags = undefined;
this.excludeTransformFlags = undefined;
this.parent = undefined;
this.kind = kind;
}
@@ -472,6 +470,7 @@ namespace ts {
public imports: LiteralExpression[];
public moduleAugmentations: LiteralExpression[];
private namedDeclarations: Map<Declaration[]>;
public ambientModuleNames: string[];
constructor(kind: SyntaxKind, pos: number, end: number) {
super(kind, pos, end);
+4 -1
View File
@@ -557,7 +557,9 @@ namespace ts.SignatureHelp {
addRange(prefixDisplayParts, callTargetDisplayParts);
}
let isVariadic: boolean;
if (isTypeParameterList) {
isVariadic = false; // type parameter lists are not variadic
prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken));
const typeParameters = candidateSignature.typeParameters;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
@@ -567,6 +569,7 @@ namespace ts.SignatureHelp {
addRange(suffixDisplayParts, parameterParts);
}
else {
isVariadic = candidateSignature.hasRestParameter;
const typeParameterParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
addRange(prefixDisplayParts, typeParameterParts);
@@ -582,7 +585,7 @@ namespace ts.SignatureHelp {
addRange(suffixDisplayParts, returnTypeParts);
return {
isVariadic: candidateSignature.hasRestParameter,
isVariadic,
prefixDisplayParts,
suffixDisplayParts,
separatorDisplayParts: [punctuationPart(SyntaxKind.CommaToken), spacePart()],
@@ -1,7 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,7): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,7): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts (1 errors) ====
for ([""] of [[""]]) { }
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
@@ -6,7 +6,7 @@ tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstra
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'.
tests/cases/compiler/abstractPropertyNegative.ts(15,5): error TS1244: Abstract methods can only appear within an abstract class.
tests/cases/compiler/abstractPropertyNegative.ts(16,37): error TS1005: '{' expected.
tests/cases/compiler/abstractPropertyNegative.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/abstractPropertyNegative.ts(19,3): error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.
tests/cases/compiler/abstractPropertyNegative.ts(24,7): error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'.
Types of property 'num' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -58,8 +58,8 @@ tests/cases/compiler/abstractPropertyNegative.ts(41,18): error TS2676: Accessors
}
let c = new C();
c.ro = "error: lhs of assignment can't be readonly";
~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~
!!! error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.
abstract class WrongTypeProperty {
abstract num: number;
@@ -1,15 +1,15 @@
tests/cases/compiler/arithAssignTyping.ts(3,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'.
tests/cases/compiler/arithAssignTyping.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(8,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(9,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(10,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(11,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(12,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/arithAssignTyping.ts(3,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(5,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(6,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(7,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(8,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(9,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(10,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(11,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(12,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(13,1): error TS2539: Cannot assign to 'f' because it is not a variable.
tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2539: Cannot assign to 'f' because it is not a variable.
==== tests/cases/compiler/arithAssignTyping.ts (12 errors) ====
@@ -17,37 +17,37 @@ tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2362: The left-hand sid
f += ''; // error
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f += 1; // error
~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'.
~
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f -= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f *= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f /= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f %= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f &= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f |= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f <<= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f >>= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f >>>= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
f ^= 1; // error
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
@@ -1,4 +1,4 @@
tests/cases/conformance/types/any/assignAnyToEveryType.ts(41,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/types/any/assignAnyToEveryType.ts(41,1): error TS2539: Cannot assign to 'M' because it is not a variable.
==== tests/cases/conformance/types/any/assignAnyToEveryType.ts (1 errors) ====
@@ -44,7 +44,7 @@ tests/cases/conformance/types/any/assignAnyToEveryType.ts(41,1): error TS2364: I
M = x;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
function k<T>(a: T) {
a = x;
@@ -1,22 +1,22 @@
tests/cases/compiler/assignToEnum.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignToEnum.ts(3,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignToEnum.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/assignToEnum.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/assignToEnum.ts(2,1): error TS2539: Cannot assign to 'A' because it is not a variable.
tests/cases/compiler/assignToEnum.ts(3,1): error TS2539: Cannot assign to 'A' because it is not a variable.
tests/cases/compiler/assignToEnum.ts(4,3): error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
tests/cases/compiler/assignToEnum.ts(5,3): error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
==== tests/cases/compiler/assignToEnum.ts (4 errors) ====
enum A { foo, bar }
A = undefined; // invalid LHS
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
A = A.bar; // invalid LHS
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
A.foo = 1; // invalid LHS
~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
A.foo = A.bar; // invalid LHS
~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
@@ -1,4 +1,4 @@
tests/cases/compiler/assignToExistingClass.ts(8,13): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignToExistingClass.ts(8,13): error TS2539: Cannot assign to 'Mocked' because it is not a variable.
==== tests/cases/compiler/assignToExistingClass.ts (1 errors) ====
@@ -11,7 +11,7 @@ tests/cases/compiler/assignToExistingClass.ts(8,13): error TS2364: Invalid left-
willThrowError() {
Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression.
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'Mocked' because it is not a variable.
return { myProp: "test" };
};
}
@@ -1,4 +1,4 @@
tests/cases/compiler/assignToInvalidLHS.ts(4,9): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignToInvalidLHS.ts(4,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
==== tests/cases/compiler/assignToInvalidLHS.ts (1 errors) ====
@@ -7,4 +7,4 @@ tests/cases/compiler/assignToInvalidLHS.ts(4,9): error TS2364: Invalid left-hand
// Below is actually valid JavaScript (see http://es5.github.com/#x8.7 ), even though will always fail at runtime with 'invalid left-hand side'
var x = new y = 5;
~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
@@ -1,42 +1,42 @@
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6,21): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7,13): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(8,21): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(11,18): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(13,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(19,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(22,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(24,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(27,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(28,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(29,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6,21): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7,13): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(8,21): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(11,18): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(13,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(17,1): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(19,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(22,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(24,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(27,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(28,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(29,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,3): error TS7028: Unused label.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(44,19): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(46,27): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(50,20): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,11): error TS1005: ';' expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(54,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(57,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(58,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(59,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(60,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(61,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(62,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(63,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(64,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(65,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(66,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(67,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(68,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(69,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(54,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(57,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(58,2): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(59,2): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(60,2): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(61,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(62,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(63,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(64,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(65,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(66,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(67,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(68,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(69,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
@@ -47,61 +47,61 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
class C {
constructor() { this = value; }
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
foo() { this = value; }
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
static sfoo() { this = value; }
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
function foo() { this = value; }
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
this = value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// identifiers: module, class, enum, function
module M { export var a; }
M = value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
C = value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
enum E { }
E = value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
foo = value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
// literals
null = value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
true = value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
false = value;
~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
0 = value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
'' = value;
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
/d+/ = value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// object literals
{ a: 0} = value;
@@ -113,9 +113,9 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
// array literals
['', ''] = value;
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// super
class Derived extends C {
@@ -143,48 +143,48 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
// function calls
foo() = value;
~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// parentheses, the containted expression is value
(this) = value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(M) = value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
(C) = value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
(E) = value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
(foo) = value;
~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~~~
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
(null) = value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(true) = value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(0) = value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
('') = value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(/d+/) = value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
({}) = value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
([]) = value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(function baz() { }) = value;
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(foo()) = value;
~~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
@@ -1,12 +1,12 @@
tests/cases/compiler/assignmentToFunction.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignmentToFunction.ts(8,9): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignmentToFunction.ts(2,1): error TS2539: Cannot assign to 'fn' because it is not a variable.
tests/cases/compiler/assignmentToFunction.ts(8,9): error TS2539: Cannot assign to 'bar' because it is not a variable.
==== tests/cases/compiler/assignmentToFunction.ts (2 errors) ====
function fn() { }
fn = () => 3;
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
module foo {
function xyz() {
@@ -14,6 +14,6 @@ tests/cases/compiler/assignmentToFunction.ts(8,9): error TS2364: Invalid left-ha
}
bar = null;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'bar' because it is not a variable.
}
}
@@ -1,4 +1,4 @@
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2695: Left side of comma operator is unused and has no side effects.
@@ -6,6 +6,6 @@ tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2695:
var x;
(1, x)=0;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
@@ -3,9 +3,9 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(13,1): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(14,1): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(15,1): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(25,5): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(17,1): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(18,2): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(25,5): error TS2539: Cannot assign to 'M3' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(31,1): error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'.
Types of property 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -15,8 +15,8 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(33,1): error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'.
Types of property 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(37,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(38,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(37,1): error TS2539: Cannot assign to 'fn' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(38,2): error TS2539: Cannot assign to 'fn' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(43,5): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(44,5): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(48,5): error TS2322: Type '""' is not assignable to type 'number'.
@@ -24,10 +24,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(54,5): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(55,5): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(56,5): error TS2322: Type '""' is not assignable to type 'number'.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(62,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(63,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(69,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(62,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(63,2): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(69,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(70,2): error TS2539: Cannot assign to 'C' because it is not a variable.
==== tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts (24 errors) ====
@@ -59,10 +59,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
M = { y: 3 }; // Error
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
(M) = { y: 3 }; // Error
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
module M2 {
export module M3 {
@@ -71,7 +71,7 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
M3 = { x: 3 }; // Error
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'M3' because it is not a variable.
}
M2.M3 = { x: 3 }; // OK
(M2).M3 = { x: 3 }; // OK
@@ -97,10 +97,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
function fn() { }
fn = () => 3; // Bug 823548: Should be error (fn is not a reference)
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
(fn) = () => 3; // Should be error
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~~
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
function fn2(x: number, y: { t: number }) {
x = 3;
@@ -140,10 +140,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
}
E = undefined; // Error
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
(E) = undefined; // Error
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
class C {
@@ -151,8 +151,8 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
C = undefined; // Error
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
(C) = undefined; // Error
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
@@ -1,7 +1,7 @@
tests/cases/compiler/assignmentToReferenceTypes.ts(5,1): error TS2304: Cannot find name 'M'.
tests/cases/compiler/assignmentToReferenceTypes.ts(9,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignmentToReferenceTypes.ts(13,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/assignmentToReferenceTypes.ts(9,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/compiler/assignmentToReferenceTypes.ts(13,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2539: Cannot assign to 'f' because it is not a variable.
==== tests/cases/compiler/assignmentToReferenceTypes.ts (4 errors) ====
@@ -17,18 +17,18 @@ tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2364: Invalid
}
C = null;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
enum E {
}
E = null;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
function f() { }
f = null;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
var x = 1;
x = null;
@@ -1,8 +1,8 @@
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(11,1): error TS2304: Cannot find name 'M'.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,3): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2539: Cannot assign to 'fn' because it is not a variable.
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2693: 'I' only refers to a type, but is being used as a value here.
@@ -24,20 +24,20 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er
class C { }
C = null; // Error
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
enum E { A }
E = null; // Error
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
E.A = null; // OK per spec, Error per implementation (509581)
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
function fn() { }
fn = null; // Should be error
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
var v;
v = null; // OK
@@ -0,0 +1,10 @@
tests/cases/conformance/async/es5/asyncAliasReturnType_es5.ts(3,21): error TS1055: Type 'PromiseAlias' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
==== tests/cases/conformance/async/es5/asyncAliasReturnType_es5.ts (1 errors) ====
type PromiseAlias<T> = Promise<T>;
async function f(): PromiseAlias<void> {
~~~~~~~~~~~~~~~~~~
!!! error TS1055: Type 'PromiseAlias' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
}
@@ -77,6 +77,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
var _this = this;
var missing_1 = require("missing");
function f0() {
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/];
@@ -1,9 +1,9 @@
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(6,23): error TS1055: Type '{}' is not a valid async function return type.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(7,23): error TS1055: Type 'any' is not a valid async function return type.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS1055: Type 'number' is not a valid async function return type.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(9,23): error TS1055: Type 'PromiseLike' is not a valid async function return type.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(6,23): error TS1055: Type '{}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(7,23): error TS1055: Type 'any' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS1055: Type 'number' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(9,23): error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
Types of property 'then' are incompatible.
Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult1, TResult2>(onfulfilled: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>; }'.
@@ -20,21 +20,21 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1
async function fn1() { } // valid: Promise<void>
async function fn2(): { } { } // error
~~~
!!! error TS1055: Type '{}' is not a valid async function return type.
!!! error TS1055: Type '{}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
async function fn3(): any { } // error
~~~
!!! error TS1055: Type 'any' is not a valid async function return type.
!!! error TS1055: Type 'any' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
async function fn4(): number { } // error
~~~~~~
!!! error TS1055: Type 'number' is not a valid async function return type.
!!! error TS1055: Type 'number' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
async function fn5(): PromiseLike<void> { } // error
~~~~~~~~~~~~~~~~~
!!! error TS1055: Type 'PromiseLike' is not a valid async function return type.
!!! error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
async function fn6(): Thenable { } // error
~~~~~~~~
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type.
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
~~~~~~~~
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type.
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
!!! error TS1055: Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
!!! error TS1055: Types of property 'then' are incompatible.
!!! error TS1055: Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult1, TResult2>(onfulfilled: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>; }'.
@@ -1,5 +1,5 @@
error TS2318: Cannot find global type 'Promise'.
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1057: An async function or method must have a valid awaitable return type.
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value.
tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'.
tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all code paths return a value.
@@ -9,7 +9,7 @@ tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all co
==== tests/cases/compiler/asyncFunctionNoReturnType.ts (4 errors) ====
async () => {
~~~~~~~~~~~~~
!!! error TS1057: An async function or method must have a valid awaitable return type.
!!! error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.
~~~~~~~~~~~~~
!!! error TS7030: Not all code paths return a value.
if (window)
+28
View File
@@ -0,0 +1,28 @@
//// [asyncIIFE.ts]
function f1() {
(async () => {
await 10
throw new Error();
})();
var x = 1;
}
//// [asyncIIFE.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
function f1() {
(() => __awaiter(this, void 0, void 0, function* () {
yield 10;
throw new Error();
}))();
var x = 1;
}
@@ -0,0 +1,16 @@
=== tests/cases/compiler/asyncIIFE.ts ===
function f1() {
>f1 : Symbol(f1, Decl(asyncIIFE.ts, 0, 0))
(async () => {
await 10
throw new Error();
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
})();
var x = 1;
>x : Symbol(x, Decl(asyncIIFE.ts, 7, 7))
}
+25
View File
@@ -0,0 +1,25 @@
=== tests/cases/compiler/asyncIIFE.ts ===
function f1() {
>f1 : () => void
(async () => {
>(async () => { await 10 throw new Error(); })() : Promise<never>
>(async () => { await 10 throw new Error(); }) : () => Promise<never>
>async () => { await 10 throw new Error(); } : () => Promise<never>
await 10
>await 10 : 10
>10 : 10
throw new Error();
>new Error() : Error
>Error : ErrorConstructor
})();
var x = 1;
>x : number
>1 : 1
}
+19 -5
View File
@@ -1,6 +1,6 @@
//// [callWithSpread.ts]
interface X {
foo(x: number, y: number, ...z: string[]);
foo(x: number, y: number, ...z: string[]): X;
}
function foo(x: number, y: number, ...z: string[]) {
@@ -19,10 +19,18 @@ obj.foo(1, 2, "abc");
obj.foo(1, 2, ...a);
obj.foo(1, 2, ...a, "abc");
obj.foo(1, 2, ...a).foo(1, 2, "abc");
obj.foo(1, 2, ...a).foo(1, 2, ...a);
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
(obj.foo)(1, 2, "abc");
(obj.foo)(1, 2, ...a);
(obj.foo)(1, 2, ...a, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
xa[1].foo(1, 2, "abc");
xa[1].foo(1, 2, ...a);
xa[1].foo(1, 2, ...a, "abc");
@@ -72,13 +80,19 @@ foo.apply(void 0, [1, 2].concat(a, ["abc"]));
obj.foo(1, 2, "abc");
obj.foo.apply(obj, [1, 2].concat(a));
obj.foo.apply(obj, [1, 2].concat(a, ["abc"]));
obj.foo.apply(obj, [1, 2].concat(a)).foo(1, 2, "abc");
(_a = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_a, [1, 2].concat(a));
(_b = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_b, [1, 2].concat(a, ["abc"]));
(obj.foo)(1, 2, "abc");
obj.foo.apply(obj, [1, 2].concat(a));
obj.foo.apply(obj, [1, 2].concat(a, ["abc"]));
(obj.foo.apply(obj, [1, 2].concat(a)).foo)(1, 2, "abc");
(_c = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_c, [1, 2].concat(a));
(_d = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_d, [1, 2].concat(a, ["abc"]));
xa[1].foo(1, 2, "abc");
(_a = xa[1]).foo.apply(_a, [1, 2].concat(a));
(_b = xa[1]).foo.apply(_b, [1, 2].concat(a, ["abc"]));
(_c = xa[1]).foo.apply(_c, [1, 2, "abc"]);
(_e = xa[1]).foo.apply(_e, [1, 2].concat(a));
(_f = xa[1]).foo.apply(_f, [1, 2].concat(a, ["abc"]));
(_g = xa[1]).foo.apply(_g, [1, 2, "abc"]);
var C = (function () {
function C(x, y) {
var z = [];
@@ -109,4 +123,4 @@ var D = (function (_super) {
};
return D;
}(C));
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f, _g;
@@ -2,11 +2,12 @@
interface X {
>X : Symbol(X, Decl(callWithSpread.ts, 0, 0))
foo(x: number, y: number, ...z: string[]);
foo(x: number, y: number, ...z: string[]): X;
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>x : Symbol(x, Decl(callWithSpread.ts, 1, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 1, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 1, 29))
>X : Symbol(X, Decl(callWithSpread.ts, 0, 0))
}
function foo(x: number, y: number, ...z: string[]) {
@@ -58,6 +59,32 @@ obj.foo(1, 2, ...a, "abc");
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
obj.foo(1, 2, ...a).foo(1, 2, "abc");
>obj.foo(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
obj.foo(1, 2, ...a).foo(1, 2, ...a);
>obj.foo(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
>obj.foo(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
(obj.foo)(1, 2, "abc");
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
@@ -75,6 +102,32 @@ obj.foo(1, 2, ...a, "abc");
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
>(obj.foo)(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
>(obj.foo)(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
>(obj.foo)(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
xa[1].foo(1, 2, "abc");
>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
@@ -99,60 +152,60 @@ xa[1].foo(1, 2, ...a, "abc");
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
class C {
>C : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>C : Symbol(C, Decl(callWithSpread.ts, 36, 40))
constructor(x: number, y: number, ...z: string[]) {
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 31, 37))
>x : Symbol(x, Decl(callWithSpread.ts, 39, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 39, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 39, 37))
this.foo(x, y);
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 39, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 39, 26))
this.foo(x, y, ...z);
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 31, 37))
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 39, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 39, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 39, 37))
}
foo(x: number, y: number, ...z: string[]) {
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 35, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 35, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 35, 29))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 43, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 43, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 43, 29))
}
}
class D extends C {
>D : Symbol(D, Decl(callWithSpread.ts, 37, 1))
>C : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>D : Symbol(D, Decl(callWithSpread.ts, 45, 1))
>C : Symbol(C, Decl(callWithSpread.ts, 36, 40))
constructor() {
super(1, 2);
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
super(1, 2, ...a);
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
}
foo() {
>foo : Symbol(D.foo, Decl(callWithSpread.ts, 43, 5))
>foo : Symbol(D.foo, Decl(callWithSpread.ts, 51, 5))
super.foo(1, 2);
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
super.foo(1, 2, ...a);
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
}
}
+143 -34
View File
@@ -2,11 +2,12 @@
interface X {
>X : X
foo(x: number, y: number, ...z: string[]);
>foo : (x: number, y: number, ...z: string[]) => any
foo(x: number, y: number, ...z: string[]): X;
>foo : (x: number, y: number, ...z: string[]) => X
>x : number
>y : number
>z : string[]
>X : X
}
function foo(x: number, y: number, ...z: string[]) {
@@ -55,29 +56,80 @@ foo(1, 2, ...a, "abc");
>"abc" : "abc"
obj.foo(1, 2, "abc");
>obj.foo(1, 2, "abc") : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj.foo(1, 2, "abc") : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
obj.foo(1, 2, ...a);
>obj.foo(1, 2, ...a) : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
obj.foo(1, 2, ...a, "abc");
>obj.foo(1, 2, ...a, "abc") : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj.foo(1, 2, ...a, "abc") : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>"abc" : "abc"
obj.foo(1, 2, ...a).foo(1, 2, "abc");
>obj.foo(1, 2, ...a).foo(1, 2, "abc") : X
>obj.foo(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
obj.foo(1, 2, ...a).foo(1, 2, ...a);
>obj.foo(1, 2, ...a).foo(1, 2, ...a) : X
>obj.foo(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
>obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc") : X
>obj.foo(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
@@ -85,32 +137,89 @@ obj.foo(1, 2, ...a, "abc");
>"abc" : "abc"
(obj.foo)(1, 2, "abc");
>(obj.foo)(1, 2, "abc") : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>(obj.foo)(1, 2, "abc") : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
(obj.foo)(1, 2, ...a);
>(obj.foo)(1, 2, ...a) : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
(obj.foo)(1, 2, ...a, "abc");
>(obj.foo)(1, 2, ...a, "abc") : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>(obj.foo)(1, 2, ...a, "abc") : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>"abc" : "abc"
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
>((obj.foo)(1, 2, ...a).foo)(1, 2, "abc") : X
>((obj.foo)(1, 2, ...a).foo) : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
>((obj.foo)(1, 2, ...a).foo)(1, 2, ...a) : X
>((obj.foo)(1, 2, ...a).foo) : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
>((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc") : X
>((obj.foo)(1, 2, ...a).foo) : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
@@ -118,35 +227,35 @@ obj.foo(1, 2, ...a, "abc");
>"abc" : "abc"
xa[1].foo(1, 2, "abc");
>xa[1].foo(1, 2, "abc") : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo(1, 2, "abc") : X
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
xa[1].foo(1, 2, ...a);
>xa[1].foo(1, 2, ...a) : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo(1, 2, ...a) : X
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
xa[1].foo(1, 2, ...a, "abc");
>xa[1].foo(1, 2, ...a, "abc") : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo(1, 2, ...a, "abc") : X
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
@@ -158,11 +267,11 @@ xa[1].foo(1, 2, ...a, "abc");
>(<Function>xa[1].foo) : Function
><Function>xa[1].foo : Function
>Function : Function
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>...[1, 2, "abc"] : string | number
>[1, 2, "abc"] : (string | number)[]
>1 : 1
@@ -1,6 +1,7 @@
EmitSkipped: true
Diagnostics:
Cannot write file '/tests/cases/fourslash/b.js' because it would overwrite input file.
Cannot write file '/tests/cases/fourslash/b.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
EmitSkipped: false
FileName : /tests/cases/fourslash/a.js
@@ -1,37 +1,37 @@
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(8,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(9,9): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(9,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(12,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(13,9): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(13,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(16,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(17,9): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(22,5): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(23,5): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(26,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(27,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(31,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(34,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(35,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(38,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(39,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(17,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(22,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(23,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(26,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(27,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(31,1): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(32,1): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(34,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(35,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(38,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(39,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(49,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(50,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(51,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(52,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(50,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(51,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(52,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(53,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(54,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(54,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(55,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(56,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(56,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(59,9): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(60,9): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(63,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(64,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(64,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(70,15): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(71,15): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(75,15): error TS1034: 'super' must be followed by an argument list or member access.
@@ -43,35 +43,35 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(88,11): error TS1005: ';' expected.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(89,11): error TS1005: ';' expected.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(92,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(93,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(96,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(97,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(98,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(99,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(100,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(101,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(102,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(103,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(93,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(96,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(97,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(98,2): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(99,2): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(100,2): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(101,2): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(102,2): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(103,2): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(108,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(109,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(110,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(111,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(109,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(110,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(111,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(112,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(113,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(113,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(114,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(115,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(115,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(116,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(117,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(117,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(118,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(119,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(119,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(120,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(121,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(121,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(122,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ====
@@ -87,7 +87,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
this += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
foo() {
this *= value;
@@ -95,7 +95,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
this += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
static sfoo() {
this *= value;
@@ -103,94 +103,94 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
this += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
}
function foo() {
this *= value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
this += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
this *= value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
this += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// identifiers: module, class, enum, function
module M { export var a; }
M *= value;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
M += value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
C *= value;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
C += value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
enum E { }
E *= value;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
E += value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
foo *= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
foo += value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
// literals
null *= value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
null += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
true *= value;
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
true += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
false *= value;
~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
false += value;
~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
0 *= value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
0 += value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
'' *= value;
~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
'' += value;
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
/d+/ *= value;
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
/d+/ += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// object literals
{ a: 0} *= value;
@@ -206,7 +206,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
['', ''] += value;
~~~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// super
class Derived extends C {
@@ -259,90 +259,90 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
foo() += value;
~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// parentheses, the containted expression is value
(this) *= value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(this) += value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(M) *= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
(M) += value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
(C) *= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
(C) += value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
(E) *= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
(E) += value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
(foo) *= value;
~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~~~
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
(foo) += value;
~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~~~
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
(null) *= value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(null) += value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(true) *= value;
~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
(true) += value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(0) *= value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(0) += value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
('') *= value;
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
('') += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(/d+/) *= value;
~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
(/d+/) += value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
({}) *= value;
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
({}) += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
([]) *= value;
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
([]) += value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(function baz1() { }) *= value;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
(function baz2() { }) += value;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(foo()) *= value;
~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
(foo()) += value;
~~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
@@ -1,16 +1,16 @@
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(7,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(10,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(13,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(18,5): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(27,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(32,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(18,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(21,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(25,1): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(27,1): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(32,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(39,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(43,3): error TS7028: Unused label.
@@ -22,14 +22,14 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(65,21): error TS1128: Declaration or statement expected.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(66,11): error TS1005: ';' expected.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(69,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(72,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(73,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(74,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(76,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(72,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(73,2): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(74,2): error TS2539: Cannot assign to 'C' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,2): error TS2539: Cannot assign to 'E' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(76,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(78,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(79,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(79,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(80,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(81,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(82,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
@@ -64,36 +64,36 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
function foo() {
this **= value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
this **= value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
// identifiers: module, class, enum, function
module M { export var a; }
M **= value;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
C **= value;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
enum E { }
E **= value;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
foo **= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
// literals
null **= value;
~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
true **= value;
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
@@ -102,7 +102,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
0 **= value;
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
'' **= value;
~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
@@ -160,28 +160,28 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
// parentheses, the containted expression is value
(this) **= value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(M) **= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
(C) **= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
(E) **= value;
~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
(foo) **= value;
~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~~~
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
(null) **= value;
~~~~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
(true) **= value;
~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
(0) **= value;
~~~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
('') **= value;
~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
@@ -1,4 +1,4 @@
tests/cases/compiler/concatClassAndString.ts(4,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/concatClassAndString.ts(4,1): error TS2539: Cannot assign to 'f' because it is not a variable.
==== tests/cases/compiler/concatClassAndString.ts (1 errors) ====
@@ -7,5 +7,5 @@ tests/cases/compiler/concatClassAndString.ts(4,1): error TS2364: Invalid left-ha
f += '';
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
@@ -1,4 +1,4 @@
tests/cases/compiler/file2.ts(1,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/file2.ts(1,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
==== tests/cases/compiler/file1.ts (0 errors) ====
@@ -8,4 +8,4 @@ tests/cases/compiler/file2.ts(1,1): error TS2449: The operand of an increment or
==== tests/cases/compiler/file2.ts (1 errors) ====
x++;
~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
@@ -1,20 +1,20 @@
tests/cases/compiler/constDeclarations-access2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(7,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(16,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(18,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(19,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(20,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(21,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(23,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(5,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(6,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(7,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(8,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(9,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(10,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(11,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(12,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(13,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(14,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(15,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(16,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(18,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(19,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(20,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(21,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access2.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
==== tests/cases/compiler/constDeclarations-access2.ts (17 errors) ====
@@ -24,57 +24,57 @@ tests/cases/compiler/constDeclarations-access2.ts(23,3): error TS2449: The opera
// Errors
x = 1;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x += 2;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x -= 3;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x *= 4;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x /= 5;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x %= 6;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x <<= 7;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x >>= 8;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x >>>= 9;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x &= 10;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x |= 11;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x ^= 12;
~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x++;
~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
x--;
~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++x;
~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
--x;
~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++((x));
~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
// OK
var a = x + 1;
@@ -1,21 +1,21 @@
tests/cases/compiler/constDeclarations-access3.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(16,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(21,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(22,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(23,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(24,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(26,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(8,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(9,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(10,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(11,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(12,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(13,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(14,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(15,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(16,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(17,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(18,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(19,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(21,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(22,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(24,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(26,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access3.ts(28,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
==== tests/cases/compiler/constDeclarations-access3.ts (18 errors) ====
@@ -27,62 +27,62 @@ tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand
// Errors
M.x = 1;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x += 2;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x -= 3;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x *= 4;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x /= 5;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x %= 6;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x <<= 7;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x >>= 8;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x >>>= 9;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x &= 10;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x |= 11;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x ^= 12;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x++;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x--;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++M.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
--M.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++((M.x));
~~~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M["x"] = 0;
~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
// OK
var a = M.x + 1;
@@ -1,21 +1,21 @@
tests/cases/compiler/constDeclarations-access4.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(16,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(21,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(22,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(23,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(24,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(26,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(28,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(8,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(9,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(10,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(11,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(12,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(13,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(14,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(15,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(16,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(17,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(18,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(19,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(21,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(22,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(24,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(26,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-access4.ts(28,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
==== tests/cases/compiler/constDeclarations-access4.ts (18 errors) ====
@@ -27,62 +27,62 @@ tests/cases/compiler/constDeclarations-access4.ts(28,1): error TS2450: Left-hand
// Errors
M.x = 1;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x += 2;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x -= 3;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x *= 4;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x /= 5;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x %= 6;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x <<= 7;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x >>= 8;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x >>>= 9;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x &= 10;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x |= 11;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x ^= 12;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x++;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M.x--;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++M.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
--M.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++((M.x));
~~~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
M["x"] = 0;
~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
// OK
var a = M.x + 1;
@@ -1,21 +1,21 @@
tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(7,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(17,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(18,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(19,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(20,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(4,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(5,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(6,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(7,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(8,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(9,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(10,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(11,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(12,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(13,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(14,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(15,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(17,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(18,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(19,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(20,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(22,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations_access_2.ts(24,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ====
@@ -23,62 +23,62 @@ tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-han
import m = require('constDeclarations_access_1');
// Errors
m.x = 1;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x += 2;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x -= 3;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x *= 4;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x /= 5;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x %= 6;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x <<= 7;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x >>= 8;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x >>>= 9;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x &= 10;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x |= 11;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x ^= 12;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m
m.x++;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m.x--;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++m.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
--m.x;
~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
++((m.x));
~~~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
m["x"] = 0;
~~~~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
// OK
var a = m.x + 1;
@@ -5,7 +5,7 @@ tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' de
tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized
tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized
tests/cases/compiler/constDeclarations-errors.ts(10,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'.
tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2540: Cannot assign to 'c8' because it is a constant or a read-only property.
tests/cases/compiler/constDeclarations-errors.ts(13,11): error TS1155: 'const' declarations must be initialized
tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' declarations must be initialized
tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator '<' cannot be applied to types '0' and '1'.
@@ -37,7 +37,7 @@ tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator
~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'.
~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
!!! error TS2540: Cannot assign to 'c8' because it is a constant or a read-only property.
// error, can not be unintalized
for(const c9; c9 < 1;) { }
@@ -1,8 +1,8 @@
tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS2479: Property 'B' does not exist on 'const' enum 'E'.
tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS2339: Property 'B' does not exist on type 'typeof E'.
==== tests/cases/compiler/constEnumBadPropertyNames.ts (1 errors) ====
const enum E { A }
var x = E["B"]
~~~
!!! error TS2479: Property 'B' does not exist on 'const' enum 'E'.
!!! error TS2339: Property 'B' does not exist on type 'typeof E'.
@@ -1,7 +1,7 @@
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(14,9): 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.
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(15,12): error TS2476: A const enum member can only be accessed using a string literal.
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(17,1): error TS2322: Type '"string"' is not assignable to type 'G'.
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,3): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
==== tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts (4 errors) ====
@@ -30,6 +30,6 @@ tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,1): error TS24
!!! error TS2322: Type '"string"' is not assignable to type 'G'.
function foo(x: G) { }
G.B = 3;
~~~
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
@@ -76,16 +76,16 @@ enum numbersNotConst {
}
let s3 = test[numbersNotConst.zero];
>s3 : any
>test[numbersNotConst.zero] : any
>s3 : string
>test[numbersNotConst.zero] : string
>test : indexAccess
>numbersNotConst.zero : numbersNotConst.zero
>numbersNotConst : typeof numbersNotConst
>zero : numbersNotConst.zero
let n3 = test[numbersNotConst.one];
>n3 : any
>test[numbersNotConst.one] : any
>n3 : number
>test[numbersNotConst.one] : number
>test : indexAccess
>numbersNotConst.one : numbersNotConst.one
>numbersNotConst : typeof numbersNotConst
@@ -25,7 +25,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(59,5): error TS1
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(70,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(73,37): error TS1127: Invalid character.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(82,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,23): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,23): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(91,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(106,29): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(107,13): error TS1109: Expression expected.
@@ -236,7 +236,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS
//
var any = 0 ^=
~
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
var bool = 0;
~~~
!!! error TS1109: Expression expected.
@@ -12,4 +12,4 @@ exports.y = function (x) { return 1; };
//// [declarationEmitTypeAliasWithTypeParameters1.d.ts]
export declare type Bar<X, Y> = () => [X, Y];
export declare type Foo<Y> = Bar<any, Y>;
export declare const y: (x: () => [any, string]) => number;
export declare const y: (x: Bar<any, string>) => number;
@@ -8,15 +8,15 @@ export type Bar<X, Y> = () => [X, Y];
>Y : Y
export type Foo<Y> = Bar<any, Y>;
>Foo : () => [any, Y]
>Foo : Bar<any, Y>
>Y : Y
>Bar : Bar<X, Y>
>Y : Y
export const y = (x: Foo<string>) => 1
>y : (x: () => [any, string]) => number
>(x: Foo<string>) => 1 : (x: () => [any, string]) => number
>x : () => [any, string]
>Foo : () => [any, Y]
>y : (x: Bar<any, string>) => number
>(x: Foo<string>) => 1 : (x: Bar<any, string>) => number
>x : Bar<any, string>
>Foo : Bar<any, Y>
>1 : 1
@@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.d.ts (0 errors) ====
declare class c {
@@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/out.d.ts (0 errors) ====
declare class c {
@@ -1,16 +1,16 @@
tests/cases/compiler/decrementAndIncrementOperators.ts(4,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(6,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(7,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(9,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(10,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(12,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(13,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(15,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(16,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(18,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(19,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(21,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(22,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/compiler/decrementAndIncrementOperators.ts(4,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(6,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(7,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(9,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(10,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(12,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(13,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(15,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(16,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(18,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(19,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(21,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/compiler/decrementAndIncrementOperators.ts(22,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
==== tests/cases/compiler/decrementAndIncrementOperators.ts (13 errors) ====
@@ -19,49 +19,49 @@ tests/cases/compiler/decrementAndIncrementOperators.ts(22,3): error TS2357: The
// errors
1 ++;
~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
(1)++;
~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
(1)--;
~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
++(1);
~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
--(1);
~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
(1 + 2)++;
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
(1 + 2)--;
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
++(1 + 2);
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
--(1 + 2);
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
(x + x)++;
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
(x + x)--;
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
++(x + x);
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
--(x + x);
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
//OK
x++;
@@ -1,36 +1,36 @@
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(24,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(25,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(26,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(25,25): error TS2539: Cannot assign to 'A' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(26,25): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(27,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(28,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(30,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(31,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(32,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(31,23): error TS2539: Cannot assign to 'A' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(32,23): error TS2539: Cannot assign to 'M' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -79,10 +79,10 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
var ResultIsNumber2 = --A;
~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
var ResultIsNumber3 = --M;
~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
var ResultIsNumber4 = --obj;
~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -95,10 +95,10 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
var ResultIsNumber7 = A--;
~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
var ResultIsNumber8 = M--;
~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
var ResultIsNumber9 = obj--;
~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -115,7 +115,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
var ResultIsNumber13 = --undefined;
~~~~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'undefined' because it is not a variable.
var ResultIsNumber14 = null--;
~~~~
@@ -125,28 +125,28 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
var ResultIsNumber16 = undefined--;
~~~~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'undefined' because it is not a variable.
// any type expressions
var ResultIsNumber17 = --foo();
~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber18 = --A.foo();
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber19 = --(null + undefined);
~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber20 = --(null + null);
~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber21 = --(undefined + undefined);
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber22 = --obj1.x;
@@ -158,23 +158,23 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
var ResultIsNumber24 = foo()--;
~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber25 = A.foo()--;
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber26 = (null + undefined)--;
~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber27 = (null + null)--;
~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber28 = (undefined + undefined)--;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber29 = obj1.x--;
@@ -1,7 +1,7 @@
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(6,25): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(7,23): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(10,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(6,31): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(7,29): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(10,9): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2542: Index signature in type 'typeof ENUM1' only permits reading.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,7): error TS2304: Cannot find name 'A'.
@@ -12,19 +12,19 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
// expression
var ResultIsNumber1 = --ENUM1["A"];
~~~~~~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
var ResultIsNumber2 = ENUM1.A--;
~~~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
// miss assignment operator
--ENUM1["A"];
~~~~~~~~~~
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
~~~
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
ENUM1[A]--;
~~~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2542: Index signature in type 'typeof ENUM1' only permits reading.
~
!!! error TS2304: Cannot find name 'A'.
@@ -1,15 +1,15 @@
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(7,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(8,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(10,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(11,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(14,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(7,25): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(8,25): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(10,23): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(11,23): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(14,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(14,43): error TS2339: Property 'B' does not exist on type 'typeof ENUM'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(15,23): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(15,23): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(15,29): error TS2339: Property 'A' does not exist on type 'typeof ENUM'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(18,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(19,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(21,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(22,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(18,3): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(19,3): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(21,1): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(22,1): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts (12 errors) ====
@@ -21,41 +21,41 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
// enum type var
var ResultIsNumber1 = --ENUM;
~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
var ResultIsNumber2 = --ENUM1;
~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
var ResultIsNumber3 = ENUM--;
~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
var ResultIsNumber4 = ENUM1--;
~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
// enum type expressions
var ResultIsNumber5 = --(ENUM["A"] + ENUM.B);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~
!!! error TS2339: Property 'B' does not exist on type 'typeof ENUM'.
var ResultIsNumber6 = (ENUM.A + ENUM["B"])--;
~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~
!!! error TS2339: Property 'A' does not exist on type 'typeof ENUM'.
// miss assignment operator
--ENUM;
~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
--ENUM1;
~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
ENUM--;
~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
ENUM1--;
~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
@@ -1,23 +1,23 @@
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(18,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(19,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(22,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(22,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(23,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(24,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(26,23): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(26,23): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(27,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(28,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(31,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(32,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(33,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(35,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(36,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(37,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(40,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(31,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(32,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(33,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(35,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(36,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(37,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(40,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(41,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(42,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(44,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(42,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(44,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(45,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(46,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(46,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts (20 errors) ====
@@ -48,7 +48,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
// number type literal
var ResultIsNumber3 = --1;
~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber4 = --{ x: 1, y: 2};
~~~~~~~~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -58,7 +58,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
var ResultIsNumber6 = 1--;
~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber7 = { x: 1, y: 2 }--;
~~~~~~~~~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -69,41 +69,41 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
// number type expressions
var ResultIsNumber9 = --foo();
~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber10 = --A.foo();
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber11 = --(NUMBER + NUMBER);
~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber12 = foo()--;
~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber13 = A.foo()--;
~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
var ResultIsNumber14 = (NUMBER + NUMBER)--;
~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
// miss assignment operator
--1;
~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
--NUMBER1;
~~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
--foo();
~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
1--;
~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
NUMBER1--;
~~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
foo()--;
~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
@@ -0,0 +1,26 @@
//// [doWhileUnreachableCode.ts]
function test() {
let foo = 0;
testLoop: do {
foo++;
continue testLoop;
} while (function() {
var x = 1;
return false;
}());
return foo;
}
//// [doWhileUnreachableCode.js]
function test() {
var foo = 0;
testLoop: do {
foo++;
continue testLoop;
} while (function () {
var x = 1;
return false;
}());
return foo;
}
@@ -0,0 +1,22 @@
=== tests/cases/compiler/doWhileUnreachableCode.ts ===
function test() {
>test : Symbol(test, Decl(doWhileUnreachableCode.ts, 0, 0))
let foo = 0;
>foo : Symbol(foo, Decl(doWhileUnreachableCode.ts, 1, 7))
testLoop: do {
foo++;
>foo : Symbol(foo, Decl(doWhileUnreachableCode.ts, 1, 7))
continue testLoop;
} while (function() {
var x = 1;
>x : Symbol(x, Decl(doWhileUnreachableCode.ts, 6, 11))
return false;
}());
return foo;
>foo : Symbol(foo, Decl(doWhileUnreachableCode.ts, 1, 7))
}
@@ -0,0 +1,34 @@
=== tests/cases/compiler/doWhileUnreachableCode.ts ===
function test() {
>test : () => number
let foo = 0;
>foo : number
>0 : 0
testLoop: do {
>testLoop : any
foo++;
>foo++ : number
>foo : number
continue testLoop;
>testLoop : any
} while (function() {
>function() { var x = 1; return false; }() : boolean
>function() { var x = 1; return false; } : () => boolean
var x = 1;
>x : number
>1 : 1
return false;
>false : false
}());
return foo;
>foo : number
}

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