-
Notifications
You must be signed in to change notification settings - Fork 12.8k
type export issue #23280
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
Comments
From @waitingsong on April 7, 2018 3:17 If change export interface Config {
keys: string
news: {
pageSize: number;
};
} without sub object news, then issue gone export interface Config {
keys: string
// news: {
// pageSize: number;
// };
} |
From @waitingsong on April 7, 2018 3:46 maybe bug of TypeScript ? |
Simplified repro: export interface I { x: number; }
export type J = I; b.ts import { J } from './a';
export const f = (): J => ({ x: 0 }); Result:
No error when using @weswigham May be related to recent declaration emit changes? |
I don't think so; this is a visibility error, and the mechanics of those didn't change with the emitter rewrite; we're probably just not considering alias visibility when attempting to write |
Nope, looks like this was a bug way back in |
So probably just another longstanding bug in |
Riiiiight, so this isn't strictly a bug but it's not strictly desired behavior either. Type aliases aren't currently considered aliases of something because they can do things like this: // @declaration: true
// @filename: a.ts
export interface I<T> { x: T; }
export type J = I<any>;
// @filename: b.ts
import { J } from './a';
export const f = (): J => ({ x: 0 }); note how the type alias is an instantiation of the type. Another: // @declaration: true
// @filename: a.ts
export interface I<T> { x: T; }
export type J<Q> = I<Q>;
// @filename: b.ts
import { J } from './a';
export const f = (): J<number> => ({ x: 0 }); in this case it forwards a type parameter. @mhegazy is this worth special-casing? |
Hmmm... on the other hand, in both cases (the OP and @Andy-MS 's example) there's explicitly a reference to the alias somewhere in the types the make up the expression - we probably aught to be writing the output type using that rather than what the alias resolves to anyway; this may just be a symptom of eager alias resolution, endemic of how we treat type aliases. |
@mhegazy This is honestly a little different. (Though that would incidentally fix the issue in the OP.) In this case, we're opting not to write out the type as the user wrote it (ie, with an alias) and we issue a visibility error because of it. And we write out the type that way because we forgot the alias ever existed. 🤷♀️ |
Maintaining the alias is a different issue. do not think we have a simple or clear fix for this one. so i would say that part is a design limitation. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
From @waitingsong on April 7, 2018 3:12
Issue Type: Bug
tsconfig.json
package.json
config/config.default.ts
config.local.ts
got error:
if change to `"declaration": false,``` , then issue gone.
any suggestion ?
VS Code version: Code 1.21.1 (79b44aa704ce542d8ca4a3cc44cfca566e7720f1, 2018-03-14T14:46:47.128Z)
OS version: Windows_NT x64 6.1.7601
System Info
Copied from original issue: microsoft/vscode#47374
The text was updated successfully, but these errors were encountered: