-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Description
The error relates to enums, and exports using the new typescript node resolution (with the typings property in the package.json). I have tested this on typescript@next.
The bug can be reproduced through the following scenario: (please go to https://github.com/christyharagan/typeScript-enum-export-bug to find this code):
Three projects: a
, b
, c
.
b
depends on a
c
depends on b
a
exports an enum through its index.ts:
export enum E{}
b
then exports a function that returns E
through its index.ts:
import {E} from 'a'
export function f():E {
return null
}
c
then consumes f
through its index.ts:
import {E} from 'a'
import {f} from 'b'
let e:E = f()
There is now an error for e
:
Type 'E' is not assignable to type 'E'.
All three packages have a package.json that looks like this:
{
"name": "b",
"version": "1",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"dependencies": {
"a": "1"
}
}
And a tsconfig.json that looks like:
{
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"rootDir": "./src",
"target": "es5",
"outDir": "./lib"
},
"files": [
"src/index.ts"
]
}
Furthermore, this defect occurs if f
were to export another symbol (e.g. an interface) which references an exported enum somewhere within it's structure or hierarchy.
This only seems to affect enums, not other types.