From e4ab2db9fb88520e81427e2c6f252fdbb717dcf8 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 26 Jan 2016 10:51:10 -0800 Subject: [PATCH 01/14] Fix find all references for salsa --- src/compiler/checker.ts | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 645b3835b9..a3052d1f12 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -376,8 +376,8 @@ namespace ts { const moduleAugmentation = moduleName.parent; if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. - // its symbol already has accumulated information for all declarations - // so we need to add it just once - do the work only for first declaration + // its symbol already has accumulated information for all declarations + // so we need to add it just once - do the work only for first declaration Debug.assert(moduleAugmentation.symbol.declarations.length > 1); return; } @@ -386,7 +386,7 @@ namespace ts { mergeSymbolTable(globals, moduleAugmentation.symbol.exports); } else { - // find a module that about to be augmented + // find a module that about to be augmented let mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); if (!mainModule) { return; @@ -812,7 +812,7 @@ namespace ts { } // No static member is present. - // Check if we're in an instance method and look for a relevant instance member. + // Check if we're in an instance method and look for a relevant instance member. if (location === container && !(location.flags & NodeFlags.Static)) { const instanceType = (getDeclaredTypeOfSymbol(classSymbol)).thisType; if (getPropertyOfType(instanceType, name)) { @@ -1163,7 +1163,7 @@ namespace ts { return getMergedSymbol(sourceFile.symbol); } if (moduleNotFoundError) { - // report errors only if it was requested + // report errors only if it was requested error(moduleReferenceLiteral, Diagnostics.File_0_is_not_a_module, sourceFile.fileName); } return undefined; @@ -2618,7 +2618,7 @@ namespace ts { } } else if (declaration.kind === SyntaxKind.Parameter) { - // If it's a parameter, see if the parent has a jsdoc comment with an @param + // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. const paramTag = getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { @@ -2633,7 +2633,7 @@ namespace ts { function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration): Type { if (declaration.parserContextFlags & ParserContextFlags.JavaScriptFile) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has - // one as its type), otherwise fallback to the below standard TS codepaths to + // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. const type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { @@ -4058,7 +4058,7 @@ namespace ts { const isJSConstructSignature = isJSDocConstructSignature(declaration); let returnType: Type = undefined; - // If this is a JSDoc construct signature, then skip the first parameter in the + // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. for (let i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { @@ -4461,7 +4461,7 @@ namespace ts { } if (symbol.flags & SymbolFlags.Value && node.kind === SyntaxKind.JSDocTypeReference) { - // A JSDocTypeReference may have resolved to a value (as opposed to a type). In + // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. return getTypeOfSymbol(symbol); @@ -10404,7 +10404,7 @@ namespace ts { /* *TypeScript Specification 1.0 (6.3) - July 2014 - * An explicitly typed function whose return type isn't the Void type, + * An explicitly typed function whose return type isn't the Void type, * the Any type, or a union type containing the Void or Any type as a constituent * must have at least one return statement somewhere in its body. * An exception to this rule is if the function implementation consists of a single 'throw' statement. @@ -14426,10 +14426,10 @@ namespace ts { if (isAmbientExternalModule) { if (isExternalModuleAugmentation(node)) { // body of the augmentation should be checked for consistency only if augmentation was applied to its target (either global scope or module) - // otherwise we'll be swamped in cascading errors. + // otherwise we'll be swamped in cascading errors. // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied - // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). + // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). const checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & SymbolFlags.Merged); if (checkBody) { // body of ambient external module is always a module block @@ -15200,6 +15200,18 @@ namespace ts { return getSymbolOfNode(entityName.parent); } + if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) { + const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case SpecialPropertyAssignmentKind.ExportsProperty: + case SpecialPropertyAssignmentKind.ThisProperty: + case SpecialPropertyAssignmentKind.PrototypeProperty: + return getSymbolOfNode(entityName.parent); + case SpecialPropertyAssignmentKind.ModuleExports: + return getSymbolOfNode(entityName.parent.parent); + } + } + if (entityName.parent.kind === SyntaxKind.ExportAssignment) { return resolveEntityName(entityName, /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); From b389e9c61984f1ac303e3382b2d3ceaa9a8e0b84 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 27 Jan 2016 12:43:31 -0800 Subject: [PATCH 02/14] Fix for thisProperty --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a3052d1f12..d590f715ed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15204,9 +15204,9 @@ namespace ts { const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case SpecialPropertyAssignmentKind.ExportsProperty: - case SpecialPropertyAssignmentKind.ThisProperty: case SpecialPropertyAssignmentKind.PrototypeProperty: return getSymbolOfNode(entityName.parent); + case SpecialPropertyAssignmentKind.ThisProperty: case SpecialPropertyAssignmentKind.ModuleExports: return getSymbolOfNode(entityName.parent.parent); } From 9a6815f3c7887c757cbe5a56dc6f6b4e67f6d2bc Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 27 Jan 2016 13:26:41 -0800 Subject: [PATCH 03/14] add tests --- tests/cases/fourslash/renameJsExports.ts | 12 ++++++++++++ tests/cases/fourslash/renameJsPrototypeProperty.ts | 12 ++++++++++++ tests/cases/fourslash/renameJsThisProperty.ts | 12 ++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/cases/fourslash/renameJsExports.ts create mode 100644 tests/cases/fourslash/renameJsPrototypeProperty.ts create mode 100644 tests/cases/fourslash/renameJsThisProperty.ts diff --git a/tests/cases/fourslash/renameJsExports.ts b/tests/cases/fourslash/renameJsExports.ts new file mode 100644 index 0000000000..227eebe4a0 --- /dev/null +++ b/tests/cases/fourslash/renameJsExports.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports.[|area|] = function (r) { return r * r; } + +// @Filename: b.js +////var mod = require('./a'); +////var t = mod./**/[|area|](10); + +goTo.marker(); +verify.renameLocations(false, false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty.ts b/tests/cases/fourslash/renameJsPrototypeProperty.ts new file mode 100644 index 0000000000..651514859c --- /dev/null +++ b/tests/cases/fourslash/renameJsPrototypeProperty.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +////} +////bar.prototype.[|x|] = 10; +////var t = new bar(); +////t./**/[|x|] = 11; + +goTo.marker(); +verify.renameLocations(false, false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty.ts b/tests/cases/fourslash/renameJsThisProperty.ts new file mode 100644 index 0000000000..aed59d298b --- /dev/null +++ b/tests/cases/fourslash/renameJsThisProperty.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +//// this.[|x|] = 10; +////} +////var t = new bar(); +////t./**/[|x|] = 11; + +goTo.marker(); +verify.renameLocations(false, false); \ No newline at end of file From 646e46e022cddbfe31655ce5f0a40b7603dcca0b Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 27 Jan 2016 13:38:42 -0800 Subject: [PATCH 04/14] Fix build error --- .../asyncFunctionDeclaration15_es6.errors.txt | 20 +++++++++---------- .../asyncImportedPromise_es6.errors.txt | 2 +- .../asyncQualifiedReturnType_es6.errors.txt | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt index 7b682f9dcd..e8d3e7d79b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,23): error TS1064: The return type of an async function or method must be the global Promise. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(7,23): error TS1064: The return type of an async function or method must be the global Promise. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(7,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise type. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member. @@ -15,19 +15,19 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 async function fn1() { } // valid: Promise async function fn2(): { } { } // error ~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise. +!!! error TS1064: The return type of an async function or method must be the global Promise type. async function fn3(): any { } // error ~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise. +!!! error TS1064: The return type of an async function or method must be the global Promise type. async function fn4(): number { } // error ~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise. +!!! error TS1064: The return type of an async function or method must be the global Promise type. async function fn5(): PromiseLike { } // error ~~~~~~~~~~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise. +!!! error TS1064: The return type of an async function or method must be the global Promise type. async function fn6(): Thenable { } // error ~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise. +!!! error TS1064: The return type of an async function or method must be the global Promise type. async function fn7() { return; } // valid: Promise async function fn8() { return 1; } // valid: Promise async function fn9() { return null; } // valid: Promise diff --git a/tests/baselines/reference/asyncImportedPromise_es6.errors.txt b/tests/baselines/reference/asyncImportedPromise_es6.errors.txt index 994445dbed..881b36704a 100644 --- a/tests/baselines/reference/asyncImportedPromise_es6.errors.txt +++ b/tests/baselines/reference/asyncImportedPromise_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/async/es6/test.ts(3,25): error TS1064: The return type of an async function or method must be the global Promise. +tests/cases/conformance/async/es6/test.ts(3,25): error TS1064: The return type of an async function or method must be the global Promise type. ==== tests/cases/conformance/async/es6/task.ts (0 errors) ==== diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es6.errors.txt b/tests/baselines/reference/asyncQualifiedReturnType_es6.errors.txt index f1d01bb2a7..205ea01673 100644 --- a/tests/baselines/reference/asyncQualifiedReturnType_es6.errors.txt +++ b/tests/baselines/reference/asyncQualifiedReturnType_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts(6,21): error TS1064: The return type of an async function or method must be the global Promise. +tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts(6,21): error TS1064: The return type of an async function or method must be the global Promise type. ==== tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts(6,21): error T async function f(): X.MyPromise { ~~~~~~~~~~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise. +!!! error TS1064: The return type of an async function or method must be the global Promise type. } \ No newline at end of file From 5b68d6559a8e126fac23388e199be29c3dab9a97 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 27 Jan 2016 15:27:11 -0800 Subject: [PATCH 05/14] strip quotes from module names during deduplication --- src/compiler/emitter.ts | 14 ++++++-- .../deduplicateImportsInSystem.errors.txt | 32 ++++++++++++++++++ .../reference/deduplicateImportsInSystem.js | 33 +++++++++++++++++++ .../compiler/deduplicateImportsInSystem.ts | 9 +++++ 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/deduplicateImportsInSystem.errors.txt create mode 100644 tests/baselines/reference/deduplicateImportsInSystem.js create mode 100644 tests/cases/compiler/deduplicateImportsInSystem.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0a40047f68..4d771bd253 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7068,14 +7068,22 @@ const _super = (function (geti, seti) { for (let i = 0; i < externalImports.length; i++) { const text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName); - if (hasProperty(groupIndices, text)) { + if (text === undefined) { + continue; + } + + // text should be quoted string + // for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same + const key = text.substr(1, text.length - 2); + + if (hasProperty(groupIndices, key)) { // deduplicate/group entries in dependency list by the dependency name - const groupIndex = groupIndices[text]; + const groupIndex = groupIndices[key]; dependencyGroups[groupIndex].push(externalImports[i]); continue; } else { - groupIndices[text] = dependencyGroups.length; + groupIndices[key] = dependencyGroups.length; dependencyGroups.push([externalImports[i]]); } diff --git a/tests/baselines/reference/deduplicateImportsInSystem.errors.txt b/tests/baselines/reference/deduplicateImportsInSystem.errors.txt new file mode 100644 index 0000000000..d1bfe88160 --- /dev/null +++ b/tests/baselines/reference/deduplicateImportsInSystem.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/deduplicateImportsInSystem.ts(1,17): error TS2307: Cannot find module 'f1'. +tests/cases/compiler/deduplicateImportsInSystem.ts(2,17): error TS2307: Cannot find module 'f2'. +tests/cases/compiler/deduplicateImportsInSystem.ts(3,17): error TS2307: Cannot find module 'f3'. +tests/cases/compiler/deduplicateImportsInSystem.ts(4,17): error TS2307: Cannot find module 'f2'. +tests/cases/compiler/deduplicateImportsInSystem.ts(5,17): error TS2307: Cannot find module 'f2'. +tests/cases/compiler/deduplicateImportsInSystem.ts(6,17): error TS2307: Cannot find module 'f1'. +tests/cases/compiler/deduplicateImportsInSystem.ts(8,1): error TS2304: Cannot find name 'console'. + + +==== tests/cases/compiler/deduplicateImportsInSystem.ts (7 errors) ==== + import {A} from "f1"; + ~~~~ +!!! error TS2307: Cannot find module 'f1'. + import {B} from "f2"; + ~~~~ +!!! error TS2307: Cannot find module 'f2'. + import {C} from "f3"; + ~~~~ +!!! error TS2307: Cannot find module 'f3'. + import {D} from 'f2'; + ~~~~ +!!! error TS2307: Cannot find module 'f2'. + import {E} from "f2"; + ~~~~ +!!! error TS2307: Cannot find module 'f2'. + import {F} from 'f1'; + ~~~~ +!!! error TS2307: Cannot find module 'f1'. + + console.log(A + B + C + D + E + F) + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. \ No newline at end of file diff --git a/tests/baselines/reference/deduplicateImportsInSystem.js b/tests/baselines/reference/deduplicateImportsInSystem.js new file mode 100644 index 0000000000..956d293cad --- /dev/null +++ b/tests/baselines/reference/deduplicateImportsInSystem.js @@ -0,0 +1,33 @@ +//// [deduplicateImportsInSystem.ts] +import {A} from "f1"; +import {B} from "f2"; +import {C} from "f3"; +import {D} from 'f2'; +import {E} from "f2"; +import {F} from 'f1'; + +console.log(A + B + C + D + E + F) + +//// [deduplicateImportsInSystem.js] +System.register(["f1", "f2", "f3"], function(exports_1) { + "use strict"; + var f1_1, f2_1, f3_1, f2_2, f2_3, f1_2; + return { + setters:[ + function (f1_1_1) { + f1_1 = f1_1_1; + f1_2 = f1_1_1; + }, + function (f2_1_1) { + f2_1 = f2_1_1; + f2_2 = f2_1_1; + f2_3 = f2_1_1; + }, + function (f3_1_1) { + f3_1 = f3_1_1; + }], + execute: function() { + console.log(f1_1.A + f2_1.B + f3_1.C + f2_2.D + f2_3.E + f1_2.F); + } + } +}); diff --git a/tests/cases/compiler/deduplicateImportsInSystem.ts b/tests/cases/compiler/deduplicateImportsInSystem.ts new file mode 100644 index 0000000000..2fcbc16be0 --- /dev/null +++ b/tests/cases/compiler/deduplicateImportsInSystem.ts @@ -0,0 +1,9 @@ +// @module: system +import {A} from "f1"; +import {B} from "f2"; +import {C} from "f3"; +import {D} from 'f2'; +import {E} from "f2"; +import {F} from 'f1'; + +console.log(A + B + C + D + E + F) \ No newline at end of file From c353252c8e7d914dbf23539633f07951213a1026 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 27 Jan 2016 19:51:43 -0800 Subject: [PATCH 06/14] Update authors for release 1.8 --- AUTHORS.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index 486a15bf47..0501514d75 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -2,9 +2,11 @@ TypeScript is authored by: * Adam Freidin * Ahmad Farid +* Akshar Patel * Anders Hejlsberg * Arnav Singh * Arthur Ozga +* Asad Saeeduddin * Basarat Ali Syed * Ben Duffield * Bill Ticehurst @@ -15,30 +17,39 @@ TypeScript is authored by: * Colby Russell * Colin Snover * Cyrus Najmabadi +* Dan Corder * Dan Quirk * Daniel Rosenwasser +* @dashaus * David Li * Denis Nedelyaev * Dick van den Brink * Dirk Bäumer +* Dirk Holtwick * Eyas Sharaiha +* @falsandtru * Frank Wallis * Gabriel Isenberg * Gilad Peleg * Graeme Wicksted * Guillaume Salles +* Guy Bedford * Harald Niesche +* Iain Monro * Ingvar Stepanyan * Ivo Gabe de Wolff * James Whitney * Jason Freeman +* Jason Killian * Jason Ramsay * Jed Mao +* Jeffrey Morlan * Johannes Rieken * John Vilk * Jonathan Bond-Caron * Jonathan Park * Jonathan Turner +* Jonathon Smith * Josh Kalderimis * Julian Williams * Kagami Sascha Rosylight @@ -46,21 +57,27 @@ TypeScript is authored by: * Ken Howard * Kenji Imamula * Lorant Pinter +* Lucien Greathouse * Martin Všetička * Masahiro Wakame +* Mattias Buelens * Max Deepfield * Micah Zoltu * Mohamed Hegazy * Nathan Shively-Sanders +* Nathan Yee * Oleg Mihailik * Oleksandr Chekhovskyi * Paul van Brenk +* @pcbro * Pedro Maltez * Philip Bulley * piloopin * @progre * Punya Biswal +* Richard Sentino * Ron Buckton +* Rowan Wyborn * Ryan Cavanaugh * Ryohei Ikegami * Sébastien Arod @@ -71,7 +88,9 @@ TypeScript is authored by: * Solal Pirelli * Stan Thomas * Steve Lucco +* Thomas Loubiou * Tien Hoanhtien +* Tim Perry * Tingan Ho * togru * Tomas Grubliauskas @@ -81,5 +100,6 @@ TypeScript is authored by: * Wesley Wigham * York Yao * Yui Tanglertsampan +* Yuichi Nukiyama * Zev Spitz * Zhengbo Li From 301901709336b23ee3a4762855cd516a7229b6d6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 28 Jan 2016 10:39:54 -0800 Subject: [PATCH 07/14] Emit readonly in declaration files --- src/compiler/declarationEmitter.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 9a57b4b1a3..7a8db9f90e 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -648,6 +648,9 @@ namespace ts { if (node.flags & NodeFlags.Static) { write("static "); } + if (node.flags & NodeFlags.Readonly) { + write("readonly "); + } if (node.flags & NodeFlags.Abstract) { write("abstract "); } @@ -1342,15 +1345,17 @@ namespace ts { const prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; - // Construct signature or constructor type write new Signature - if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) { - write("new "); - } - emitTypeParameters(node.typeParameters); if (node.kind === SyntaxKind.IndexSignature) { + // Index signature can have readonly modifier + emitClassMemberDeclarationFlags(node); write("["); } else { + // Construct signature or constructor type write new Signature + if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) { + write("new "); + } + emitTypeParameters(node.typeParameters); write("("); } From 371811ab5b795ce0abb2a0c81e96098c09768652 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 28 Jan 2016 10:40:08 -0800 Subject: [PATCH 08/14] Adding test --- .../reference/readonlyInDeclarationFile.js | 83 +++++++++++++++++++ .../readonlyInDeclarationFile.symbols | 76 +++++++++++++++++ .../reference/readonlyInDeclarationFile.types | 83 +++++++++++++++++++ .../compiler/readonlyInDeclarationFile.ts | 36 ++++++++ 4 files changed, 278 insertions(+) create mode 100644 tests/baselines/reference/readonlyInDeclarationFile.js create mode 100644 tests/baselines/reference/readonlyInDeclarationFile.symbols create mode 100644 tests/baselines/reference/readonlyInDeclarationFile.types create mode 100644 tests/cases/compiler/readonlyInDeclarationFile.ts diff --git a/tests/baselines/reference/readonlyInDeclarationFile.js b/tests/baselines/reference/readonlyInDeclarationFile.js new file mode 100644 index 0000000000..d2a20280e0 --- /dev/null +++ b/tests/baselines/reference/readonlyInDeclarationFile.js @@ -0,0 +1,83 @@ +//// [readonlyInDeclarationFile.ts] + +interface Foo { + readonly x: number; + readonly [x: string]: Object; +} + +class C { + protected readonly y: number; + readonly [x: string]: Object; + private static readonly a = "foo"; + protected static readonly b = "foo"; + public static readonly c = "foo"; +} + +var z: { + readonly a: string; + readonly [x: string]: Object; +} + +function f() { + return { + get x() { return 1; }, + get y() { return 1; }, + set y(value) { } + } +} + +function g() { + var x: { + readonly a: string; + readonly [x: string]: Object; + } + return x; +} + +//// [readonlyInDeclarationFile.js] +var C = (function () { + function C() { + } + C.a = "foo"; + C.b = "foo"; + C.c = "foo"; + return C; +}()); +var z; +function f() { + return { + get x() { return 1; }, + get y() { return 1; }, + set y(value) { } + }; +} +function g() { + var x; + return x; +} + + +//// [readonlyInDeclarationFile.d.ts] +interface Foo { + readonly x: number; + readonly [x: string]: Object; +} +declare class C { + protected readonly y: number; + readonly [x: string]: Object; + private static readonly a; + protected static readonly b: string; + static readonly c: string; +} +declare var z: { + readonly a: string; + readonly [x: string]: Object; +}; +declare function f(): { + readonly x: number; + y: number; +}; +declare function g(): { + readonly [x: string]: Object; + readonly a: string; +}; diff --git a/tests/baselines/reference/readonlyInDeclarationFile.symbols b/tests/baselines/reference/readonlyInDeclarationFile.symbols new file mode 100644 index 0000000000..f7bbf19a0a --- /dev/null +++ b/tests/baselines/reference/readonlyInDeclarationFile.symbols @@ -0,0 +1,76 @@ +=== tests/cases/compiler/readonlyInDeclarationFile.ts === + +interface Foo { +>Foo : Symbol(Foo, Decl(readonlyInDeclarationFile.ts, 0, 0)) + + readonly x: number; +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 1, 15)) + + readonly [x: string]: Object; +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 3, 14)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +class C { +>C : Symbol(C, Decl(readonlyInDeclarationFile.ts, 4, 1)) + + protected readonly y: number; +>y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 6, 9)) + + readonly [x: string]: Object; +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 8, 14)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + private static readonly a = "foo"; +>a : Symbol(C.a, Decl(readonlyInDeclarationFile.ts, 8, 33)) + + protected static readonly b = "foo"; +>b : Symbol(C.b, Decl(readonlyInDeclarationFile.ts, 9, 38)) + + public static readonly c = "foo"; +>c : Symbol(C.c, Decl(readonlyInDeclarationFile.ts, 10, 40)) +} + +var z: { +>z : Symbol(z, Decl(readonlyInDeclarationFile.ts, 14, 3)) + + readonly a: string; +>a : Symbol(a, Decl(readonlyInDeclarationFile.ts, 14, 8)) + + readonly [x: string]: Object; +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 16, 14)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +function f() { +>f : Symbol(f, Decl(readonlyInDeclarationFile.ts, 17, 1)) + + return { + get x() { return 1; }, +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 20, 12)) + + get y() { return 1; }, +>y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 21, 30), Decl(readonlyInDeclarationFile.ts, 22, 30)) + + set y(value) { } +>y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 21, 30), Decl(readonlyInDeclarationFile.ts, 22, 30)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 23, 14)) + } +} + +function g() { +>g : Symbol(g, Decl(readonlyInDeclarationFile.ts, 25, 1)) + + var x: { +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 28, 7)) + + readonly a: string; +>a : Symbol(a, Decl(readonlyInDeclarationFile.ts, 28, 12)) + + readonly [x: string]: Object; +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 30, 18)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + } + return x; +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 28, 7)) +} diff --git a/tests/baselines/reference/readonlyInDeclarationFile.types b/tests/baselines/reference/readonlyInDeclarationFile.types new file mode 100644 index 0000000000..9b2f9d51d9 --- /dev/null +++ b/tests/baselines/reference/readonlyInDeclarationFile.types @@ -0,0 +1,83 @@ +=== tests/cases/compiler/readonlyInDeclarationFile.ts === + +interface Foo { +>Foo : Foo + + readonly x: number; +>x : number + + readonly [x: string]: Object; +>x : string +>Object : Object +} + +class C { +>C : C + + protected readonly y: number; +>y : number + + readonly [x: string]: Object; +>x : string +>Object : Object + + private static readonly a = "foo"; +>a : string +>"foo" : string + + protected static readonly b = "foo"; +>b : string +>"foo" : string + + public static readonly c = "foo"; +>c : string +>"foo" : string +} + +var z: { +>z : { readonly [x: string]: Object; readonly a: string; } + + readonly a: string; +>a : string + + readonly [x: string]: Object; +>x : string +>Object : Object +} + +function f() { +>f : () => { readonly x: number; y: number; } + + return { +>{ get x() { return 1; }, get y() { return 1; }, set y(value) { } } : { readonly x: number; y: number; } + + get x() { return 1; }, +>x : number +>1 : number + + get y() { return 1; }, +>y : number +>1 : number + + set y(value) { } +>y : number +>value : number + } +} + +function g() { +>g : () => { readonly [x: string]: Object; readonly a: string; } + + var x: { +>x : { readonly [x: string]: Object; readonly a: string; } + + readonly a: string; +>a : string + + readonly [x: string]: Object; +>x : string +>Object : Object + } + return x; +>x : { readonly [x: string]: Object; readonly a: string; } +} diff --git a/tests/cases/compiler/readonlyInDeclarationFile.ts b/tests/cases/compiler/readonlyInDeclarationFile.ts new file mode 100644 index 0000000000..99241b8c0c --- /dev/null +++ b/tests/cases/compiler/readonlyInDeclarationFile.ts @@ -0,0 +1,36 @@ +// @target: es5 +// @declaration: true + +interface Foo { + readonly x: number; + readonly [x: string]: Object; +} + +class C { + protected readonly y: number; + readonly [x: string]: Object; + private static readonly a = "foo"; + protected static readonly b = "foo"; + public static readonly c = "foo"; +} + +var z: { + readonly a: string; + readonly [x: string]: Object; +} + +function f() { + return { + get x() { return 1; }, + get y() { return 1; }, + set y(value) { } + } +} + +function g() { + var x: { + readonly a: string; + readonly [x: string]: Object; + } + return x; +} \ No newline at end of file From 364b08854bc1face5c9b38301bb83c7346f1ccce Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 28 Jan 2016 11:02:49 -0800 Subject: [PATCH 09/14] Recognize the RHS of assignments as the JSDoc target expression Fixes #6552 --- src/compiler/parser.ts | 6 +++--- src/compiler/utilities.ts | 14 ++++++++++++- .../fourslash/getJavaScriptCompletions18.ts | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/getJavaScriptCompletions18.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 57bd9860d1..7806df795d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4051,7 +4051,7 @@ namespace ts { setDecoratorContext(/*val*/ true); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseOptionalIdentifier() { @@ -4335,13 +4335,13 @@ namespace ts { const labeledStatement = createNode(SyntaxKind.LabeledStatement, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); + return addJSDocComment(finishNode(labeledStatement)); } else { const expressionStatement = createNode(SyntaxKind.ExpressionStatement, fullStart); expressionStatement.expression = expression; parseSemicolon(); - return finishNode(expressionStatement); + return addJSDocComment(finishNode(expressionStatement)); } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4bf1422e88..0856cb5547 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1186,7 +1186,19 @@ namespace ts { node.parent.parent.parent.kind === SyntaxKind.VariableStatement; const variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; - return variableStatementNode && variableStatementNode.jsDocComment; + if (variableStatementNode) { + return variableStatementNode.jsDocComment; + } + + // Also recognize when the node is the RHS of an assignment expression + const isSourceOfAssignmentExpressionStatement = + node.parent && node.parent.parent && + node.parent.kind === SyntaxKind.BinaryExpression && + (node.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken && + node.parent.parent.kind === SyntaxKind.ExpressionStatement; + if (isSourceOfAssignmentExpressionStatement) { + return node.parent.parent.jsDocComment; + } } return undefined; diff --git a/tests/cases/fourslash/getJavaScriptCompletions18.ts b/tests/cases/fourslash/getJavaScriptCompletions18.ts new file mode 100644 index 0000000000..a30d4943f4 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions18.ts @@ -0,0 +1,21 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// /** +//// * @param {number} a +//// * @param {string} b +//// */ +//// exports.foo = function(a, b) { +//// a/*a*/; +//// b/*b*/ +//// }; + +goTo.marker('a'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method'); + + +goTo.marker('b'); +edit.insert('.'); +verify.completionListContains('substr', undefined, undefined, 'method'); From bf897c29393e7e7ee92a71e123e502ca3d0ba12f Mon Sep 17 00:00:00 2001 From: zhengbli Date: Thu, 28 Jan 2016 11:26:32 -0800 Subject: [PATCH 10/14] Add more tests and comments --- src/compiler/checker.ts | 2 ++ tests/cases/fourslash/renameCrossJsTs01.ts | 12 ++++++++++++ tests/cases/fourslash/renameCrossJsTs02.ts | 12 ++++++++++++ .../{renameJsExports.ts => renameJsExports01.ts} | 2 +- tests/cases/fourslash/renameJsExports02.ts | 12 ++++++++++++ ...ypeProperty.ts => renameJsPrototypeProperty01.ts} | 2 +- tests/cases/fourslash/renameJsPrototypeProperty02.ts | 12 ++++++++++++ ...meJsThisProperty.ts => renameJsThisProperty01.ts} | 2 +- tests/cases/fourslash/renameJsThisProperty02.ts | 12 ++++++++++++ 9 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/renameCrossJsTs01.ts create mode 100644 tests/cases/fourslash/renameCrossJsTs02.ts rename tests/cases/fourslash/{renameJsExports.ts => renameJsExports01.ts} (72%) create mode 100644 tests/cases/fourslash/renameJsExports02.ts rename tests/cases/fourslash/{renameJsPrototypeProperty.ts => renameJsPrototypeProperty01.ts} (69%) create mode 100644 tests/cases/fourslash/renameJsPrototypeProperty02.ts rename tests/cases/fourslash/{renameJsThisProperty.ts => renameJsThisProperty01.ts} (68%) create mode 100644 tests/cases/fourslash/renameJsThisProperty02.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b3792a9798..758c5bbb4a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15367,6 +15367,8 @@ namespace ts { case SpecialPropertyAssignmentKind.ThisProperty: case SpecialPropertyAssignmentKind.ModuleExports: return getSymbolOfNode(entityName.parent.parent); + default: + // Fall through if it is not a special property assignment } } diff --git a/tests/cases/fourslash/renameCrossJsTs01.ts b/tests/cases/fourslash/renameCrossJsTs01.ts new file mode 100644 index 0000000000..52cb4c587d --- /dev/null +++ b/tests/cases/fourslash/renameCrossJsTs01.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports.[|area|] = function (r) { return r * r; } + +// @Filename: b.ts +////import { [|area|] } from './a'; +////var t = /**/[|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameCrossJsTs02.ts b/tests/cases/fourslash/renameCrossJsTs02.ts new file mode 100644 index 0000000000..7ff1ae96ff --- /dev/null +++ b/tests/cases/fourslash/renameCrossJsTs02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports./**/[|area|] = function (r) { return r * r; } + +// @Filename: b.ts +////import { [|area|] } from './a'; +////var t = [|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsExports.ts b/tests/cases/fourslash/renameJsExports01.ts similarity index 72% rename from tests/cases/fourslash/renameJsExports.ts rename to tests/cases/fourslash/renameJsExports01.ts index 227eebe4a0..923d30eedf 100644 --- a/tests/cases/fourslash/renameJsExports.ts +++ b/tests/cases/fourslash/renameJsExports01.ts @@ -9,4 +9,4 @@ ////var t = mod./**/[|area|](10); goTo.marker(); -verify.renameLocations(false, false); \ No newline at end of file +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsExports02.ts b/tests/cases/fourslash/renameJsExports02.ts new file mode 100644 index 0000000000..86b0471dc1 --- /dev/null +++ b/tests/cases/fourslash/renameJsExports02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports./**/[|area|] = function (r) { return r * r; } + +// @Filename: b.js +////var mod = require('./a'); +////var t = mod.[|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty.ts b/tests/cases/fourslash/renameJsPrototypeProperty01.ts similarity index 69% rename from tests/cases/fourslash/renameJsPrototypeProperty.ts rename to tests/cases/fourslash/renameJsPrototypeProperty01.ts index 651514859c..f756f57edb 100644 --- a/tests/cases/fourslash/renameJsPrototypeProperty.ts +++ b/tests/cases/fourslash/renameJsPrototypeProperty01.ts @@ -9,4 +9,4 @@ ////t./**/[|x|] = 11; goTo.marker(); -verify.renameLocations(false, false); \ No newline at end of file +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty02.ts b/tests/cases/fourslash/renameJsPrototypeProperty02.ts new file mode 100644 index 0000000000..721dc312eb --- /dev/null +++ b/tests/cases/fourslash/renameJsPrototypeProperty02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +////} +////bar.prototype./**/[|x|] = 10; +////var t = new bar(); +////t.[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty.ts b/tests/cases/fourslash/renameJsThisProperty01.ts similarity index 68% rename from tests/cases/fourslash/renameJsThisProperty.ts rename to tests/cases/fourslash/renameJsThisProperty01.ts index aed59d298b..91338e0431 100644 --- a/tests/cases/fourslash/renameJsThisProperty.ts +++ b/tests/cases/fourslash/renameJsThisProperty01.ts @@ -9,4 +9,4 @@ ////t./**/[|x|] = 11; goTo.marker(); -verify.renameLocations(false, false); \ No newline at end of file +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty02.ts b/tests/cases/fourslash/renameJsThisProperty02.ts new file mode 100644 index 0000000000..8398507c9c --- /dev/null +++ b/tests/cases/fourslash/renameJsThisProperty02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +//// this./**/[|x|] = 10; +////} +////var t = new bar(); +////t.[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file From da6e82f639a7cc96887fde34391a9c8c654fa301 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 28 Jan 2016 11:39:19 -0800 Subject: [PATCH 11/14] Use union types in the return type of functions in the error case Fixes #6663 --- src/compiler/checker.ts | 3 ++- .../fourslash/getJavaScriptCompletions19.ts | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/getJavaScriptCompletions19.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 61c05d7688..55587ca683 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10390,7 +10390,8 @@ namespace ts { } else { error(func, Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; + // Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience + return getUnionType(types); } } diff --git a/tests/cases/fourslash/getJavaScriptCompletions19.ts b/tests/cases/fourslash/getJavaScriptCompletions19.ts new file mode 100644 index 0000000000..5a361930e8 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions19.ts @@ -0,0 +1,25 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// function fn() { +//// if (foo) { +//// return 0; +//// } else { +//// return '0'; +//// } +//// } +//// let x = fn(); +//// if(typeof x === 'string') { +//// x/*str*/ +//// } else { +//// x/*num*/ +//// } + +goTo.marker('str'); +edit.insert('.'); +verify.completionListContains('substr', undefined, undefined, 'method'); + +goTo.marker('num'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method'); From a88ff9c2ad9a2476ede5148b67b20d70684e3af8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 28 Jan 2016 13:28:49 -0800 Subject: [PATCH 12/14] Emit readonly in declaration file for get-only accessors in classes --- src/compiler/declarationEmitter.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 7a8db9f90e..ab0b16947f 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -637,21 +637,21 @@ namespace ts { } } - function emitClassMemberDeclarationFlags(node: Declaration) { - if (node.flags & NodeFlags.Private) { + function emitClassMemberDeclarationFlags(flags: NodeFlags) { + if (flags & NodeFlags.Private) { write("private "); } - else if (node.flags & NodeFlags.Protected) { + else if (flags & NodeFlags.Protected) { write("protected "); } - if (node.flags & NodeFlags.Static) { + if (flags & NodeFlags.Static) { write("static "); } - if (node.flags & NodeFlags.Readonly) { + if (flags & NodeFlags.Readonly) { write("readonly "); } - if (node.flags & NodeFlags.Abstract) { + if (flags & NodeFlags.Abstract) { write("abstract "); } } @@ -1077,7 +1077,7 @@ namespace ts { } emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags); emitVariableDeclaration(node); write(";"); writeLine(); @@ -1230,7 +1230,7 @@ namespace ts { if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags | (accessors.setAccessor ? 0 : NodeFlags.Readonly)); writeTextOfNode(currentText, node.name); if (!(node.flags & NodeFlags.Private)) { accessorWithTypeAnnotation = node; @@ -1317,7 +1317,7 @@ namespace ts { emitModuleElementDeclarationFlags(node); } else if (node.kind === SyntaxKind.MethodDeclaration) { - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags); } if (node.kind === SyntaxKind.FunctionDeclaration) { write("function "); @@ -1347,7 +1347,7 @@ namespace ts { if (node.kind === SyntaxKind.IndexSignature) { // Index signature can have readonly modifier - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags); write("["); } else { From 898797fceef1b9a5653c01091ee3647faad53977 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 28 Jan 2016 13:29:20 -0800 Subject: [PATCH 13/14] Adding more test cases --- .../compiler/readonlyInDeclarationFile.ts | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/cases/compiler/readonlyInDeclarationFile.ts b/tests/cases/compiler/readonlyInDeclarationFile.ts index 99241b8c0c..03e643782f 100644 --- a/tests/cases/compiler/readonlyInDeclarationFile.ts +++ b/tests/cases/compiler/readonlyInDeclarationFile.ts @@ -7,11 +7,31 @@ interface Foo { } class C { - protected readonly y: number; readonly [x: string]: Object; - private static readonly a = "foo"; - protected static readonly b = "foo"; - public static readonly c = "foo"; + private readonly a1: number; + protected readonly a2: number; + public readonly a3: number; + private get b1() { return 1 } + protected get b2() { return 1 } + public get b3() { return 1 } + private get c1() { return 1 } + private set c1(value) { } + protected get c2() { return 1 } + protected set c2(value) { } + public get c3() { return 1 } + public set c3(value) { } + private static readonly s1: number; + protected static readonly s2: number; + public static readonly s3: number; + private static get t1() { return 1 } + protected static get t2() { return 1 } + public static get t3() { return 1 } + private static get u1() { return 1 } + private static set u1(value) { } + protected static get u2() { return 1 } + protected static set u2(value) { } + public static get u3() { return 1 } + public static set u3(value) { } } var z: { From c00d239c00e3785f5cd1ac3f75b26242ff3e60ba Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 28 Jan 2016 13:29:58 -0800 Subject: [PATCH 14/14] Accepting new baselines --- tests/baselines/reference/classdecl.js | 4 +- .../reference/commentsClassMembers.js | 4 +- .../reference/commentsInheritance.js | 12 +- .../baselines/reference/declFileAccessors.js | 4 +- .../reference/declFilePrivateStatic.js | 4 +- .../declarationEmit_protectedMembers.js | 4 +- tests/baselines/reference/giant.js | 24 ++-- .../isDeclarationVisibleNodeKinds.js | 2 +- tests/baselines/reference/moduledecl.js | 4 +- .../reference/readonlyInDeclarationFile.js | 119 ++++++++++++++++-- .../readonlyInDeclarationFile.symbols | 112 +++++++++++++---- .../reference/readonlyInDeclarationFile.types | 99 +++++++++++++-- .../reference/symbolDeclarationEmit13.js | 2 +- .../reference/symbolDeclarationEmit14.js | 4 +- .../reference/typeGuardOfFormThisMember.js | 2 +- .../typeGuardOfFormThisMemberErrors.js | 2 +- 16 files changed, 320 insertions(+), 82 deletions(-) diff --git a/tests/baselines/reference/classdecl.js b/tests/baselines/reference/classdecl.js index 710c5166d3..a8a440fa17 100644 --- a/tests/baselines/reference/classdecl.js +++ b/tests/baselines/reference/classdecl.js @@ -211,12 +211,12 @@ declare class a { pgF(): void; pv: any; d: number; - static p2: { + static readonly p2: { x: number; y: number; }; private static d2(); - private static p3; + private static readonly p3; private pv3; private foo(n); private foo(s); diff --git a/tests/baselines/reference/commentsClassMembers.js b/tests/baselines/reference/commentsClassMembers.js index fe2dc0a63d..dacbde7a27 100644 --- a/tests/baselines/reference/commentsClassMembers.js +++ b/tests/baselines/reference/commentsClassMembers.js @@ -568,8 +568,8 @@ declare var i1_c: typeof c1; declare class cProperties { private val; /** getter only property*/ - p1: number; - nc_p1: number; + readonly p1: number; + readonly nc_p1: number; /**setter only property*/ p2: number; nc_p2: number; diff --git a/tests/baselines/reference/commentsInheritance.js b/tests/baselines/reference/commentsInheritance.js index b9d84b2475..42df3cca38 100644 --- a/tests/baselines/reference/commentsInheritance.js +++ b/tests/baselines/reference/commentsInheritance.js @@ -316,19 +316,19 @@ declare class c2 { /** c2 c2_f1*/ c2_f1(): void; /** c2 c2_prop*/ - c2_prop: number; + readonly c2_prop: number; c2_nc_p1: number; c2_nc_f1(): void; - c2_nc_prop: number; + readonly c2_nc_prop: number; /** c2 p1*/ p1: number; /** c2 f1*/ f1(): void; /** c2 prop*/ - prop: number; + readonly prop: number; nc_p1: number; nc_f1(): void; - nc_prop: number; + readonly nc_prop: number; /** c2 constructor*/ constructor(a: number); } @@ -339,10 +339,10 @@ declare class c3 extends c2 { /** c3 f1*/ f1(): void; /** c3 prop*/ - prop: number; + readonly prop: number; nc_p1: number; nc_f1(): void; - nc_prop: number; + readonly nc_prop: number; } declare var c2_i: c2; declare var c3_i: c3; diff --git a/tests/baselines/reference/declFileAccessors.js b/tests/baselines/reference/declFileAccessors.js index e3616c79e3..2bd51bfbfb 100644 --- a/tests/baselines/reference/declFileAccessors.js +++ b/tests/baselines/reference/declFileAccessors.js @@ -284,7 +284,7 @@ export declare class c1 { nc_p3: number; private nc_pp3; static nc_s3: string; - onlyGetter: number; + readonly onlyGetter: number; onlySetter: number; } //// [declFileAccessors_1.d.ts] @@ -302,6 +302,6 @@ declare class c2 { nc_p3: number; private nc_pp3; static nc_s3: string; - onlyGetter: number; + readonly onlyGetter: number; onlySetter: number; } diff --git a/tests/baselines/reference/declFilePrivateStatic.js b/tests/baselines/reference/declFilePrivateStatic.js index dd81d94b3c..30cd85444c 100644 --- a/tests/baselines/reference/declFilePrivateStatic.js +++ b/tests/baselines/reference/declFilePrivateStatic.js @@ -52,8 +52,8 @@ declare class C { static y: number; private static a(); static b(): void; - private static c; - static d: number; + private static readonly c; + static readonly d: number; private static e; static f: any; } diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.js b/tests/baselines/reference/declarationEmit_protectedMembers.js index 5aad004939..192f0647ed 100644 --- a/tests/baselines/reference/declarationEmit_protectedMembers.js +++ b/tests/baselines/reference/declarationEmit_protectedMembers.js @@ -135,7 +135,7 @@ declare class C1 { protected static sx: number; protected static sf(): number; protected static staticSetter: number; - protected static staticGetter: number; + protected static readonly staticGetter: number; } declare class C2 extends C1 { protected f(): number; @@ -146,7 +146,7 @@ declare class C3 extends C2 { static sx: number; f(): number; static sf(): number; - static staticGetter: number; + static readonly staticGetter: number; } declare class C4 { protected a: number; diff --git a/tests/baselines/reference/giant.js b/tests/baselines/reference/giant.js index 2a04541ef2..149a975d41 100644 --- a/tests/baselines/reference/giant.js +++ b/tests/baselines/reference/giant.js @@ -1120,11 +1120,11 @@ export declare class eC { pF(): void; private rF(); pgF(): void; - pgF: any; + readonly pgF: any; psF(param: any): void; psF: any; private rgF(); - private rgF; + private readonly rgF; private rsF(param); private rsF; static tV: any; @@ -1132,7 +1132,7 @@ export declare class eC { static tsF(param: any): void; static tsF: any; static tgF(): void; - static tgF: any; + static readonly tgF: any; } export interface eI { (): any; @@ -1172,11 +1172,11 @@ export declare module eM { pF(): void; private rF(); pgF(): void; - pgF: any; + readonly pgF: any; psF(param: any): void; psF: any; private rgF(); - private rgF; + private readonly rgF; private rsF(param); private rsF; static tV: any; @@ -1184,7 +1184,7 @@ export declare module eM { static tsF(param: any): void; static tsF: any; static tgF(): void; - static tgF: any; + static readonly tgF: any; } interface eI { (): any; @@ -1239,11 +1239,11 @@ export declare module eM { pF(): void; private rF(); pgF(): void; - pgF: any; + readonly pgF: any; psF(param: any): void; psF: any; private rgF(); - private rgF; + private readonly rgF; private rsF(param); private rsF; static tV: any; @@ -1251,7 +1251,7 @@ export declare module eM { static tsF(param: any): void; static tsF: any; static tgF(): void; - static tgF: any; + static readonly tgF: any; } module eaM { var V: any; @@ -1281,11 +1281,11 @@ export declare class eaC { pF(): void; private rF(); pgF(): void; - pgF: any; + readonly pgF: any; psF(param: any): void; psF: any; private rgF(); - private rgF; + private readonly rgF; private rsF(param); private rsF; static tV: any; @@ -1293,7 +1293,7 @@ export declare class eaC { static tsF(param: any): void; static tsF: any; static tgF(): void; - static tgF: any; + static readonly tgF: any; } export declare module eaM { var V: any; diff --git a/tests/baselines/reference/isDeclarationVisibleNodeKinds.js b/tests/baselines/reference/isDeclarationVisibleNodeKinds.js index 99e1ac72ac..e24032eb85 100644 --- a/tests/baselines/reference/isDeclarationVisibleNodeKinds.js +++ b/tests/baselines/reference/isDeclarationVisibleNodeKinds.js @@ -193,7 +193,7 @@ declare module schema { } declare module schema { class T { - createValidator9: (data: T) => T; + readonly createValidator9: (data: T) => T; createValidator10: (data: T) => T; } } diff --git a/tests/baselines/reference/moduledecl.js b/tests/baselines/reference/moduledecl.js index 2e765e512d..f4efbadbf3 100644 --- a/tests/baselines/reference/moduledecl.js +++ b/tests/baselines/reference/moduledecl.js @@ -459,10 +459,10 @@ declare module exportTests { class C3_public { private getC2_private(); private setC2_private(arg); - private c2; + private readonly c2; getC1_public(): C1_public; setC1_public(arg: C1_public): void; - c1: C1_public; + readonly c1: C1_public; } } declare module mAmbient { diff --git a/tests/baselines/reference/readonlyInDeclarationFile.js b/tests/baselines/reference/readonlyInDeclarationFile.js index d2a20280e0..71e48272ec 100644 --- a/tests/baselines/reference/readonlyInDeclarationFile.js +++ b/tests/baselines/reference/readonlyInDeclarationFile.js @@ -6,11 +6,31 @@ interface Foo { } class C { - protected readonly y: number; readonly [x: string]: Object; - private static readonly a = "foo"; - protected static readonly b = "foo"; - public static readonly c = "foo"; + private readonly a1: number; + protected readonly a2: number; + public readonly a3: number; + private get b1() { return 1 } + protected get b2() { return 1 } + public get b3() { return 1 } + private get c1() { return 1 } + private set c1(value) { } + protected get c2() { return 1 } + protected set c2(value) { } + public get c3() { return 1 } + public set c3(value) { } + private static readonly s1: number; + protected static readonly s2: number; + public static readonly s3: number; + private static get t1() { return 1 } + protected static get t2() { return 1 } + public static get t3() { return 1 } + private static get u1() { return 1 } + private static set u1(value) { } + protected static get u2() { return 1 } + protected static set u2(value) { } + public static get u3() { return 1 } + public static set u3(value) { } } var z: { @@ -38,9 +58,72 @@ function g() { var C = (function () { function C() { } - C.a = "foo"; - C.b = "foo"; - C.c = "foo"; + Object.defineProperty(C.prototype, "b1", { + get: function () { return 1; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "b2", { + get: function () { return 1; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "b3", { + get: function () { return 1; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "c1", { + get: function () { return 1; }, + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "c2", { + get: function () { return 1; }, + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "c3", { + get: function () { return 1; }, + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "t1", { + get: function () { return 1; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "t2", { + get: function () { return 1; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "t3", { + get: function () { return 1; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "u1", { + get: function () { return 1; }, + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "u2", { + get: function () { return 1; }, + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "u3", { + get: function () { return 1; }, + set: function (value) { }, + enumerable: true, + configurable: true + }); return C; }()); var z; @@ -63,11 +146,25 @@ interface Foo { readonly [x: string]: Object; } declare class C { - protected readonly y: number; readonly [x: string]: Object; - private static readonly a; - protected static readonly b: string; - static readonly c: string; + private readonly a1; + protected readonly a2: number; + readonly a3: number; + private readonly b1; + protected readonly b2: number; + readonly b3: number; + private c1; + protected c2: number; + c3: number; + private static readonly s1; + protected static readonly s2: number; + static readonly s3: number; + private static readonly t1; + protected static readonly t2: number; + static readonly t3: number; + private static u1; + protected static u2: number; + static u3: number; } declare var z: { readonly a: string; diff --git a/tests/baselines/reference/readonlyInDeclarationFile.symbols b/tests/baselines/reference/readonlyInDeclarationFile.symbols index f7bbf19a0a..af979e4dac 100644 --- a/tests/baselines/reference/readonlyInDeclarationFile.symbols +++ b/tests/baselines/reference/readonlyInDeclarationFile.symbols @@ -14,63 +14,129 @@ interface Foo { class C { >C : Symbol(C, Decl(readonlyInDeclarationFile.ts, 4, 1)) - protected readonly y: number; ->y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 6, 9)) - readonly [x: string]: Object; ->x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 8, 14)) +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 7, 14)) >Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) - private static readonly a = "foo"; ->a : Symbol(C.a, Decl(readonlyInDeclarationFile.ts, 8, 33)) + private readonly a1: number; +>a1 : Symbol(a1, Decl(readonlyInDeclarationFile.ts, 7, 33)) - protected static readonly b = "foo"; ->b : Symbol(C.b, Decl(readonlyInDeclarationFile.ts, 9, 38)) + protected readonly a2: number; +>a2 : Symbol(a2, Decl(readonlyInDeclarationFile.ts, 8, 32)) - public static readonly c = "foo"; ->c : Symbol(C.c, Decl(readonlyInDeclarationFile.ts, 10, 40)) + public readonly a3: number; +>a3 : Symbol(a3, Decl(readonlyInDeclarationFile.ts, 9, 34)) + + private get b1() { return 1 } +>b1 : Symbol(b1, Decl(readonlyInDeclarationFile.ts, 10, 31)) + + protected get b2() { return 1 } +>b2 : Symbol(b2, Decl(readonlyInDeclarationFile.ts, 11, 33)) + + public get b3() { return 1 } +>b3 : Symbol(b3, Decl(readonlyInDeclarationFile.ts, 12, 35)) + + private get c1() { return 1 } +>c1 : Symbol(c1, Decl(readonlyInDeclarationFile.ts, 13, 32), Decl(readonlyInDeclarationFile.ts, 14, 33)) + + private set c1(value) { } +>c1 : Symbol(c1, Decl(readonlyInDeclarationFile.ts, 13, 32), Decl(readonlyInDeclarationFile.ts, 14, 33)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 15, 19)) + + protected get c2() { return 1 } +>c2 : Symbol(c2, Decl(readonlyInDeclarationFile.ts, 15, 29), Decl(readonlyInDeclarationFile.ts, 16, 35)) + + protected set c2(value) { } +>c2 : Symbol(c2, Decl(readonlyInDeclarationFile.ts, 15, 29), Decl(readonlyInDeclarationFile.ts, 16, 35)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 17, 21)) + + public get c3() { return 1 } +>c3 : Symbol(c3, Decl(readonlyInDeclarationFile.ts, 17, 31), Decl(readonlyInDeclarationFile.ts, 18, 32)) + + public set c3(value) { } +>c3 : Symbol(c3, Decl(readonlyInDeclarationFile.ts, 17, 31), Decl(readonlyInDeclarationFile.ts, 18, 32)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 19, 18)) + + private static readonly s1: number; +>s1 : Symbol(C.s1, Decl(readonlyInDeclarationFile.ts, 19, 28)) + + protected static readonly s2: number; +>s2 : Symbol(C.s2, Decl(readonlyInDeclarationFile.ts, 20, 39)) + + public static readonly s3: number; +>s3 : Symbol(C.s3, Decl(readonlyInDeclarationFile.ts, 21, 41)) + + private static get t1() { return 1 } +>t1 : Symbol(C.t1, Decl(readonlyInDeclarationFile.ts, 22, 38)) + + protected static get t2() { return 1 } +>t2 : Symbol(C.t2, Decl(readonlyInDeclarationFile.ts, 23, 40)) + + public static get t3() { return 1 } +>t3 : Symbol(C.t3, Decl(readonlyInDeclarationFile.ts, 24, 42)) + + private static get u1() { return 1 } +>u1 : Symbol(C.u1, Decl(readonlyInDeclarationFile.ts, 25, 39), Decl(readonlyInDeclarationFile.ts, 26, 40)) + + private static set u1(value) { } +>u1 : Symbol(C.u1, Decl(readonlyInDeclarationFile.ts, 25, 39), Decl(readonlyInDeclarationFile.ts, 26, 40)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 27, 26)) + + protected static get u2() { return 1 } +>u2 : Symbol(C.u2, Decl(readonlyInDeclarationFile.ts, 27, 36), Decl(readonlyInDeclarationFile.ts, 28, 42)) + + protected static set u2(value) { } +>u2 : Symbol(C.u2, Decl(readonlyInDeclarationFile.ts, 27, 36), Decl(readonlyInDeclarationFile.ts, 28, 42)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 29, 28)) + + public static get u3() { return 1 } +>u3 : Symbol(C.u3, Decl(readonlyInDeclarationFile.ts, 29, 38), Decl(readonlyInDeclarationFile.ts, 30, 39)) + + public static set u3(value) { } +>u3 : Symbol(C.u3, Decl(readonlyInDeclarationFile.ts, 29, 38), Decl(readonlyInDeclarationFile.ts, 30, 39)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 31, 25)) } var z: { ->z : Symbol(z, Decl(readonlyInDeclarationFile.ts, 14, 3)) +>z : Symbol(z, Decl(readonlyInDeclarationFile.ts, 34, 3)) readonly a: string; ->a : Symbol(a, Decl(readonlyInDeclarationFile.ts, 14, 8)) +>a : Symbol(a, Decl(readonlyInDeclarationFile.ts, 34, 8)) readonly [x: string]: Object; ->x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 16, 14)) +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 36, 14)) >Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) } function f() { ->f : Symbol(f, Decl(readonlyInDeclarationFile.ts, 17, 1)) +>f : Symbol(f, Decl(readonlyInDeclarationFile.ts, 37, 1)) return { get x() { return 1; }, ->x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 20, 12)) +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 40, 12)) get y() { return 1; }, ->y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 21, 30), Decl(readonlyInDeclarationFile.ts, 22, 30)) +>y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 41, 30), Decl(readonlyInDeclarationFile.ts, 42, 30)) set y(value) { } ->y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 21, 30), Decl(readonlyInDeclarationFile.ts, 22, 30)) ->value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 23, 14)) +>y : Symbol(y, Decl(readonlyInDeclarationFile.ts, 41, 30), Decl(readonlyInDeclarationFile.ts, 42, 30)) +>value : Symbol(value, Decl(readonlyInDeclarationFile.ts, 43, 14)) } } function g() { ->g : Symbol(g, Decl(readonlyInDeclarationFile.ts, 25, 1)) +>g : Symbol(g, Decl(readonlyInDeclarationFile.ts, 45, 1)) var x: { ->x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 28, 7)) +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 48, 7)) readonly a: string; ->a : Symbol(a, Decl(readonlyInDeclarationFile.ts, 28, 12)) +>a : Symbol(a, Decl(readonlyInDeclarationFile.ts, 48, 12)) readonly [x: string]: Object; ->x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 30, 18)) +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 50, 18)) >Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) } return x; ->x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 28, 7)) +>x : Symbol(x, Decl(readonlyInDeclarationFile.ts, 48, 7)) } diff --git a/tests/baselines/reference/readonlyInDeclarationFile.types b/tests/baselines/reference/readonlyInDeclarationFile.types index 9b2f9d51d9..7a3e11577c 100644 --- a/tests/baselines/reference/readonlyInDeclarationFile.types +++ b/tests/baselines/reference/readonlyInDeclarationFile.types @@ -14,24 +14,99 @@ interface Foo { class C { >C : C - protected readonly y: number; ->y : number - readonly [x: string]: Object; >x : string >Object : Object - private static readonly a = "foo"; ->a : string ->"foo" : string + private readonly a1: number; +>a1 : number - protected static readonly b = "foo"; ->b : string ->"foo" : string + protected readonly a2: number; +>a2 : number - public static readonly c = "foo"; ->c : string ->"foo" : string + public readonly a3: number; +>a3 : number + + private get b1() { return 1 } +>b1 : number +>1 : number + + protected get b2() { return 1 } +>b2 : number +>1 : number + + public get b3() { return 1 } +>b3 : number +>1 : number + + private get c1() { return 1 } +>c1 : number +>1 : number + + private set c1(value) { } +>c1 : number +>value : number + + protected get c2() { return 1 } +>c2 : number +>1 : number + + protected set c2(value) { } +>c2 : number +>value : number + + public get c3() { return 1 } +>c3 : number +>1 : number + + public set c3(value) { } +>c3 : number +>value : number + + private static readonly s1: number; +>s1 : number + + protected static readonly s2: number; +>s2 : number + + public static readonly s3: number; +>s3 : number + + private static get t1() { return 1 } +>t1 : number +>1 : number + + protected static get t2() { return 1 } +>t2 : number +>1 : number + + public static get t3() { return 1 } +>t3 : number +>1 : number + + private static get u1() { return 1 } +>u1 : number +>1 : number + + private static set u1(value) { } +>u1 : number +>value : number + + protected static get u2() { return 1 } +>u2 : number +>1 : number + + protected static set u2(value) { } +>u2 : number +>value : number + + public static get u3() { return 1 } +>u3 : number +>1 : number + + public static set u3(value) { } +>u3 : number +>value : number } var z: { diff --git a/tests/baselines/reference/symbolDeclarationEmit13.js b/tests/baselines/reference/symbolDeclarationEmit13.js index 8111672866..bbd2c15cfc 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.js +++ b/tests/baselines/reference/symbolDeclarationEmit13.js @@ -13,6 +13,6 @@ class C { //// [symbolDeclarationEmit13.d.ts] declare class C { - [Symbol.toPrimitive]: string; + readonly [Symbol.toPrimitive]: string; [Symbol.toStringTag]: any; } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.js b/tests/baselines/reference/symbolDeclarationEmit14.js index b8a6b3e409..d4ae3eeb43 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.js +++ b/tests/baselines/reference/symbolDeclarationEmit14.js @@ -13,6 +13,6 @@ class C { //// [symbolDeclarationEmit14.d.ts] declare class C { - [Symbol.toPrimitive]: string; - [Symbol.toStringTag]: string; + readonly [Symbol.toPrimitive]: string; + readonly [Symbol.toStringTag]: string; } diff --git a/tests/baselines/reference/typeGuardOfFormThisMember.js b/tests/baselines/reference/typeGuardOfFormThisMember.js index 2f983d2cdf..9d71613ed8 100644 --- a/tests/baselines/reference/typeGuardOfFormThisMember.js +++ b/tests/baselines/reference/typeGuardOfFormThisMember.js @@ -170,7 +170,7 @@ declare namespace Test { path: string; isFSO: this is FileSystemObject; isFile: this is File; - isDirectory: this is Directory; + readonly isDirectory: this is Directory; isNetworked: this is (Networked & this); constructor(path: string); } diff --git a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js index 6f681ab09c..5991fdd316 100644 --- a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js +++ b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.js @@ -95,7 +95,7 @@ declare namespace Test { path: string; isFSO: this is FileSystemObject; isFile: this is File; - isDirectory: this is Directory; + readonly isDirectory: this is Directory; isNetworked: this is (Networked & this); constructor(path: string); }