From 578013b65cbc78930279388a810fbb0d12b67c73 Mon Sep 17 00:00:00 2001 From: rpgeeganage Date: Sun, 5 May 2019 18:59:45 +0200 Subject: [PATCH 1/4] modified the service file --- src/services/services.ts | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 42d2278bcba93..ab5138fb489ae 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1467,33 +1467,49 @@ namespace ts { } const typeChecker = program.getTypeChecker(); - const symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); + const nodeForQuickInfo = getNodeForQuickInfo(node, typeChecker); + const symbol = getSymbolAtLocationForQuickInfo(nodeForQuickInfo, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { - const type = shouldGetType(sourceFile, node, position) ? typeChecker.getTypeAtLocation(node) : undefined; + const type = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type && { kind: ScriptElementKind.unknown, kindModifiers: ScriptElementKindModifier.none, - textSpan: createTextSpanFromNode(node, sourceFile), - displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(node))), + textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile), + displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(nodeForQuickInfo))), documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : undefined, tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(cancellationToken, typeChecker => - SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, getContainerNode(node), node) + SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, getContainerNode(nodeForQuickInfo), nodeForQuickInfo) ); return { kind: symbolKind, kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), - textSpan: createTextSpanFromNode(node, sourceFile), + textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts, documentation, tags, }; } + function getNodeForQuickInfo(node: Node, typeChecker: TypeChecker): Node { + const firstParentNode = node.parent.getFirstToken(); + const firstNodeSyntaxKind = firstParentNode ? firstParentNode.kind : undefined; + + if (node.kind === SyntaxKind.NewKeyword || firstNodeSyntaxKind === SyntaxKind.NewKeyword) { + for (const singleNode of node.parent.getChildren()) { + const symbol = getSymbolAtLocationForQuickInfo(singleNode, typeChecker); + if (symbol) { + return singleNode; + } + } + } + return node; + } + function shouldGetType(sourceFile: SourceFile, node: Node, position: number): boolean { switch (node.kind) { case SyntaxKind.Identifier: From 9959ce449e6ef9dcb047572f7e670811f5447206 Mon Sep 17 00:00:00 2001 From: rpgeeganage Date: Sun, 5 May 2019 19:00:01 +0200 Subject: [PATCH 2/4] added test --- .../fourslash/quickInfoOnNewKeyword01.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/cases/fourslash/quickInfoOnNewKeyword01.ts diff --git a/tests/cases/fourslash/quickInfoOnNewKeyword01.ts b/tests/cases/fourslash/quickInfoOnNewKeyword01.ts new file mode 100644 index 0000000000000..21ccb8a65024d --- /dev/null +++ b/tests/cases/fourslash/quickInfoOnNewKeyword01.ts @@ -0,0 +1,21 @@ +/// + +////class Cat { +//// /** +//// * NOTE: this constructor is private! Please use the factory function +//// */ +//// private constructor() { } +//// +//// static makeCat() { new Cat(); } +////} +//// +////ne/*1*/w Ca/*2*/t(/*3*/); + +verify.quickInfoAt('1', 'constructor Cat(): Cat', +'NOTE: this constructor is private! Please use the factory function'); + +verify.quickInfoAt('2', 'constructor Cat(): Cat', +'NOTE: this constructor is private! Please use the factory function'); + +verify.quickInfoAt('3', 'constructor Cat(): Cat', +'NOTE: this constructor is private! Please use the factory function'); From ca749b107cbd4b467904c51d3b6dc78d30a43d6b Mon Sep 17 00:00:00 2001 From: rpgeeganage Date: Sun, 5 May 2019 21:58:31 +0200 Subject: [PATCH 3/4] updated the baseline files --- tests/baselines/reference/jsDocTags.baseline | 70 +++++ ...oDisplayPartsTypeParameterInClass.baseline | 84 +++++- ...playPartsTypeParameterInInterface.baseline | 260 +++++++++++++++++- 3 files changed, 402 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/jsDocTags.baseline b/tests/baselines/reference/jsDocTags.baseline index f316a9c42459d..2d89c183ab344 100644 --- a/tests/baselines/reference/jsDocTags.baseline +++ b/tests/baselines/reference/jsDocTags.baseline @@ -79,6 +79,76 @@ "marker": { "fileName": "/tests/cases/fourslash/jsDocTags.ts", "position": 981 + }, + "quickInfo": { + "kind": "constructor", + "kindModifiers": "", + "textSpan": { + "start": 977, + "length": 3 + }, + "displayParts": [ + { + "text": "constructor", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "value", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + } + ], + "documentation": [ + { + "text": "This is the constructor.", + "kind": "text" + } + ], + "tags": [ + { + "name": "myjsdoctag", + "text": "this is a comment" + } + ] } }, { diff --git a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline index 48bd280a1b505..68e48ff9b68e4 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline @@ -2991,15 +2991,15 @@ "position": 337 }, "quickInfo": { - "kind": "var", + "kind": "constructor", "kindModifiers": "", "textSpan": { - "start": 337, - "length": 9 + "start": 334, + "length": 2 }, "displayParts": [ { - "text": "var", + "text": "constructor", "kind": "keyword" }, { @@ -3007,8 +3007,40 @@ "kind": "space" }, { - "text": "cInstance", - "kind": "localName" + "text": "c2", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "c", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" }, { "text": ":", @@ -3030,6 +3062,46 @@ "text": "string", "kind": "keyword" }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c2", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "c", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, { "text": ">", "kind": "punctuation" diff --git a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline index 715811f9918a1..6830394801c48 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline @@ -5568,8 +5568,8 @@ "kind": "var", "kindModifiers": "", "textSpan": { - "start": 415, - "length": 4 + "start": 409, + "length": 5 }, "displayParts": [ { @@ -5581,7 +5581,7 @@ "kind": "space" }, { - "text": "iVal", + "text": "iVal1", "kind": "localName" }, { @@ -5592,6 +5592,130 @@ "text": " ", "kind": "space" }, + { + "text": "I1", + "kind": "interfaceName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "I", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "I", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "I", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, { "text": "I", "kind": "interfaceName" @@ -5621,8 +5745,8 @@ "kind": "var", "kindModifiers": "", "textSpan": { - "start": 421, - "length": 4 + "start": 409, + "length": 5 }, "displayParts": [ { @@ -5634,7 +5758,7 @@ "kind": "space" }, { - "text": "iVal", + "text": "iVal1", "kind": "localName" }, { @@ -5645,6 +5769,130 @@ "text": " ", "kind": "space" }, + { + "text": "I1", + "kind": "interfaceName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "I", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "I", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "I", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, { "text": "I", "kind": "interfaceName" From 8f209be149ec626f40031a5b0f904ae5ea74479d Mon Sep 17 00:00:00 2001 From: rpgeeganage Date: Mon, 6 May 2019 21:21:37 +0200 Subject: [PATCH 4/4] fixed the comments --- src/services/services.ts | 16 +- tests/baselines/reference/jsDocTags.baseline | 70 ----- ...oDisplayPartsTypeParameterInClass.baseline | 84 +----- ...playPartsTypeParameterInInterface.baseline | 260 +----------------- .../fourslash/quickInfoOnNewKeyword01.ts | 5 +- 5 files changed, 17 insertions(+), 418 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index ab5138fb489ae..628ec395437b6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1467,7 +1467,7 @@ namespace ts { } const typeChecker = program.getTypeChecker(); - const nodeForQuickInfo = getNodeForQuickInfo(node, typeChecker); + const nodeForQuickInfo = getNodeForQuickInfo(node); const symbol = getSymbolAtLocationForQuickInfo(nodeForQuickInfo, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { @@ -1495,17 +1495,9 @@ namespace ts { }; } - function getNodeForQuickInfo(node: Node, typeChecker: TypeChecker): Node { - const firstParentNode = node.parent.getFirstToken(); - const firstNodeSyntaxKind = firstParentNode ? firstParentNode.kind : undefined; - - if (node.kind === SyntaxKind.NewKeyword || firstNodeSyntaxKind === SyntaxKind.NewKeyword) { - for (const singleNode of node.parent.getChildren()) { - const symbol = getSymbolAtLocationForQuickInfo(singleNode, typeChecker); - if (symbol) { - return singleNode; - } - } + function getNodeForQuickInfo(node: Node): Node { + if (isNewExpression(node.parent) && node.pos === node.parent.pos) { + return node.parent.expression; } return node; } diff --git a/tests/baselines/reference/jsDocTags.baseline b/tests/baselines/reference/jsDocTags.baseline index 2d89c183ab344..f316a9c42459d 100644 --- a/tests/baselines/reference/jsDocTags.baseline +++ b/tests/baselines/reference/jsDocTags.baseline @@ -79,76 +79,6 @@ "marker": { "fileName": "/tests/cases/fourslash/jsDocTags.ts", "position": 981 - }, - "quickInfo": { - "kind": "constructor", - "kindModifiers": "", - "textSpan": { - "start": 977, - "length": 3 - }, - "displayParts": [ - { - "text": "constructor", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Foo", - "kind": "className" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "value", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Foo", - "kind": "className" - } - ], - "documentation": [ - { - "text": "This is the constructor.", - "kind": "text" - } - ], - "tags": [ - { - "name": "myjsdoctag", - "text": "this is a comment" - } - ] } }, { diff --git a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline index 68e48ff9b68e4..48bd280a1b505 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInClass.baseline @@ -2991,15 +2991,15 @@ "position": 337 }, "quickInfo": { - "kind": "constructor", + "kind": "var", "kindModifiers": "", "textSpan": { - "start": 334, - "length": 2 + "start": 337, + "length": 9 }, "displayParts": [ { - "text": "constructor", + "text": "var", "kind": "keyword" }, { @@ -3007,68 +3007,8 @@ "kind": "space" }, { - "text": "c2", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "c", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "a", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" + "text": "cInstance", + "kind": "localName" }, { "text": ":", @@ -3078,14 +3018,6 @@ "text": " ", "kind": "space" }, - { - "text": "c2", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, { "text": "c", "kind": "className" @@ -3098,10 +3030,6 @@ "text": "string", "kind": "keyword" }, - { - "text": ">", - "kind": "punctuation" - }, { "text": ">", "kind": "punctuation" diff --git a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline index 6830394801c48..715811f9918a1 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline @@ -5568,8 +5568,8 @@ "kind": "var", "kindModifiers": "", "textSpan": { - "start": 409, - "length": 5 + "start": 415, + "length": 4 }, "displayParts": [ { @@ -5581,7 +5581,7 @@ "kind": "space" }, { - "text": "iVal1", + "text": "iVal", "kind": "localName" }, { @@ -5592,130 +5592,6 @@ "text": " ", "kind": "space" }, - { - "text": "I1", - "kind": "interfaceName" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "a", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "b", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, { "text": "I", "kind": "interfaceName" @@ -5745,8 +5621,8 @@ "kind": "var", "kindModifiers": "", "textSpan": { - "start": 409, - "length": 5 + "start": 421, + "length": 4 }, "displayParts": [ { @@ -5758,7 +5634,7 @@ "kind": "space" }, { - "text": "iVal1", + "text": "iVal", "kind": "localName" }, { @@ -5769,130 +5645,6 @@ "text": " ", "kind": "space" }, - { - "text": "I1", - "kind": "interfaceName" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "a", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "b", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "I", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, { "text": "I", "kind": "interfaceName" diff --git a/tests/cases/fourslash/quickInfoOnNewKeyword01.ts b/tests/cases/fourslash/quickInfoOnNewKeyword01.ts index 21ccb8a65024d..f7d1e359b8d2a 100644 --- a/tests/cases/fourslash/quickInfoOnNewKeyword01.ts +++ b/tests/cases/fourslash/quickInfoOnNewKeyword01.ts @@ -9,13 +9,10 @@ //// static makeCat() { new Cat(); } ////} //// -////ne/*1*/w Ca/*2*/t(/*3*/); +////ne/*1*/w Ca/*2*/t(); verify.quickInfoAt('1', 'constructor Cat(): Cat', 'NOTE: this constructor is private! Please use the factory function'); verify.quickInfoAt('2', 'constructor Cat(): Cat', 'NOTE: this constructor is private! Please use the factory function'); - -verify.quickInfoAt('3', 'constructor Cat(): Cat', -'NOTE: this constructor is private! Please use the factory function');