Skip to content

Emit 'object' type in declaration emitter #13505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler/declarationEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ namespace ts {
case SyntaxKind.StringKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.ObjectKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.UndefinedKeyword:
Expand Down
8 changes: 8 additions & 0 deletions tests/baselines/reference/nonPrimitiveAsProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ var b: WithNonPrimitive = {foo: "bar"}; // expect error
//// [nonPrimitiveAsProperty.js]
var a = { foo: { bar: "bar" } };
var b = { foo: "bar" }; // expect error


//// [nonPrimitiveAsProperty.d.ts]
interface WithNonPrimitive {
foo: object;
}
declare var a: WithNonPrimitive;
declare var b: WithNonPrimitive;
8 changes: 8 additions & 0 deletions tests/baselines/reference/nonPrimitiveInFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ function returnError() {
var ret = 123;
return ret; // expect error
}


//// [nonPrimitiveInFunction.d.ts]
declare function takeObject(o: object): void;
declare function returnObject(): object;
declare var nonPrimitive: object;
declare var primitive: boolean;
declare function returnError(): object;
18 changes: 18 additions & 0 deletions tests/baselines/reference/nonPrimitiveInGeneric.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,21 @@ var x; // error
var y; // ok
var z; // ok
var u; // ok


//// [nonPrimitiveInGeneric.d.ts]
declare function generic<T>(t: T): void;
declare var a: {};
declare var b: string;
declare function bound<T extends object>(t: T): void;
declare function bound2<T extends object>(): void;
declare function bound3<T extends {}>(t: T): void;
interface Proxy<T extends object> {
}
declare var x: Proxy<number>;
declare var y: Proxy<null>;
declare var z: Proxy<undefined>;
interface Blah {
foo: number;
}
declare var u: Proxy<Blah>;
5 changes: 5 additions & 0 deletions tests/baselines/reference/nonPrimitiveUnionIntersection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ var a = ""; // error
var b = ""; // ok
a = b; // error
b = a; // ok


//// [nonPrimitiveUnionIntersection.d.ts]
declare var a: object & string;
declare var b: object | string;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @declaration: true
interface WithNonPrimitive {
foo: object
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @declaration: true
function takeObject(o: object) {}
function returnObject(): object {
return {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @declaration: true
function generic<T>(t: T) {
var o: object = t; // expect error
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @declaration: true
var a: object & string = ""; // error
var b: object | string = ""; // ok
a = b; // error
Expand Down