Skip to content

Emits undefined for unknown types in declaration file #7173

@tjoskar

Description

@tjoskar

TypeScript Version:

1.7.5 / nightly (1.9.0-dev.20160221)

Code

Lets say I want to export some empty arrays:

// test.ts
export default {
  foo: [],
  bar: [],
  baz: []
}

and I want to generate a definition file for it:

> tsc test.ts --module commonjs -d

Expected behavior:

declare var _default: {
    foo: any[];
    bar: any[];
    baz: any[];
};
export default _default;

I expect the type to be any since the compiler don't know anything about the type.

Actual behavior:

declare var _default: {
    foo: undefined[];
    bar: undefined[];
    baz: undefined[];
};
export default _default;

Instead, I get undefined which is an invalid type (Error: can not find name 'undefined').

This seems like a bug?

Thanks and keep up the good work, I can't wait for version 2.0.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions