Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1217,14 +1217,18 @@ namespace ts {

const previousNeedsDeclare = needsDeclare;
switch (input.kind) {
case SyntaxKind.TypeAliasDeclaration: // Type aliases get `declare`d if need be (for legacy support), but that's all
return cleanup(factory.updateTypeAliasDeclaration(
case SyntaxKind.TypeAliasDeclaration: {
needsDeclare = false;
const clean = cleanup(factory.updateTypeAliasDeclaration(
input,
ensureModifiers(input),
input.name,
visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration),
visitNode(input.type, visitDeclarationSubtree, isTypeNode)
));
needsDeclare = previousNeedsDeclare;
return clean;
}
case SyntaxKind.InterfaceDeclaration: {
return cleanup(factory.updateInterfaceDeclaration(
input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.__esModule = true;


//// [DeclarationErrorsNoEmitOnError.d.ts]
declare type T = {
type T = {
x: number;
};
export interface I {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export declare function wrapClass(param: any): {
foo(): any;
};
};
export declare type Constructor<T = {}> = new (...args: any[]) => T;
export type Constructor<T = {}> = new (...args: any[]) => T;
export declare function Timestamped<TBase extends Constructor>(Base: TBase): {
new (...args: any[]): {
timestamp: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ exports.Broken = Broken;


//// [types.d.ts]
export declare type Merge<T, U> = T & U;
export type Merge<T, U> = T & U;
//// [type-a.d.ts]
export declare type TypeA = {
export type TypeA = {
a: string;
};
//// [type-b.d.ts]
import { Merge } from './types';
import { TypeA } from './type-a';
export declare type TypeB = Merge<TypeA, {
export type TypeB = Merge<TypeA, {
b: string;
}>;
//// [index.d.ts]
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/circularAccessorAnnotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ declare const c3: {
get foo(): string;
set foo(value: typeof c3.foo);
};
declare type T1 = {
type T1 = {
get foo(): T1["foo"];
};
declare type T2 = {
type T2 = {
set foo(value: T2["foo"]);
};
declare type T3 = {
type T3 = {
get foo(): string;
set foo(value: T3["foo"]);
};
4 changes: 2 additions & 2 deletions tests/baselines/reference/circularBaseTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function f(m) {


//// [circularBaseTypes.d.ts]
declare type M<T> = {
type M<T> = {
value: T;
};
interface M2 extends M<M3> {
}
declare type M3 = M2[keyof M2];
type M3 = M2[keyof M2];
declare function f(m: M3): any;
4 changes: 2 additions & 2 deletions tests/baselines/reference/circularIndexedAccessErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ function foo() {


//// [circularIndexedAccessErrors.d.ts]
declare type T1 = {
type T1 = {
x: T1["x"];
};
declare type T2<K extends "x" | "y"> = {
type T2<K extends "x" | "y"> = {
x: T2<K>[K];
y: number;
};
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/coAndContraVariantInferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ call(actionB, printFn);


//// [coAndContraVariantInferences.d.ts]
declare type A = {
type A = {
kind: 'a';
};
declare type B = {
type B = {
kind: 'b';
};
declare const a: A;
Expand Down
Loading