mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Merge pull request #1312 from Microsoft/isDeclarationVisibleAssert
Handle assert for missing node kind in isDeclarationVisible for functionType and constructorType
This commit is contained in:
commit
170014c3da
@ -1608,6 +1608,8 @@ module ts {
|
||||
return isDeclarationVisible(<Declaration>parent);
|
||||
|
||||
case SyntaxKind.Property:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.Method:
|
||||
if (node.flags & (NodeFlags.Private | NodeFlags.Protected)) {
|
||||
// Private/protected properties/methods are not visible
|
||||
@ -1622,6 +1624,14 @@ module ts {
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.TypeReference:
|
||||
case SyntaxKind.ArrayType:
|
||||
case SyntaxKind.TupleType:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return isDeclarationVisible(<Declaration>node.parent);
|
||||
|
||||
// Source file is always visible
|
||||
|
||||
199
tests/baselines/reference/isDeclarationVisibleNodeKinds.js
Normal file
199
tests/baselines/reference/isDeclarationVisibleNodeKinds.js
Normal file
@ -0,0 +1,199 @@
|
||||
//// [isDeclarationVisibleNodeKinds.ts]
|
||||
|
||||
// Function types
|
||||
module schema {
|
||||
export function createValidator1(schema: any): <T>(data: T) => T {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Constructor types
|
||||
module schema {
|
||||
export function createValidator2(schema: any): new <T>(data: T) => T {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// union types
|
||||
module schema {
|
||||
export function createValidator3(schema: any): number | { new <T>(data: T): T; } {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Array types
|
||||
module schema {
|
||||
export function createValidator4(schema: any): { new <T>(data: T): T; }[] {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TypeLiterals
|
||||
module schema {
|
||||
export function createValidator5(schema: any): { new <T>(data: T): T } {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Tuple types
|
||||
module schema {
|
||||
export function createValidator6(schema: any): [ new <T>(data: T) => T, number] {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Paren Types
|
||||
module schema {
|
||||
export function createValidator7(schema: any): (new <T>(data: T)=>T )[] {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Type reference
|
||||
module schema {
|
||||
export function createValidator8(schema: any): Array<{ <T>(data: T) : T}> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module schema {
|
||||
export class T {
|
||||
get createValidator9(): <T>(data: T) => T {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
set createValidator10(v: <T>(data: T) => T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [isDeclarationVisibleNodeKinds.js]
|
||||
// Function types
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator1(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator1 = createValidator1;
|
||||
})(schema || (schema = {}));
|
||||
// Constructor types
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator2(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator2 = createValidator2;
|
||||
})(schema || (schema = {}));
|
||||
// union types
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator3(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator3 = createValidator3;
|
||||
})(schema || (schema = {}));
|
||||
// Array types
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator4(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator4 = createValidator4;
|
||||
})(schema || (schema = {}));
|
||||
// TypeLiterals
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator5(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator5 = createValidator5;
|
||||
})(schema || (schema = {}));
|
||||
// Tuple types
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator6(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator6 = createValidator6;
|
||||
})(schema || (schema = {}));
|
||||
// Paren Types
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator7(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator7 = createValidator7;
|
||||
})(schema || (schema = {}));
|
||||
// Type reference
|
||||
var schema;
|
||||
(function (_schema) {
|
||||
function createValidator8(schema) {
|
||||
return undefined;
|
||||
}
|
||||
_schema.createValidator8 = createValidator8;
|
||||
})(schema || (schema = {}));
|
||||
var schema;
|
||||
(function (schema) {
|
||||
var T = (function () {
|
||||
function T() {
|
||||
}
|
||||
Object.defineProperty(T.prototype, "createValidator9", {
|
||||
get: function () {
|
||||
return undefined;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(T.prototype, "createValidator10", {
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return T;
|
||||
})();
|
||||
schema.T = T;
|
||||
})(schema || (schema = {}));
|
||||
|
||||
|
||||
//// [isDeclarationVisibleNodeKinds.d.ts]
|
||||
declare module schema {
|
||||
function createValidator1(schema: any): <T>(data: T) => T;
|
||||
}
|
||||
declare module schema {
|
||||
function createValidator2(schema: any): new <T>(data: T) => T;
|
||||
}
|
||||
declare module schema {
|
||||
function createValidator3(schema: any): number | {
|
||||
new <T>(data: T): T;
|
||||
};
|
||||
}
|
||||
declare module schema {
|
||||
function createValidator4(schema: any): {
|
||||
new <T>(data: T): T;
|
||||
}[];
|
||||
}
|
||||
declare module schema {
|
||||
function createValidator5(schema: any): {
|
||||
new <T>(data: T): T;
|
||||
};
|
||||
}
|
||||
declare module schema {
|
||||
function createValidator6(schema: any): [new <T>(data: T) => T, number];
|
||||
}
|
||||
declare module schema {
|
||||
function createValidator7(schema: any): (new <T>(data: T) => T)[];
|
||||
}
|
||||
declare module schema {
|
||||
function createValidator8(schema: any): Array<{
|
||||
<T>(data: T): T;
|
||||
}>;
|
||||
}
|
||||
declare module schema {
|
||||
class T {
|
||||
createValidator9: <T>(data: T) => T;
|
||||
createValidator10: <T>(data: T) => T;
|
||||
}
|
||||
}
|
||||
168
tests/baselines/reference/isDeclarationVisibleNodeKinds.types
Normal file
168
tests/baselines/reference/isDeclarationVisibleNodeKinds.types
Normal file
@ -0,0 +1,168 @@
|
||||
=== tests/cases/compiler/isDeclarationVisibleNodeKinds.ts ===
|
||||
|
||||
// Function types
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator1(schema: any): <T>(data: T) => T {
|
||||
>createValidator1 : (schema: any) => <T>(data: T) => T
|
||||
>schema : any
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
// Constructor types
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator2(schema: any): new <T>(data: T) => T {
|
||||
>createValidator2 : (schema: any) => new <T>(data: T) => T
|
||||
>schema : any
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
// union types
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator3(schema: any): number | { new <T>(data: T): T; } {
|
||||
>createValidator3 : (schema: any) => number | (new <T>(data: T) => T)
|
||||
>schema : any
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
// Array types
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator4(schema: any): { new <T>(data: T): T; }[] {
|
||||
>createValidator4 : (schema: any) => (new <T>(data: T) => T)[]
|
||||
>schema : any
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TypeLiterals
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator5(schema: any): { new <T>(data: T): T } {
|
||||
>createValidator5 : (schema: any) => new <T>(data: T) => T
|
||||
>schema : any
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
// Tuple types
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator6(schema: any): [ new <T>(data: T) => T, number] {
|
||||
>createValidator6 : (schema: any) => [new <T>(data: T) => T, number]
|
||||
>schema : any
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
// Paren Types
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator7(schema: any): (new <T>(data: T)=>T )[] {
|
||||
>createValidator7 : (schema: any) => (new <T>(data: T) => T)[]
|
||||
>schema : any
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
// Type reference
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export function createValidator8(schema: any): Array<{ <T>(data: T) : T}> {
|
||||
>createValidator8 : (schema: any) => (<T>(data: T) => T)[]
|
||||
>schema : any
|
||||
>Array : T[]
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module schema {
|
||||
>schema : typeof schema
|
||||
|
||||
export class T {
|
||||
>T : T
|
||||
|
||||
get createValidator9(): <T>(data: T) => T {
|
||||
>createValidator9 : <T>(data: T) => T
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
set createValidator10(v: <T>(data: T) => T) {
|
||||
>createValidator10 : <T>(data: T) => T
|
||||
>v : <T>(data: T) => T
|
||||
>T : T
|
||||
>data : T
|
||||
>T : T
|
||||
>T : T
|
||||
}
|
||||
}
|
||||
}
|
||||
71
tests/cases/compiler/isDeclarationVisibleNodeKinds.ts
Normal file
71
tests/cases/compiler/isDeclarationVisibleNodeKinds.ts
Normal file
@ -0,0 +1,71 @@
|
||||
// @declaration: true
|
||||
// @target: es5
|
||||
|
||||
// Function types
|
||||
module schema {
|
||||
export function createValidator1(schema: any): <T>(data: T) => T {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Constructor types
|
||||
module schema {
|
||||
export function createValidator2(schema: any): new <T>(data: T) => T {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// union types
|
||||
module schema {
|
||||
export function createValidator3(schema: any): number | { new <T>(data: T): T; } {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Array types
|
||||
module schema {
|
||||
export function createValidator4(schema: any): { new <T>(data: T): T; }[] {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TypeLiterals
|
||||
module schema {
|
||||
export function createValidator5(schema: any): { new <T>(data: T): T } {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Tuple types
|
||||
module schema {
|
||||
export function createValidator6(schema: any): [ new <T>(data: T) => T, number] {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Paren Types
|
||||
module schema {
|
||||
export function createValidator7(schema: any): (new <T>(data: T)=>T )[] {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Type reference
|
||||
module schema {
|
||||
export function createValidator8(schema: any): Array<{ <T>(data: T) : T}> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module schema {
|
||||
export class T {
|
||||
get createValidator9(): <T>(data: T) => T {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
set createValidator10(v: <T>(data: T) => T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user