mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
//// [tests/cases/conformance/classes/members/accessibility/privateProtectedMembersAreNotAccessibleDestructuring.ts] ////
|
|
|
|
//// [privateProtectedMembersAreNotAccessibleDestructuring.ts]
|
|
class K {
|
|
private priv;
|
|
protected prot;
|
|
private privateMethod() { }
|
|
m() {
|
|
let { priv: a, prot: b } = this; // ok
|
|
let { priv, prot } = new K(); // ok
|
|
}
|
|
}
|
|
class C extends K {
|
|
m2() {
|
|
let { priv: a } = this; // error
|
|
let { prot: b } = this; // ok
|
|
}
|
|
}
|
|
let k = new K();
|
|
let { priv } = k; // error
|
|
let { prot } = k; // error
|
|
let { privateMethod } = k; // error
|
|
let { priv: a, prot: b, privateMethod: pm } = k; // error
|
|
function f({ priv, prot, privateMethod }: K) {
|
|
|
|
}
|
|
|
|
|
|
//// [privateProtectedMembersAreNotAccessibleDestructuring.js]
|
|
"use strict";
|
|
class K {
|
|
privateMethod() { }
|
|
m() {
|
|
let { priv: a, prot: b } = this; // ok
|
|
let { priv, prot } = new K(); // ok
|
|
}
|
|
}
|
|
class C extends K {
|
|
m2() {
|
|
let { priv: a } = this; // error
|
|
let { prot: b } = this; // ok
|
|
}
|
|
}
|
|
let k = new K();
|
|
let { priv } = k; // error
|
|
let { prot } = k; // error
|
|
let { privateMethod } = k; // error
|
|
let { priv: a, prot: b, privateMethod: pm } = k; // error
|
|
function f({ priv, prot, privateMethod }) {
|
|
}
|