From 9ed27b23aba2356d5dff855dc28639727ed7529e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sun, 30 Nov 2014 11:04:15 -0800 Subject: [PATCH] Handel assert for missing node kind in isDeclarationVisible for functionType and constructorType --- src/compiler/checker.ts | 2 ++ .../reference/constructorTypeDeclarations.js | 22 ++++++++++++++++ .../constructorTypeDeclarations.types | 17 ++++++++++++ .../reference/functionTypeDeclarations.js | 26 +++++++++++++++++++ .../reference/functionTypeDeclarations.types | 24 +++++++++++++++++ .../compiler/constructorTypeDeclarations.ts | 7 +++++ .../compiler/functionTypeDeclarations.ts | 9 +++++++ 7 files changed, 107 insertions(+) create mode 100644 tests/baselines/reference/constructorTypeDeclarations.js create mode 100644 tests/baselines/reference/constructorTypeDeclarations.types create mode 100644 tests/baselines/reference/functionTypeDeclarations.js create mode 100644 tests/baselines/reference/functionTypeDeclarations.types create mode 100644 tests/cases/compiler/constructorTypeDeclarations.ts create mode 100644 tests/cases/compiler/functionTypeDeclarations.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6afbbcdd510..dacca9b07d8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1617,7 +1617,9 @@ 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: diff --git a/tests/baselines/reference/constructorTypeDeclarations.js b/tests/baselines/reference/constructorTypeDeclarations.js new file mode 100644 index 00000000000..7b983a69bde --- /dev/null +++ b/tests/baselines/reference/constructorTypeDeclarations.js @@ -0,0 +1,22 @@ +//// [constructorTypeDeclarations.ts] + +module schema { + export function createValidator(schema: any): new (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 (data: T) => T; +} diff --git a/tests/baselines/reference/constructorTypeDeclarations.types b/tests/baselines/reference/constructorTypeDeclarations.types new file mode 100644 index 00000000000..34bd6166650 --- /dev/null +++ b/tests/baselines/reference/constructorTypeDeclarations.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/constructorTypeDeclarations.ts === + +module schema { +>schema : typeof schema + + export function createValidator(schema: any): new (data: T) => T { +>createValidator : (schema: any) => new (data: T) => T +>schema : any +>T : T +>data : T +>T : T +>T : T + + return undefined; +>undefined : undefined + } +} diff --git a/tests/baselines/reference/functionTypeDeclarations.js b/tests/baselines/reference/functionTypeDeclarations.js new file mode 100644 index 00000000000..34408f74b58 --- /dev/null +++ b/tests/baselines/reference/functionTypeDeclarations.js @@ -0,0 +1,26 @@ +//// [functionTypeDeclarations.ts] + +module schema { + export function createValidator(schema: any): (data: T) => T { + return (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): (data: T) => T; +} diff --git a/tests/baselines/reference/functionTypeDeclarations.types b/tests/baselines/reference/functionTypeDeclarations.types new file mode 100644 index 00000000000..1118444fdf4 --- /dev/null +++ b/tests/baselines/reference/functionTypeDeclarations.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/functionTypeDeclarations.ts === + +module schema { +>schema : typeof schema + + export function createValidator(schema: any): (data: T) => T { +>createValidator : (schema: any) => (data: T) => T +>schema : any +>T : T +>data : T +>T : T +>T : T + + return (data: T) => { +>(data: T) => { return data; } : (data: T) => T +>T : T +>data : T +>T : T + + return data; +>data : T + } + } +} diff --git a/tests/cases/compiler/constructorTypeDeclarations.ts b/tests/cases/compiler/constructorTypeDeclarations.ts new file mode 100644 index 00000000000..48d6f884632 --- /dev/null +++ b/tests/cases/compiler/constructorTypeDeclarations.ts @@ -0,0 +1,7 @@ +// @declaration: true + +module schema { + export function createValidator(schema: any): new (data: T) => T { + return undefined; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/functionTypeDeclarations.ts b/tests/cases/compiler/functionTypeDeclarations.ts new file mode 100644 index 00000000000..e0d7c7cdbf4 --- /dev/null +++ b/tests/cases/compiler/functionTypeDeclarations.ts @@ -0,0 +1,9 @@ +// @declaration: true + +module schema { + export function createValidator(schema: any): (data: T) => T { + return (data: T) => { + return data; + } + } +} \ No newline at end of file