diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2e975397c1a49..d74df308d34d5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8589,6 +8589,28 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node)); } + function tryVisitTypeReference(node: TypeReferenceNode) { + if (canReuseTypeNode(context, node)) { + const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context); + const typeArguments = visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode); + + if (!introducesError) { + const updated = factory.updateTypeReferenceNode( + node, + newName, + typeArguments, + ); + return setTextRange(context, updated, node); + } + else { + const serializedName = serializeTypeName(context, node.typeName, /*isTypeOf*/ false, typeArguments); + if (serializedName) { + return setTextRange(context, serializedName, node.typeName); + } + } + } + } + function visitExistingNodeTreeSymbolsWorker(node: Node): Node | undefined { if (isJSDocTypeExpression(node)) { // Unwrap JSDocTypeExpressions @@ -8681,7 +8703,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (canReuseTypeNode(context, node)) { return node; } - return serializeExistingTypeNode(context, node); + hadError = true; + return node; } if (isTypeParameterDeclaration(node)) { return factory.updateTypeParameterDeclaration( @@ -8692,27 +8715,23 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode), ); } + + if (isIndexedAccessTypeNode(node) && isTypeReferenceNode(node.objectType)) { + const objectType = tryVisitTypeReference(node.objectType); + if (!objectType) { + hadError = true; + return node; + } + return factory.updateIndexedAccessTypeNode(node, objectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode)!); + } + if (isTypeReferenceNode(node)) { - if (canReuseTypeNode(context, node)) { - const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context); - const typeArguments = visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode); - - if (!introducesError) { - const updated = factory.updateTypeReferenceNode( - node, - newName, - typeArguments, - ); - return setTextRange(context, updated, node); - } - else { - const serializedName = serializeTypeName(context, node.typeName, /*isTypeOf*/ false, typeArguments); - if (serializedName) { - return setTextRange(context, serializedName, node.typeName); - } - } + const result = tryVisitTypeReference(node); + if (result) { + return result; } - return serializeExistingTypeNode(context, node); + hadError = true; + return node; } if (isLiteralImportTypeNode(node)) { const nodeSymbol = getNodeLinks(node).resolvedSymbol; @@ -8765,7 +8784,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (serializedName) { return setTextRange(context, serializedName, node.exprName); } - return serializeExistingTypeNode(context, node); + hadError = true; + return node; } return factory.updateTypeQueryNode( node, @@ -8837,9 +8857,22 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ); } - if (isTypeOperatorNode(node) && node.operator === SyntaxKind.UniqueKeyword && node.type.kind === SyntaxKind.SymbolKeyword) { - if (!canReuseTypeNode(context, node)) { - return serializeExistingTypeNode(context, node); + if (isTypeOperatorNode(node)) { + if (node.operator === SyntaxKind.UniqueKeyword && node.type.kind === SyntaxKind.SymbolKeyword) { + if (!canReuseTypeNode(context, node)) { + hadError = true; + return node; + } + } + else if (node.operator === SyntaxKind.KeyOfKeyword) { + if (isTypeReferenceNode(node.type)) { + const type = tryVisitTypeReference(node.type); + if (!type) { + hadError = true; + return node; + } + return factory.updateTypeOperatorNode(node, type); + } } } diff --git a/tests/baselines/reference/correlatedUnions.types b/tests/baselines/reference/correlatedUnions.types index cfab9eafdbf84..8c842614b3fcf 100644 --- a/tests/baselines/reference/correlatedUnions.types +++ b/tests/baselines/reference/correlatedUnions.types @@ -822,7 +822,7 @@ function ff1() { } function apply(funKey: K, ...args: ArgMap[K]) { >apply : (funKey: K, ...args: { sum: [a: number, b: number]; concat: [a: string, b: string, c: string]; }[K]) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^ ^^^^^ ^^^^^^^^^ ^^^^^^^^^^ ^^^ ^^^^^^^^^ +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^ ^^^^^ ^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^ >funKey : K > : ^ >args : { sum: [a: number, b: number]; concat: [a: string, b: string, c: string]; }[K] @@ -854,7 +854,7 @@ function ff1() { >apply('sum', 1, 2) : void > : ^^^^ >apply : (funKey: K, ...args: { sum: [a: number, b: number]; concat: [a: string, b: string, c: string]; }[K]) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^ ^^^^^ ^^^^^^^^^ ^^^^^^^^^^ ^^^ ^^^^^^^^^ +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^ ^^^^^ ^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^ >'sum' : "sum" > : ^^^^^ >1 : 1 @@ -868,7 +868,7 @@ function ff1() { >apply('concat', 'str1', 'str2', 'str3' ) : void > : ^^^^ >apply : (funKey: K, ...args: { sum: [a: number, b: number]; concat: [a: string, b: string, c: string]; }[K]) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^ ^^^^^ ^^^^^^^^^ ^^^^^^^^^^ ^^^ ^^^^^^^^^ +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^ ^^ ^^^^^ ^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^ >'concat' : "concat" > : ^^^^^^^^ >'str1' : "str1" diff --git a/tests/baselines/reference/declarationEmitAliasInlineing.js b/tests/baselines/reference/declarationEmitAliasInlineing.js new file mode 100644 index 0000000000000..73ad5be9da142 --- /dev/null +++ b/tests/baselines/reference/declarationEmitAliasInlineing.js @@ -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, key: keyof O, p2: Omit) => {}; + +//// [aExp.ts] +export type O = { + prop: string + prop2: string +} + +export type I = { + prop: string +} + +export const fnExp = (v: O['prop'], p: Omit, key: keyof O, p2: Omit) => {}; + +//// [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, key: keyof O, p2: Omit) => 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, key: keyof O, p2: Omit) => void; +//// [b.d.ts] +export declare const f: (v: string, p: Omit<{ + 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, key: keyof import("./aExp").O, p2: Omit) => void; diff --git a/tests/baselines/reference/declarationEmitAliasInlineing.symbols b/tests/baselines/reference/declarationEmitAliasInlineing.symbols new file mode 100644 index 0000000000000..0aea42299b0ca --- /dev/null +++ b/tests/baselines/reference/declarationEmitAliasInlineing.symbols @@ -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, key: keyof O, p2: Omit) => {}; +>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, key: keyof O, p2: Omit) => {}; +>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)) + diff --git a/tests/baselines/reference/declarationEmitAliasInlineing.types b/tests/baselines/reference/declarationEmitAliasInlineing.types new file mode 100644 index 0000000000000..a03f57311a4ee --- /dev/null +++ b/tests/baselines/reference/declarationEmitAliasInlineing.types @@ -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, key: keyof O, p2: Omit) => {}; +>fn : (v: O["prop"], p: Omit, key: keyof O, p2: Omit) => void +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ +>(v: O['prop'], p: Omit, key: keyof O, p2: Omit) => {} : (v: O["prop"], p: Omit, key: keyof O, p2: Omit) => void +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ +>v : string +> : ^^^^^^ +>p : Omit +> : ^^^^^^^^^^^^^^^ +>key : keyof O +> : ^^^^^^^ +>p2 : Omit +> : ^^^^^^^^^^^^^^^ + +=== 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, key: keyof O, p2: Omit) => {}; +>fnExp : (v: O["prop"], p: Omit, key: keyof O, p2: Omit) => void +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ +>(v: O['prop'], p: Omit, key: keyof O, p2: Omit) => {} : (v: O["prop"], p: Omit, key: keyof O, p2: Omit) => void +> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^ +>v : string +> : ^^^^^^ +>p : Omit +> : ^^^^^^^^^^^^^^^ +>key : keyof O +> : ^^^^^^^ +>p2 : Omit +> : ^^^^^^^^^^^^^^^ + +=== 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, key: keyof import("aExp").O, p2: Omit) => 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, key: keyof import("aExp").O, p2: Omit) => void +> : ^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^^^ ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^^^^ +>fnExp : (v: import("aExp").O["prop"], p: Omit, key: keyof import("aExp").O, p2: Omit) => void +> : ^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^ ^^ ^^ ^^^^^^ ^^^ ^^ ^^^^^^ ^ ^^^^^^ ^ ^^^^^^^^^ + diff --git a/tests/baselines/reference/indexedAccessTypeConstraints.types b/tests/baselines/reference/indexedAccessTypeConstraints.types index 29721e2e95ce5..37ae427a5985e 100644 --- a/tests/baselines/reference/indexedAccessTypeConstraints.types +++ b/tests/baselines/reference/indexedAccessTypeConstraints.types @@ -57,7 +57,7 @@ export class Foo extends Parent> { >this.getData().get('content') : C > : ^ >this.getData().get : (prop: K) => IData[K] -> : ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ >this.getData() : Data> > : ^^^^^^^^^^^^^^ >this.getData : () => Data> @@ -67,7 +67,7 @@ export class Foo extends Parent> { >getData : () => Data> > : ^^^^^^ ^^^^^^^^ >get : (prop: K) => IData[K] -> : ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ >'content' : "content" > : ^^^^^^^^^ } @@ -87,7 +87,7 @@ export class Bar> extends Parent { >this.getData().get('content') : T["content"] > : ^^^^^^^^^^^^ >this.getData().get : (prop: K) => T[K] -> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ >this.getData() : Data > : ^^^^^^^ >this.getData : () => Data @@ -97,7 +97,7 @@ export class Bar> extends Parent { >getData : () => Data > : ^^^^^^ ^ >get : (prop: K) => T[K] -> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ >'content' : "content" > : ^^^^^^^^^ } diff --git a/tests/baselines/reference/inferTypes1.types b/tests/baselines/reference/inferTypes1.types index 23e9586745ede..0ff301c695b54 100644 --- a/tests/baselines/reference/inferTypes1.types +++ b/tests/baselines/reference/inferTypes1.types @@ -690,7 +690,7 @@ const result = invoker('test', true)({ test: (a: boolean) => 123 }) >invoker('test', true)({ test: (a: boolean) => 123 }) : number > : ^^^^^^ >invoker('test', true) : any>>(obj: T) => ReturnType -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ ^ ^^^^^^ +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ ^^^^^^^^^ >invoker : (key: K, ...args: A) => any>>(obj: T) => ReturnType > : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ ^^ ^^^^^^ ^^^^^^^^^ ^^ ^^ ^^^^^ >'test' : "test" diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types index 624fa6d54aa31..42c12d8a39538 100644 --- a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types @@ -46,8 +46,8 @@ const v = chain({a: 1, b: 2}).mapValues(square).value(); > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >chain({a: 1, b: 2}).mapValues(square) : Chainable<{ a: number; b: number; }> > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->chain({a: 1, b: 2}).mapValues : (func: (v: number) => U) => Chainable<{ [k in keyof { a: number; b: number; }]: U; }> -> : ^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^ +>chain({a: 1, b: 2}).mapValues : (func: (v: number) => U) => Chainable<{ [k in "a" | "b"]: U; }> +> : ^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ >chain({a: 1, b: 2}) : Chainable<{ a: number; b: number; }> > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >chain : (t: T) => Chainable @@ -62,8 +62,8 @@ const v = chain({a: 1, b: 2}).mapValues(square).value(); > : ^^^^^^ >2 : 2 > : ^ ->mapValues : (func: (v: number) => U) => Chainable<{ [k in keyof { a: number; b: number; }]: U; }> -> : ^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^ +>mapValues : (func: (v: number) => U) => Chainable<{ [k in "a" | "b"]: U; }> +> : ^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ >square : (x: number) => number > : ^ ^^ ^^^^^^^^^^^ >value : () => { a: number; b: number; } diff --git a/tests/baselines/reference/templateLiteralTypes4.types b/tests/baselines/reference/templateLiteralTypes4.types index ce1fb6e30e827..2b6c0f0ca409f 100644 --- a/tests/baselines/reference/templateLiteralTypes4.types +++ b/tests/baselines/reference/templateLiteralTypes4.types @@ -679,11 +679,11 @@ p.getIndex(0); // ok, 0 is a valid index >p.getIndex(0) : number > : ^^^^^^ >p.getIndex : (index: I) => FieldType["type"]> -> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^ >p : Point > : ^^^^^ >getIndex : (index: I) => FieldType["type"]> -> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^ >0 : 0 > : ^ @@ -691,11 +691,11 @@ p.getIndex(1); // ok, 1 is a valid index >p.getIndex(1) : number > : ^^^^^^ >p.getIndex : (index: I) => FieldType["type"]> -> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^ >p : Point > : ^^^^^ >getIndex : (index: I) => FieldType["type"]> -> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^ >1 : 1 > : ^ @@ -703,11 +703,11 @@ p.getIndex(2); // error, 2 is not a valid index >p.getIndex(2) : number > : ^^^^^^ >p.getIndex : (index: I) => FieldType["type"]> -> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^ >p : Point > : ^^^^^ >getIndex : (index: I) => FieldType["type"]> -> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^ ^ +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^ >2 : 2 > : ^ diff --git a/tests/baselines/reference/unionOfClassCalls.types b/tests/baselines/reference/unionOfClassCalls.types index f49f576b5f0fc..bf3e57779628d 100644 --- a/tests/baselines/reference/unionOfClassCalls.types +++ b/tests/baselines/reference/unionOfClassCalls.types @@ -33,11 +33,11 @@ switch (tmp.get('t')) { >tmp.get('t') : "A" | "B" > : ^^^^^^^^^ >tmp.get : ((k: K) => A[K]) | ((k: K) => B[K]) -> : ^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ ^ +> : ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ >tmp : Test | Test > : ^^^^^^^^^^^^^^^^^ >get : ((k: K) => A[K]) | ((k: K) => B[K]) -> : ^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^ ^ +> : ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ >'t' : "t" > : ^^^ diff --git a/tests/cases/compiler/declarationEmitAliasInlineing.ts b/tests/cases/compiler/declarationEmitAliasInlineing.ts new file mode 100644 index 0000000000000..c6f1934186dc5 --- /dev/null +++ b/tests/cases/compiler/declarationEmitAliasInlineing.ts @@ -0,0 +1,34 @@ +// @declaration: true +// @strict: true + +// @filename: a.ts +type O = { + prop: string + prop2: string +} + +type I = { + prop: string +} + +export const fn = (v: O['prop'], p: Omit, key: keyof O, p2: Omit) => {}; + +// @filename: aExp.ts + +export type O = { + prop: string + prop2: string +} + +export type I = { + prop: string +} + +export const fnExp = (v: O['prop'], p: Omit, key: keyof O, p2: Omit) => {}; + +// @filename: b.ts + +import {fn} from './a' +import {fnExp} from './aExp' +export const f = fn; +export const fExp = fnExp; \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForContextuallyTypedParameters.ts b/tests/cases/fourslash/quickInfoForContextuallyTypedParameters.ts index 219ed843923af..d394e147d7014 100644 --- a/tests/cases/fourslash/quickInfoForContextuallyTypedParameters.ts +++ b/tests/cases/fourslash/quickInfoForContextuallyTypedParameters.ts @@ -34,7 +34,7 @@ verify.quickInfos({ func?: Function; }, obj: T, key: "name"): "name"`, 4: `function foof(settings: (row: Error) => { - value: Error["name"]; + value: string; func?: Function; }, obj: Error, key: "name"): "name"` });