Description
TypeScript Version: nightly (2.4.0-dev.20170516)
Code
These are excerpts that illustrate why it's weird:
dev-tools/globals.js
/** @typedef {{[k: string]: any}} AnyObject */
sim/dex-data.js
/** @typedef {{[k: string]: any}} AnyEffect */
sim/dex.js
/** @type {AnyObject} */
let a; // this isn't an error
/** @type {AnyEffect} */
let b; // this IS an error
tsconfig.json
{
"include": [
"./dev-tools/globals.ts",
"./sim/dex-data.js",
"./sim/dex.js"
]
}
These are excerpts that explain why this behavior is so weird, but the real reason why it works this way is probably in the rest of the code, which you can see for yourself in: https://github.com/Zarel/Pokemon-Showdown/tree/149ca3759c141085d2f473fc9fdc5da5371ef32c
Expected behavior:
No error, or perhaps two errors.
Actual behavior:
sim/dex.js(3,12): error TS2304: Cannot find name 'AnyEffect'.
It's actually massively confusing to me how to access types defined in other files (I've googled and can't find any documentation on it). The general impression I get is that in modern TypeScript versions, in .ts
files, you just export them and import them and they'll work normally, but still nothing on how to do it in .js
files.
But either way, this seems like a bug.
(I tried moving the AnyEffect
typedef from sim/dex-data.js
to dev-tools/globals.js
and I still get an error for it but not AnyObject
, so there is almost certainly something weird going on here.)