Handel TypeLiterals, ParenTypes, UnionTypes, and ArrayTypes

This commit is contained in:
Mohamed Hegazy 2014-11-30 11:47:41 -08:00
parent 9ed27b23ab
commit 0246daec83
10 changed files with 318 additions and 107 deletions

View File

@ -1617,13 +1617,18 @@ module ts {
case SyntaxKind.Constructor:
case SyntaxKind.ConstructSignature:
case SyntaxKind.ConstructorType:
case SyntaxKind.CallSignature:
case SyntaxKind.FunctionType:
case SyntaxKind.IndexSignature:
case SyntaxKind.Parameter:
case SyntaxKind.ModuleBlock:
case SyntaxKind.TypeParameter:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.TypeLiteral:
case SyntaxKind.ArrayType:
case SyntaxKind.TupleType:
case SyntaxKind.UnionType:
case SyntaxKind.ParenType:
return isDeclarationVisible(node.parent);
// Source file is always visible

View File

@ -1,22 +0,0 @@
//// [constructorTypeDeclarations.ts]
module schema {
export function createValidator(schema: any): new <T>(data: T) => T {
return undefined;
}
}
//// [constructorTypeDeclarations.js]
var schema;
(function (_schema) {
function createValidator(schema) {
return undefined;
}
_schema.createValidator = createValidator;
})(schema || (schema = {}));
//// [constructorTypeDeclarations.d.ts]
declare module schema {
function createValidator(schema: any): new <T>(data: T) => T;
}

View File

@ -1,17 +0,0 @@
=== tests/cases/compiler/constructorTypeDeclarations.ts ===
module schema {
>schema : typeof schema
export function createValidator(schema: any): new <T>(data: T) => T {
>createValidator : (schema: any) => new <T>(data: T) => T
>schema : any
>T : T
>data : T
>T : T
>T : T
return undefined;
>undefined : undefined
}
}

View File

@ -1,26 +0,0 @@
//// [functionTypeDeclarations.ts]
module schema {
export function createValidator(schema: any): <T>(data: T) => T {
return <T>(data: T) => {
return data;
}
}
}
//// [functionTypeDeclarations.js]
var schema;
(function (_schema) {
function createValidator(schema) {
return function (data) {
return data;
};
}
_schema.createValidator = createValidator;
})(schema || (schema = {}));
//// [functionTypeDeclarations.d.ts]
declare module schema {
function createValidator(schema: any): <T>(data: T) => T;
}

View File

@ -1,24 +0,0 @@
=== tests/cases/compiler/functionTypeDeclarations.ts ===
module schema {
>schema : typeof schema
export function createValidator(schema: any): <T>(data: T) => T {
>createValidator : (schema: any) => <T>(data: T) => T
>schema : any
>T : T
>data : T
>T : T
>T : T
return <T>(data: T) => {
><T>(data: T) => { return data; } : <T>(data: T) => T
>T : T
>data : T
>T : T
return data;
>data : T
}
}
}

View File

@ -0,0 +1,139 @@
//// [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;
}
}
//// [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 = {}));
//// [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)[];
}

View File

@ -0,0 +1,121 @@
=== 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
}
}

View File

@ -1,7 +0,0 @@
// @declaration: true
module schema {
export function createValidator(schema: any): new <T>(data: T) => T {
return undefined;
}
}

View File

@ -1,9 +0,0 @@
// @declaration: true
module schema {
export function createValidator(schema: any): <T>(data: T) => T {
return <T>(data: T) => {
return data;
}
}
}

View File

@ -0,0 +1,51 @@
// @declaration: true
// 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;
}
}