mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
Merge branch 'master' into projzilla
This commit is contained in:
commit
bb4872787c
22
README.md
22
README.md
@ -61,29 +61,29 @@ Change to the TypeScript directory:
|
||||
cd TypeScript
|
||||
```
|
||||
|
||||
Install Gulp tools and dev dependencies:
|
||||
Install Jake tools and dev dependencies:
|
||||
|
||||
```bash
|
||||
npm install -g gulp
|
||||
npm install -g jake
|
||||
npm install
|
||||
```
|
||||
|
||||
Use one of the following to build and test:
|
||||
|
||||
```
|
||||
gulp local # Build the compiler into built/local
|
||||
gulp clean # Delete the built compiler
|
||||
gulp LKG # Replace the last known good with the built one.
|
||||
jake local # Build the compiler into built/local
|
||||
jake clean # Delete the built compiler
|
||||
jake LKG # Replace the last known good with the built one.
|
||||
# Bootstrapping step to be executed when the built compiler reaches a stable state.
|
||||
gulp tests # Build the test infrastructure using the built compiler.
|
||||
gulp runtests # Run tests using the built compiler and test infrastructure.
|
||||
jake tests # Build the test infrastructure using the built compiler.
|
||||
jake runtests # Run tests using the built compiler and test infrastructure.
|
||||
# You can override the host or specify a test for this command.
|
||||
# Use host=<hostName> or tests=<testPath>.
|
||||
gulp runtests-browser # Runs the tests using the built run.js file. Syntax is gulp runtests. Optional
|
||||
jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional
|
||||
parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.
|
||||
gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests.
|
||||
gulp lint # Runs tslint on the TypeScript source.
|
||||
gulp help # List the above commands.
|
||||
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests.
|
||||
jake lint # Runs tslint on the TypeScript source.
|
||||
jake help # List the above commands.
|
||||
```
|
||||
|
||||
|
||||
|
||||
@ -17122,20 +17122,28 @@ namespace ts {
|
||||
|
||||
// Find the first enclosing class that has the declaring classes of the protected constituents
|
||||
// of the property as base classes
|
||||
const enclosingClass = forEachEnclosingClass(node, enclosingDeclaration => {
|
||||
let enclosingClass = forEachEnclosingClass(node, enclosingDeclaration => {
|
||||
const enclosingClass = <InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)!);
|
||||
return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
|
||||
});
|
||||
// A protected property is accessible if the property is within the declaring class or classes derived from it
|
||||
if (!enclosingClass) {
|
||||
error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
|
||||
return false;
|
||||
// allow PropertyAccessibility if context is in function with this parameter
|
||||
// static member access is disallow
|
||||
let thisParameter: ParameterDeclaration | undefined;
|
||||
if (flags & ModifierFlags.Static || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
|
||||
error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
|
||||
return false;
|
||||
}
|
||||
|
||||
const thisType = getTypeFromTypeNode(thisParameter.type);
|
||||
enclosingClass = ((thisType.flags & TypeFlags.TypeParameter) ? getConstraintFromTypeParameter(<TypeParameter>thisType) : thisType) as InterfaceType;
|
||||
}
|
||||
// No further restrictions for static properties
|
||||
if (flags & ModifierFlags.Static) {
|
||||
return true;
|
||||
}
|
||||
if (type.flags & TypeFlags.TypeParameter) {
|
||||
if (type.flags & TypeFlags.TypeParameter) {
|
||||
// get the original type -- represented as the type constraint of the 'this' type
|
||||
type = (type as TypeParameter).isThisType ? getConstraintOfTypeParameter(<TypeParameter>type)! : getBaseConstraintOfType(<TypeParameter>type)!; // TODO: GH#18217 Use a different variable that's allowed to be undefined
|
||||
}
|
||||
@ -17146,6 +17154,11 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getThisParameterFromNodeContext (node: Node) {
|
||||
const thisContainer = getThisContainer(node, /* includeArrowFunctions */ false);
|
||||
return thisContainer && isFunctionLike(thisContainer) ? getThisParameter(thisContainer) : undefined;
|
||||
}
|
||||
|
||||
function symbolHasNonMethodDeclaration(symbol: Symbol) {
|
||||
return forEachProperty(symbol, prop => {
|
||||
const propKind = getDeclarationKindFromSymbol(prop);
|
||||
|
||||
@ -511,6 +511,8 @@ namespace ts.server {
|
||||
|
||||
const { fileName, project } = checkList[index];
|
||||
index++;
|
||||
// Ensure the project is upto date before checking if this file is present in the project
|
||||
project.updateGraph();
|
||||
if (!project.containsFile(fileName, requireOpen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -58,6 +58,18 @@ namespace ts.projectSystem {
|
||||
getLogFileName: () => undefined,
|
||||
};
|
||||
|
||||
function createHasErrorMessageLogger() {
|
||||
let hasErrorMsg = false;
|
||||
const { close, hasLevel, loggingEnabled, startGroup, endGroup, info, getLogFileName, perftrc } = nullLogger;
|
||||
const logger: server.Logger = {
|
||||
close, hasLevel, loggingEnabled, startGroup, endGroup, info, getLogFileName, perftrc,
|
||||
msg: () => {
|
||||
hasErrorMsg = true;
|
||||
}
|
||||
};
|
||||
return { logger, hasErrorMsg: () => hasErrorMsg };
|
||||
}
|
||||
|
||||
export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller {
|
||||
protected projectService: server.ProjectService;
|
||||
constructor(
|
||||
@ -2913,14 +2925,7 @@ namespace ts.projectSystem {
|
||||
});
|
||||
|
||||
it("Getting errors from closed script info does not throw exception (because of getting project from orphan script info)", () => {
|
||||
let hasErrorMsg = false;
|
||||
const { close, hasLevel, loggingEnabled, startGroup, endGroup, info, getLogFileName, perftrc } = nullLogger;
|
||||
const logger: server.Logger = {
|
||||
close, hasLevel, loggingEnabled, startGroup, endGroup, info, getLogFileName, perftrc,
|
||||
msg: () => {
|
||||
hasErrorMsg = true;
|
||||
}
|
||||
};
|
||||
const { logger, hasErrorMsg } = createHasErrorMessageLogger();
|
||||
const f1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "let x = 1;"
|
||||
@ -2950,7 +2955,7 @@ namespace ts.projectSystem {
|
||||
files: [f1.path]
|
||||
}
|
||||
});
|
||||
assert.isFalse(hasErrorMsg);
|
||||
assert.isFalse(hasErrorMsg());
|
||||
});
|
||||
|
||||
it("Changed module resolution reflected when specifying files list", () => {
|
||||
@ -3316,6 +3321,129 @@ namespace ts.projectSystem {
|
||||
assert.equal(info.containingProjects.length, 0);
|
||||
}
|
||||
});
|
||||
|
||||
it("handles delayed directory watch invoke on file creation", () => {
|
||||
const projectRootPath = "/users/username/projects/project";
|
||||
const fileB: File = {
|
||||
path: `${projectRootPath}/b.ts`,
|
||||
content: "export const b = 10;"
|
||||
};
|
||||
const fileA: File = {
|
||||
path: `${projectRootPath}/a.ts`,
|
||||
content: "export const a = 10;"
|
||||
};
|
||||
const fileSubA: File = {
|
||||
path: `${projectRootPath}/sub/a.ts`,
|
||||
content: fileA.content
|
||||
};
|
||||
const config: File = {
|
||||
path: `${projectRootPath}/tsconfig.json`,
|
||||
content: "{}"
|
||||
};
|
||||
const files = [fileSubA, fileB, config, libFile];
|
||||
const host = createServerHost(files);
|
||||
const { logger, hasErrorMsg } = createHasErrorMessageLogger();
|
||||
const session = createSession(host, { canUseEvents: true, noGetErrOnBackgroundUpdate: true, logger });
|
||||
openFile(fileB);
|
||||
openFile(fileSubA);
|
||||
|
||||
const services = session.getProjectService();
|
||||
checkNumberOfProjects(services, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(services.configuredProjects.get(config.path)!, files.map(f => f.path));
|
||||
host.checkTimeoutQueueLengthAndRun(0);
|
||||
|
||||
// This should schedule 2 timeouts for ensuring project structure and ensuring projects for open file
|
||||
const filesWithFileA = files.map(f => f === fileSubA ? fileA : f);
|
||||
host.reloadFS(files.map(f => f === fileSubA ? fileA : f));
|
||||
host.checkTimeoutQueueLength(2);
|
||||
|
||||
closeFile(fileSubA);
|
||||
// This should cancel existing updates and schedule new ones
|
||||
host.checkTimeoutQueueLength(2);
|
||||
checkNumberOfProjects(services, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(services.configuredProjects.get(config.path)!, files.map(f => f.path));
|
||||
|
||||
// Open the fileA (as if rename)
|
||||
openFile(fileA);
|
||||
|
||||
// config project is updated to check if fileA is present in it
|
||||
checkNumberOfProjects(services, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(services.configuredProjects.get(config.path)!, filesWithFileA.map(f => f.path));
|
||||
|
||||
// Run the timeout for updating configured project and ensuring projects for open file
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(services.configuredProjects.get(config.path)!, filesWithFileA.map(f => f.path));
|
||||
|
||||
// file is deleted but watches are not yet invoked
|
||||
const originalFileExists = host.fileExists;
|
||||
host.fileExists = s => s === fileA.path ? false : originalFileExists.call(host, s);
|
||||
closeFile(fileA);
|
||||
host.checkTimeoutQueueLength(2); // Update configured project and projects for open file
|
||||
checkProjectActualFiles(services.configuredProjects.get(config.path)!, filesWithFileA.map(f => f.path));
|
||||
|
||||
// host.fileExists = originalFileExists;
|
||||
openFile(fileSubA);
|
||||
// This should create inferred project since fileSubA not on the disk
|
||||
checkProjectActualFiles(services.configuredProjects.get(config.path)!, mapDefined(filesWithFileA, f => f === fileA ? undefined : f.path));
|
||||
checkProjectActualFiles(services.inferredProjects[0], [fileSubA.path, libFile.path]);
|
||||
|
||||
host.checkTimeoutQueueLengthAndRun(2); // Update configured project and projects for open file
|
||||
host.fileExists = originalFileExists;
|
||||
|
||||
// Actually trigger the file move
|
||||
host.reloadFS(files);
|
||||
host.checkTimeoutQueueLength(2);
|
||||
const fileBErrorTimeoutId = host.getNextTimeoutId();
|
||||
|
||||
session.executeCommandSeq<protocol.GeterrRequest>({
|
||||
command: protocol.CommandTypes.Geterr,
|
||||
arguments: {
|
||||
files: [fileB.path, fileSubA.path],
|
||||
delay: 0
|
||||
}
|
||||
});
|
||||
const getErrSeqId = session.getSeq();
|
||||
host.checkTimeoutQueueLength(3);
|
||||
|
||||
session.clearMessages();
|
||||
host.runQueuedTimeoutCallbacks(fileBErrorTimeoutId);
|
||||
checkErrorMessage(session, "syntaxDiag", { file: fileB.path, diagnostics: [] });
|
||||
|
||||
session.clearMessages();
|
||||
host.runQueuedImmediateCallbacks();
|
||||
checkErrorMessage(session, "semanticDiag", { file: fileB.path, diagnostics: [] });
|
||||
|
||||
session.clearMessages();
|
||||
const fileSubAErrorTimeoutId = host.getNextTimeoutId();
|
||||
host.runQueuedImmediateCallbacks();
|
||||
checkErrorMessage(session, "suggestionDiag", { file: fileB.path, diagnostics: [] });
|
||||
|
||||
session.clearMessages();
|
||||
host.checkTimeoutQueueLength(3);
|
||||
host.runQueuedTimeoutCallbacks(fileSubAErrorTimeoutId);
|
||||
checkCompleteEvent(session, 1, getErrSeqId);
|
||||
assert.isFalse(hasErrorMsg());
|
||||
|
||||
function openFile(file: File) {
|
||||
session.executeCommandSeq<protocol.OpenRequest>({
|
||||
command: protocol.CommandTypes.Open,
|
||||
arguments: {
|
||||
file: file.path,
|
||||
fileContent: file.content,
|
||||
projectRootPath
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function closeFile(file: File) {
|
||||
session.executeCommandSeq<protocol.CloseRequest>({
|
||||
command: protocol.CommandTypes.Close,
|
||||
arguments: {
|
||||
file: file.path
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("tsserverProjectSystem Proper errors", () => {
|
||||
|
||||
74
tests/baselines/reference/thisTypeAccessibility.errors.txt
Normal file
74
tests/baselines/reference/thisTypeAccessibility.errors.txt
Normal file
@ -0,0 +1,74 @@
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(17,10): error TS2341: Property 'p' is private and only accessible within class 'MyClass'.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(20,13): error TS2341: Property 'sp' is private and only accessible within class 'MyClass'.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(21,13): error TS2445: Property 'spp' is protected and only accessible within class 'MyClass' and its subclasses.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(26,10): error TS2341: Property 'p' is private and only accessible within class 'MyClass'.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(29,13): error TS2341: Property 'sp' is private and only accessible within class 'MyClass'.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(30,13): error TS2445: Property 'spp' is protected and only accessible within class 'MyClass' and its subclasses.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(35,10): error TS2341: Property 'p' is private and only accessible within class 'MyClass'.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(38,13): error TS2341: Property 'sp' is private and only accessible within class 'MyClass'.
|
||||
tests/cases/conformance/types/thisType/thisTypeAccessibility.ts(39,13): error TS2445: Property 'spp' is protected and only accessible within class 'MyClass' and its subclasses.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/thisType/thisTypeAccessibility.ts (9 errors) ====
|
||||
class MyClass {
|
||||
private p: number = 123;
|
||||
protected pp: number = 123;
|
||||
public ppp: number = 123;
|
||||
private static sp: number = 123;
|
||||
protected static spp: number = 123;
|
||||
public static sppp: number = 123;
|
||||
}
|
||||
|
||||
interface MyClass {
|
||||
extension1(p: number): void;
|
||||
extension2(p: number): void;
|
||||
extension3(p: number): void;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension1 = function (this: MyClass, p: number) {
|
||||
this.p = p;
|
||||
~
|
||||
!!! error TS2341: Property 'p' is private and only accessible within class 'MyClass'.
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
~~
|
||||
!!! error TS2341: Property 'sp' is private and only accessible within class 'MyClass'.
|
||||
MyClass.spp = p;
|
||||
~~~
|
||||
!!! error TS2445: Property 'spp' is protected and only accessible within class 'MyClass' and its subclasses.
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension2 = function<T extends MyClass> (this: T, p: number) {
|
||||
this.p = p;
|
||||
~
|
||||
!!! error TS2341: Property 'p' is private and only accessible within class 'MyClass'.
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
~~
|
||||
!!! error TS2341: Property 'sp' is private and only accessible within class 'MyClass'.
|
||||
MyClass.spp = p;
|
||||
~~~
|
||||
!!! error TS2445: Property 'spp' is protected and only accessible within class 'MyClass' and its subclasses.
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
function extension3<T extends MyClass> (this: T, p: number) {
|
||||
this.p = p;
|
||||
~
|
||||
!!! error TS2341: Property 'p' is private and only accessible within class 'MyClass'.
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
~~
|
||||
!!! error TS2341: Property 'sp' is private and only accessible within class 'MyClass'.
|
||||
MyClass.spp = p;
|
||||
~~~
|
||||
!!! error TS2445: Property 'spp' is protected and only accessible within class 'MyClass' and its subclasses.
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension3 = extension3;
|
||||
|
||||
83
tests/baselines/reference/thisTypeAccessibility.js
Normal file
83
tests/baselines/reference/thisTypeAccessibility.js
Normal file
@ -0,0 +1,83 @@
|
||||
//// [thisTypeAccessibility.ts]
|
||||
class MyClass {
|
||||
private p: number = 123;
|
||||
protected pp: number = 123;
|
||||
public ppp: number = 123;
|
||||
private static sp: number = 123;
|
||||
protected static spp: number = 123;
|
||||
public static sppp: number = 123;
|
||||
}
|
||||
|
||||
interface MyClass {
|
||||
extension1(p: number): void;
|
||||
extension2(p: number): void;
|
||||
extension3(p: number): void;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension1 = function (this: MyClass, p: number) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension2 = function<T extends MyClass> (this: T, p: number) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
function extension3<T extends MyClass> (this: T, p: number) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension3 = extension3;
|
||||
|
||||
|
||||
//// [thisTypeAccessibility.js]
|
||||
var MyClass = /** @class */ (function () {
|
||||
function MyClass() {
|
||||
this.p = 123;
|
||||
this.pp = 123;
|
||||
this.ppp = 123;
|
||||
}
|
||||
MyClass.sp = 123;
|
||||
MyClass.spp = 123;
|
||||
MyClass.sppp = 123;
|
||||
return MyClass;
|
||||
}());
|
||||
MyClass.prototype.extension1 = function (p) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
};
|
||||
MyClass.prototype.extension2 = function (p) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
};
|
||||
function extension3(p) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
MyClass.prototype.extension3 = extension3;
|
||||
188
tests/baselines/reference/thisTypeAccessibility.symbols
Normal file
188
tests/baselines/reference/thisTypeAccessibility.symbols
Normal file
@ -0,0 +1,188 @@
|
||||
=== tests/cases/conformance/types/thisType/thisTypeAccessibility.ts ===
|
||||
class MyClass {
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
|
||||
private p: number = 123;
|
||||
>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15))
|
||||
|
||||
protected pp: number = 123;
|
||||
>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28))
|
||||
|
||||
public ppp: number = 123;
|
||||
>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31))
|
||||
|
||||
private static sp: number = 123;
|
||||
>sp : Symbol(MyClass.sp, Decl(thisTypeAccessibility.ts, 3, 29))
|
||||
|
||||
protected static spp: number = 123;
|
||||
>spp : Symbol(MyClass.spp, Decl(thisTypeAccessibility.ts, 4, 36))
|
||||
|
||||
public static sppp: number = 123;
|
||||
>sppp : Symbol(MyClass.sppp, Decl(thisTypeAccessibility.ts, 5, 39))
|
||||
}
|
||||
|
||||
interface MyClass {
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
|
||||
extension1(p: number): void;
|
||||
>extension1 : Symbol(MyClass.extension1, Decl(thisTypeAccessibility.ts, 9, 19))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 10, 15))
|
||||
|
||||
extension2(p: number): void;
|
||||
>extension2 : Symbol(MyClass.extension2, Decl(thisTypeAccessibility.ts, 10, 32))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 11, 15))
|
||||
|
||||
extension3(p: number): void;
|
||||
>extension3 : Symbol(MyClass.extension3, Decl(thisTypeAccessibility.ts, 11, 32))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 12, 15))
|
||||
}
|
||||
|
||||
MyClass.prototype.extension1 = function (this: MyClass, p: number) {
|
||||
>MyClass.prototype.extension1 : Symbol(MyClass.extension1, Decl(thisTypeAccessibility.ts, 9, 19))
|
||||
>MyClass.prototype : Symbol(MyClass.prototype)
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>prototype : Symbol(MyClass.prototype)
|
||||
>extension1 : Symbol(MyClass.extension1, Decl(thisTypeAccessibility.ts, 9, 19))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 15, 41))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 15, 55))
|
||||
|
||||
this.p = p;
|
||||
>this.p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 15, 41))
|
||||
>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 15, 55))
|
||||
|
||||
this.pp = p;
|
||||
>this.pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 15, 41))
|
||||
>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 15, 55))
|
||||
|
||||
this.ppp = p;
|
||||
>this.ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 15, 41))
|
||||
>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 15, 55))
|
||||
|
||||
MyClass.sp = p;
|
||||
>MyClass.sp : Symbol(MyClass.sp, Decl(thisTypeAccessibility.ts, 3, 29))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>sp : Symbol(MyClass.sp, Decl(thisTypeAccessibility.ts, 3, 29))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 15, 55))
|
||||
|
||||
MyClass.spp = p;
|
||||
>MyClass.spp : Symbol(MyClass.spp, Decl(thisTypeAccessibility.ts, 4, 36))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>spp : Symbol(MyClass.spp, Decl(thisTypeAccessibility.ts, 4, 36))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 15, 55))
|
||||
|
||||
MyClass.sppp = p;
|
||||
>MyClass.sppp : Symbol(MyClass.sppp, Decl(thisTypeAccessibility.ts, 5, 39))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>sppp : Symbol(MyClass.sppp, Decl(thisTypeAccessibility.ts, 5, 39))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 15, 55))
|
||||
}
|
||||
|
||||
MyClass.prototype.extension2 = function<T extends MyClass> (this: T, p: number) {
|
||||
>MyClass.prototype.extension2 : Symbol(MyClass.extension2, Decl(thisTypeAccessibility.ts, 10, 32))
|
||||
>MyClass.prototype : Symbol(MyClass.prototype)
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>prototype : Symbol(MyClass.prototype)
|
||||
>extension2 : Symbol(MyClass.extension2, Decl(thisTypeAccessibility.ts, 10, 32))
|
||||
>T : Symbol(T, Decl(thisTypeAccessibility.ts, 24, 40))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 60))
|
||||
>T : Symbol(T, Decl(thisTypeAccessibility.ts, 24, 40))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 68))
|
||||
|
||||
this.p = p;
|
||||
>this.p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 60))
|
||||
>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 68))
|
||||
|
||||
this.pp = p;
|
||||
>this.pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 60))
|
||||
>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 68))
|
||||
|
||||
this.ppp = p;
|
||||
>this.ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 24, 60))
|
||||
>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 68))
|
||||
|
||||
MyClass.sp = p;
|
||||
>MyClass.sp : Symbol(MyClass.sp, Decl(thisTypeAccessibility.ts, 3, 29))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>sp : Symbol(MyClass.sp, Decl(thisTypeAccessibility.ts, 3, 29))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 68))
|
||||
|
||||
MyClass.spp = p;
|
||||
>MyClass.spp : Symbol(MyClass.spp, Decl(thisTypeAccessibility.ts, 4, 36))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>spp : Symbol(MyClass.spp, Decl(thisTypeAccessibility.ts, 4, 36))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 68))
|
||||
|
||||
MyClass.sppp = p;
|
||||
>MyClass.sppp : Symbol(MyClass.sppp, Decl(thisTypeAccessibility.ts, 5, 39))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>sppp : Symbol(MyClass.sppp, Decl(thisTypeAccessibility.ts, 5, 39))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 24, 68))
|
||||
}
|
||||
|
||||
function extension3<T extends MyClass> (this: T, p: number) {
|
||||
>extension3 : Symbol(extension3, Decl(thisTypeAccessibility.ts, 31, 1))
|
||||
>T : Symbol(T, Decl(thisTypeAccessibility.ts, 33, 20))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 33, 40))
|
||||
>T : Symbol(T, Decl(thisTypeAccessibility.ts, 33, 20))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 33, 48))
|
||||
|
||||
this.p = p;
|
||||
>this.p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 33, 40))
|
||||
>p : Symbol(MyClass.p, Decl(thisTypeAccessibility.ts, 0, 15))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 33, 48))
|
||||
|
||||
this.pp = p;
|
||||
>this.pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 33, 40))
|
||||
>pp : Symbol(MyClass.pp, Decl(thisTypeAccessibility.ts, 1, 28))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 33, 48))
|
||||
|
||||
this.ppp = p;
|
||||
>this.ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31))
|
||||
>this : Symbol(this, Decl(thisTypeAccessibility.ts, 33, 40))
|
||||
>ppp : Symbol(MyClass.ppp, Decl(thisTypeAccessibility.ts, 2, 31))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 33, 48))
|
||||
|
||||
MyClass.sp = p;
|
||||
>MyClass.sp : Symbol(MyClass.sp, Decl(thisTypeAccessibility.ts, 3, 29))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>sp : Symbol(MyClass.sp, Decl(thisTypeAccessibility.ts, 3, 29))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 33, 48))
|
||||
|
||||
MyClass.spp = p;
|
||||
>MyClass.spp : Symbol(MyClass.spp, Decl(thisTypeAccessibility.ts, 4, 36))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>spp : Symbol(MyClass.spp, Decl(thisTypeAccessibility.ts, 4, 36))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 33, 48))
|
||||
|
||||
MyClass.sppp = p;
|
||||
>MyClass.sppp : Symbol(MyClass.sppp, Decl(thisTypeAccessibility.ts, 5, 39))
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>sppp : Symbol(MyClass.sppp, Decl(thisTypeAccessibility.ts, 5, 39))
|
||||
>p : Symbol(p, Decl(thisTypeAccessibility.ts, 33, 48))
|
||||
}
|
||||
|
||||
MyClass.prototype.extension3 = extension3;
|
||||
>MyClass.prototype.extension3 : Symbol(MyClass.extension3, Decl(thisTypeAccessibility.ts, 11, 32))
|
||||
>MyClass.prototype : Symbol(MyClass.prototype)
|
||||
>MyClass : Symbol(MyClass, Decl(thisTypeAccessibility.ts, 0, 0), Decl(thisTypeAccessibility.ts, 7, 1))
|
||||
>prototype : Symbol(MyClass.prototype)
|
||||
>extension3 : Symbol(MyClass.extension3, Decl(thisTypeAccessibility.ts, 11, 32))
|
||||
>extension3 : Symbol(extension3, Decl(thisTypeAccessibility.ts, 31, 1))
|
||||
|
||||
217
tests/baselines/reference/thisTypeAccessibility.types
Normal file
217
tests/baselines/reference/thisTypeAccessibility.types
Normal file
@ -0,0 +1,217 @@
|
||||
=== tests/cases/conformance/types/thisType/thisTypeAccessibility.ts ===
|
||||
class MyClass {
|
||||
>MyClass : MyClass
|
||||
|
||||
private p: number = 123;
|
||||
>p : number
|
||||
>123 : 123
|
||||
|
||||
protected pp: number = 123;
|
||||
>pp : number
|
||||
>123 : 123
|
||||
|
||||
public ppp: number = 123;
|
||||
>ppp : number
|
||||
>123 : 123
|
||||
|
||||
private static sp: number = 123;
|
||||
>sp : number
|
||||
>123 : 123
|
||||
|
||||
protected static spp: number = 123;
|
||||
>spp : number
|
||||
>123 : 123
|
||||
|
||||
public static sppp: number = 123;
|
||||
>sppp : number
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
interface MyClass {
|
||||
>MyClass : MyClass
|
||||
|
||||
extension1(p: number): void;
|
||||
>extension1 : (p: number) => void
|
||||
>p : number
|
||||
|
||||
extension2(p: number): void;
|
||||
>extension2 : (p: number) => void
|
||||
>p : number
|
||||
|
||||
extension3(p: number): void;
|
||||
>extension3 : (p: number) => void
|
||||
>p : number
|
||||
}
|
||||
|
||||
MyClass.prototype.extension1 = function (this: MyClass, p: number) {
|
||||
>MyClass.prototype.extension1 = function (this: MyClass, p: number) { this.p = p; this.pp = p; this.ppp = p; MyClass.sp = p; MyClass.spp = p; MyClass.sppp = p;} : (this: MyClass, p: number) => void
|
||||
>MyClass.prototype.extension1 : (p: number) => void
|
||||
>MyClass.prototype : MyClass
|
||||
>MyClass : typeof MyClass
|
||||
>prototype : MyClass
|
||||
>extension1 : (p: number) => void
|
||||
>function (this: MyClass, p: number) { this.p = p; this.pp = p; this.ppp = p; MyClass.sp = p; MyClass.spp = p; MyClass.sppp = p;} : (this: MyClass, p: number) => void
|
||||
>this : MyClass
|
||||
>MyClass : MyClass
|
||||
>p : number
|
||||
|
||||
this.p = p;
|
||||
>this.p = p : number
|
||||
>this.p : number
|
||||
>this : MyClass
|
||||
>p : number
|
||||
>p : number
|
||||
|
||||
this.pp = p;
|
||||
>this.pp = p : number
|
||||
>this.pp : number
|
||||
>this : MyClass
|
||||
>pp : number
|
||||
>p : number
|
||||
|
||||
this.ppp = p;
|
||||
>this.ppp = p : number
|
||||
>this.ppp : number
|
||||
>this : MyClass
|
||||
>ppp : number
|
||||
>p : number
|
||||
|
||||
MyClass.sp = p;
|
||||
>MyClass.sp = p : number
|
||||
>MyClass.sp : number
|
||||
>MyClass : typeof MyClass
|
||||
>sp : number
|
||||
>p : number
|
||||
|
||||
MyClass.spp = p;
|
||||
>MyClass.spp = p : number
|
||||
>MyClass.spp : number
|
||||
>MyClass : typeof MyClass
|
||||
>spp : number
|
||||
>p : number
|
||||
|
||||
MyClass.sppp = p;
|
||||
>MyClass.sppp = p : number
|
||||
>MyClass.sppp : number
|
||||
>MyClass : typeof MyClass
|
||||
>sppp : number
|
||||
>p : number
|
||||
}
|
||||
|
||||
MyClass.prototype.extension2 = function<T extends MyClass> (this: T, p: number) {
|
||||
>MyClass.prototype.extension2 = function<T extends MyClass> (this: T, p: number) { this.p = p; this.pp = p; this.ppp = p; MyClass.sp = p; MyClass.spp = p; MyClass.sppp = p;} : <T extends MyClass>(this: T, p: number) => void
|
||||
>MyClass.prototype.extension2 : (p: number) => void
|
||||
>MyClass.prototype : MyClass
|
||||
>MyClass : typeof MyClass
|
||||
>prototype : MyClass
|
||||
>extension2 : (p: number) => void
|
||||
>function<T extends MyClass> (this: T, p: number) { this.p = p; this.pp = p; this.ppp = p; MyClass.sp = p; MyClass.spp = p; MyClass.sppp = p;} : <T extends MyClass>(this: T, p: number) => void
|
||||
>T : T
|
||||
>MyClass : MyClass
|
||||
>this : T
|
||||
>T : T
|
||||
>p : number
|
||||
|
||||
this.p = p;
|
||||
>this.p = p : number
|
||||
>this.p : number
|
||||
>this : T
|
||||
>p : number
|
||||
>p : number
|
||||
|
||||
this.pp = p;
|
||||
>this.pp = p : number
|
||||
>this.pp : number
|
||||
>this : T
|
||||
>pp : number
|
||||
>p : number
|
||||
|
||||
this.ppp = p;
|
||||
>this.ppp = p : number
|
||||
>this.ppp : number
|
||||
>this : T
|
||||
>ppp : number
|
||||
>p : number
|
||||
|
||||
MyClass.sp = p;
|
||||
>MyClass.sp = p : number
|
||||
>MyClass.sp : number
|
||||
>MyClass : typeof MyClass
|
||||
>sp : number
|
||||
>p : number
|
||||
|
||||
MyClass.spp = p;
|
||||
>MyClass.spp = p : number
|
||||
>MyClass.spp : number
|
||||
>MyClass : typeof MyClass
|
||||
>spp : number
|
||||
>p : number
|
||||
|
||||
MyClass.sppp = p;
|
||||
>MyClass.sppp = p : number
|
||||
>MyClass.sppp : number
|
||||
>MyClass : typeof MyClass
|
||||
>sppp : number
|
||||
>p : number
|
||||
}
|
||||
|
||||
function extension3<T extends MyClass> (this: T, p: number) {
|
||||
>extension3 : <T extends MyClass>(this: T, p: number) => void
|
||||
>T : T
|
||||
>MyClass : MyClass
|
||||
>this : T
|
||||
>T : T
|
||||
>p : number
|
||||
|
||||
this.p = p;
|
||||
>this.p = p : number
|
||||
>this.p : number
|
||||
>this : T
|
||||
>p : number
|
||||
>p : number
|
||||
|
||||
this.pp = p;
|
||||
>this.pp = p : number
|
||||
>this.pp : number
|
||||
>this : T
|
||||
>pp : number
|
||||
>p : number
|
||||
|
||||
this.ppp = p;
|
||||
>this.ppp = p : number
|
||||
>this.ppp : number
|
||||
>this : T
|
||||
>ppp : number
|
||||
>p : number
|
||||
|
||||
MyClass.sp = p;
|
||||
>MyClass.sp = p : number
|
||||
>MyClass.sp : number
|
||||
>MyClass : typeof MyClass
|
||||
>sp : number
|
||||
>p : number
|
||||
|
||||
MyClass.spp = p;
|
||||
>MyClass.spp = p : number
|
||||
>MyClass.spp : number
|
||||
>MyClass : typeof MyClass
|
||||
>spp : number
|
||||
>p : number
|
||||
|
||||
MyClass.sppp = p;
|
||||
>MyClass.sppp = p : number
|
||||
>MyClass.sppp : number
|
||||
>MyClass : typeof MyClass
|
||||
>sppp : number
|
||||
>p : number
|
||||
}
|
||||
|
||||
MyClass.prototype.extension3 = extension3;
|
||||
>MyClass.prototype.extension3 = extension3 : <T extends MyClass>(this: T, p: number) => void
|
||||
>MyClass.prototype.extension3 : (p: number) => void
|
||||
>MyClass.prototype : MyClass
|
||||
>MyClass : typeof MyClass
|
||||
>prototype : MyClass
|
||||
>extension3 : (p: number) => void
|
||||
>extension3 : <T extends MyClass>(this: T, p: number) => void
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
class MyClass {
|
||||
private p: number = 123;
|
||||
protected pp: number = 123;
|
||||
public ppp: number = 123;
|
||||
private static sp: number = 123;
|
||||
protected static spp: number = 123;
|
||||
public static sppp: number = 123;
|
||||
}
|
||||
|
||||
interface MyClass {
|
||||
extension1(p: number): void;
|
||||
extension2(p: number): void;
|
||||
extension3(p: number): void;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension1 = function (this: MyClass, p: number) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension2 = function<T extends MyClass> (this: T, p: number) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
function extension3<T extends MyClass> (this: T, p: number) {
|
||||
this.p = p;
|
||||
this.pp = p;
|
||||
this.ppp = p;
|
||||
MyClass.sp = p;
|
||||
MyClass.spp = p;
|
||||
MyClass.sppp = p;
|
||||
}
|
||||
|
||||
MyClass.prototype.extension3 = extension3;
|
||||
Loading…
x
Reference in New Issue
Block a user