-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Do not expand type references in keyof and index access #58715
Changes from 1 commit
3928d9b
c5d6841
96f5b35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//// [tests/cases/compiler/declarationEmitAliasInlineing.ts] //// | ||
|
||
//// [a.ts] | ||
type O = { | ||
prop: string | ||
prop2: string | ||
} | ||
|
||
type I = { | ||
prop: string | ||
} | ||
|
||
export const fn = (v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {}; | ||
|
||
//// [aExp.ts] | ||
export type O = { | ||
prop: string | ||
prop2: string | ||
} | ||
|
||
export type I = { | ||
prop: string | ||
} | ||
|
||
export const fnExp = (v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {}; | ||
|
||
//// [b.ts] | ||
import {fn} from './a' | ||
import {fnExp} from './aExp' | ||
export const f = fn; | ||
export const fExp = fnExp; | ||
|
||
//// [a.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fn = void 0; | ||
var fn = function (v, p, key, p2) { }; | ||
exports.fn = fn; | ||
//// [aExp.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fnExp = void 0; | ||
var fnExp = function (v, p, key, p2) { }; | ||
exports.fnExp = fnExp; | ||
//// [b.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fExp = exports.f = void 0; | ||
var a_1 = require("./a"); | ||
var aExp_1 = require("./aExp"); | ||
exports.f = a_1.fn; | ||
exports.fExp = aExp_1.fnExp; | ||
|
||
|
||
//// [a.d.ts] | ||
type O = { | ||
prop: string; | ||
prop2: string; | ||
}; | ||
type I = { | ||
prop: string; | ||
}; | ||
export declare const fn: (v: O["prop"], p: Omit<O, "prop">, key: keyof O, p2: Omit<O, keyof I>) => void; | ||
export {}; | ||
//// [aExp.d.ts] | ||
export type O = { | ||
prop: string; | ||
prop2: string; | ||
}; | ||
export type I = { | ||
prop: string; | ||
}; | ||
export declare const fnExp: (v: O["prop"], p: Omit<O, "prop">, key: keyof O, p2: Omit<O, keyof I>) => void; | ||
//// [b.d.ts] | ||
export declare const f: (v: string, p: Omit<{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit surprised we don't emit this as export declare const f: typeof import("./a").fn; since we're willing to emit the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
prop: string; | ||
prop2: string; | ||
}, "prop">, key: keyof { | ||
prop: string; | ||
prop2: string; | ||
}, p2: Omit<{ | ||
prop: string; | ||
prop2: string; | ||
}, "prop">) => void; | ||
export declare const fExp: (v: import("./aExp").O["prop"], p: Omit<import("./aExp").O, "prop">, key: keyof import("./aExp").O, p2: Omit<import("./aExp").O, keyof import("./aExp").I>) => void; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//// [tests/cases/compiler/declarationEmitAliasInlineing.ts] //// | ||
|
||
=== a.ts === | ||
type O = { | ||
>O : Symbol(O, Decl(a.ts, 0, 0)) | ||
|
||
prop: string | ||
>prop : Symbol(prop, Decl(a.ts, 0, 10)) | ||
|
||
prop2: string | ||
>prop2 : Symbol(prop2, Decl(a.ts, 1, 16)) | ||
} | ||
|
||
type I = { | ||
>I : Symbol(I, Decl(a.ts, 3, 1)) | ||
|
||
prop: string | ||
>prop : Symbol(prop, Decl(a.ts, 5, 10)) | ||
} | ||
|
||
export const fn = (v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {}; | ||
>fn : Symbol(fn, Decl(a.ts, 9, 12)) | ||
>v : Symbol(v, Decl(a.ts, 9, 19)) | ||
>O : Symbol(O, Decl(a.ts, 0, 0)) | ||
>p : Symbol(p, Decl(a.ts, 9, 32)) | ||
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) | ||
>O : Symbol(O, Decl(a.ts, 0, 0)) | ||
>key : Symbol(key, Decl(a.ts, 9, 52)) | ||
>O : Symbol(O, Decl(a.ts, 0, 0)) | ||
>p2 : Symbol(p2, Decl(a.ts, 9, 66)) | ||
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) | ||
>O : Symbol(O, Decl(a.ts, 0, 0)) | ||
>I : Symbol(I, Decl(a.ts, 3, 1)) | ||
|
||
=== aExp.ts === | ||
export type O = { | ||
>O : Symbol(O, Decl(aExp.ts, 0, 0)) | ||
|
||
prop: string | ||
>prop : Symbol(prop, Decl(aExp.ts, 0, 17)) | ||
|
||
prop2: string | ||
>prop2 : Symbol(prop2, Decl(aExp.ts, 1, 16)) | ||
} | ||
|
||
export type I = { | ||
>I : Symbol(I, Decl(aExp.ts, 3, 1)) | ||
|
||
prop: string | ||
>prop : Symbol(prop, Decl(aExp.ts, 5, 17)) | ||
} | ||
|
||
export const fnExp = (v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {}; | ||
>fnExp : Symbol(fnExp, Decl(aExp.ts, 9, 12)) | ||
>v : Symbol(v, Decl(aExp.ts, 9, 22)) | ||
>O : Symbol(O, Decl(aExp.ts, 0, 0)) | ||
>p : Symbol(p, Decl(aExp.ts, 9, 35)) | ||
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) | ||
>O : Symbol(O, Decl(aExp.ts, 0, 0)) | ||
>key : Symbol(key, Decl(aExp.ts, 9, 55)) | ||
>O : Symbol(O, Decl(aExp.ts, 0, 0)) | ||
>p2 : Symbol(p2, Decl(aExp.ts, 9, 69)) | ||
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) | ||
>O : Symbol(O, Decl(aExp.ts, 0, 0)) | ||
>I : Symbol(I, Decl(aExp.ts, 3, 1)) | ||
|
||
=== b.ts === | ||
import {fn} from './a' | ||
>fn : Symbol(fn, Decl(b.ts, 0, 8)) | ||
|
||
import {fnExp} from './aExp' | ||
>fnExp : Symbol(fnExp, Decl(b.ts, 1, 8)) | ||
|
||
export const f = fn; | ||
>f : Symbol(f, Decl(b.ts, 2, 12)) | ||
>fn : Symbol(fn, Decl(b.ts, 0, 8)) | ||
|
||
export const fExp = fnExp; | ||
>fExp : Symbol(fExp, Decl(b.ts, 3, 12)) | ||
>fnExp : Symbol(fnExp, Decl(b.ts, 1, 8)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
//// [tests/cases/compiler/declarationEmitAliasInlineing.ts] //// | ||
|
||
=== a.ts === | ||
type O = { | ||
>O : O | ||
> : ^ | ||
|
||
prop: string | ||
>prop : string | ||
> : ^^^^^^ | ||
|
||
prop2: string | ||
>prop2 : string | ||
> : ^^^^^^ | ||
} | ||
|
||
type I = { | ||
>I : I | ||
> : ^ | ||
|
||
prop: string | ||
>prop : string | ||
> : ^^^^^^ | ||
} | ||
|
||
export const fn = (v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {}; | ||
>fn : (v: O["prop"], p: Omit<O, "prop">, key: keyof O, p2: Omit<O, keyof I>) => void | ||
> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ | ||
>(v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {} : (v: O["prop"], p: Omit<O, "prop">, key: keyof O, p2: Omit<O, keyof I>) => void | ||
> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ | ||
>v : string | ||
> : ^^^^^^ | ||
>p : Omit<O, "prop"> | ||
> : ^^^^^^^^^^^^^^^ | ||
>key : keyof O | ||
> : ^^^^^^^ | ||
>p2 : Omit<O, "prop"> | ||
> : ^^^^^^^^^^^^^^^ | ||
|
||
=== aExp.ts === | ||
export type O = { | ||
>O : O | ||
> : ^ | ||
|
||
prop: string | ||
>prop : string | ||
> : ^^^^^^ | ||
|
||
prop2: string | ||
>prop2 : string | ||
> : ^^^^^^ | ||
} | ||
|
||
export type I = { | ||
>I : I | ||
> : ^ | ||
|
||
prop: string | ||
>prop : string | ||
> : ^^^^^^ | ||
} | ||
|
||
export const fnExp = (v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {}; | ||
>fnExp : (v: O["prop"], p: Omit<O, "prop">, key: keyof O, p2: Omit<O, keyof I>) => void | ||
> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ | ||
>(v: O['prop'], p: Omit<O, 'prop'>, key: keyof O, p2: Omit<O, keyof I>) => {} : (v: O["prop"], p: Omit<O, "prop">, key: keyof O, p2: Omit<O, keyof I>) => void | ||
> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ | ||
>v : string | ||
> : ^^^^^^ | ||
>p : Omit<O, "prop"> | ||
> : ^^^^^^^^^^^^^^^ | ||
>key : keyof O | ||
> : ^^^^^^^ | ||
>p2 : Omit<O, "prop"> | ||
> : ^^^^^^^^^^^^^^^ | ||
|
||
=== b.ts === | ||
import {fn} from './a' | ||
>fn : (v: string, p: Omit<{ prop: string; prop2: string; }, "prop">, key: keyof { prop: string; prop2: string; }, p2: Omit<{ prop: string; prop2: string; }, "prop">) => void | ||
> : ^ ^^^^^^^^^^ ^^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^^^^^ ^^^^^^^^^ | ||
|
||
import {fnExp} from './aExp' | ||
>fnExp : (v: import("aExp").O["prop"], p: Omit<import("aExp").O, "prop">, key: keyof import("aExp").O, p2: Omit<import("aExp").O, keyof import("aExp").I>) => void | ||
> : ^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^^^ ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^^^^ | ||
|
||
export const f = fn; | ||
>f : (v: string, p: Omit<{ prop: string; prop2: string; }, "prop">, key: keyof { prop: string; prop2: string; }, p2: Omit<{ prop: string; prop2: string; }, "prop">) => void | ||
> : ^ ^^^^^^^^^^ ^^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^^^^^ ^^^^^^^^^ | ||
>fn : (v: string, p: Omit<{ prop: string; prop2: string; }, "prop">, key: keyof { prop: string; prop2: string; }, p2: Omit<{ prop: string; prop2: string; }, "prop">) => void | ||
> : ^ ^^^^^^^^^^ ^^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^ ^^ ^^^^^^^^ ^^^^^^^^^ ^^^ ^^^^^^ ^^^^^^^^^ | ||
|
||
export const fExp = fnExp; | ||
>fExp : (v: import("aExp").O["prop"], p: Omit<import("aExp").O, "prop">, key: keyof import("aExp").O, p2: Omit<import("aExp").O, keyof import("aExp").I>) => void | ||
> : ^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^^^ ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^^^^ | ||
>fnExp : (v: import("aExp").O["prop"], p: Omit<import("aExp").O, "prop">, key: keyof import("aExp").O, p2: Omit<import("aExp").O, keyof import("aExp").I>) => void | ||
> : ^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^^^ ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^^^^ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the explicit fallbacks needed with the automatic fallback added in #58720?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. You are right. Better to lean on the new fallback mechanism. As it currently is we could end up trying to print the type two times (when we fail). Pushed the change