Skip to content
Open
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
25 changes: 15 additions & 10 deletions internal/compiler/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil
return
}

if e.emitOnly != EmitOnlyForcedDts && (options.NoEmit == core.TSTrue || e.host.IsEmitBlocked(declarationFilePath)) {
e.emitResult.EmitSkipped = true
return
}

if e.tr != nil {
defer e.tr.Push(tracing.PhaseEmit, "emitDeclarationFileOrBundle", map[string]any{"declarationFilePath": declarationFilePath}, true)()
}
Expand All @@ -230,7 +225,21 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil
defer putEmitContext()
sourceFile, diags := e.runDeclarationTransformers(emitContext, sourceFile, declarationFilePath, declarationMapPath)

// !!! strada skipped emit if there were diagnostics
for _, elem := range diags {
// Add declaration transform diagnostics to emit diagnostics
e.emitterDiagnostics.Add(elem)
}

if e.emitOnly != EmitOnlyForcedDts && (options.NoEmit == core.TSTrue || e.host.IsEmitBlocked(declarationFilePath)) {
e.emitResult.EmitSkipped = true
return
}

declBlocked := len(diags) > 0 && e.emitOnly != EmitOnlyForcedDts
if declBlocked {
e.emitResult.EmitSkipped = true
return
}

printerOptions := printer.PrinterOptions{
RemoveComments: options.RemoveComments.IsTrue(),
Expand All @@ -252,10 +261,6 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil
// !!!
}, emitContext)

for _, elem := range diags {
// Add declaration transform diagnostics to emit diagnostics
e.emitterDiagnostics.Add(elem)
}
e.printSourceFile(declarationFilePath, declarationMapPath, sourceFile, printer, e.emitOnly != EmitOnlyForcedDts && shouldEmitDeclarationSourceMaps(options, sourceFile))
}

Expand Down
23 changes: 19 additions & 4 deletions internal/execute/incremental/emitfileshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,28 @@ func (h *emitFilesHandler) emitAllAffectedFiles(options compiler.EmitOptions) *c
if options.TargetSourceFile != nil {
// Result from cache
diagnostics, _ := h.program.snapshot.emitDiagnosticsPerFile.Load(options.TargetSourceFile.Path())
return &compiler.EmitResult{
diags := diagnostics.getDiagnostics(h.program.program, options.TargetSourceFile)
result := &compiler.EmitResult{
EmitSkipped: true,
Diagnostics: diagnostics.getDiagnostics(h.program.program, options.TargetSourceFile),
Diagnostics: diags,
}
Comment on lines 53 to 60
h.updateHasEmitDiagnostics(result)
return result
}
for _, result := range results {
h.updateHasEmitDiagnostics(result)
}
return compiler.CombineEmitResults(results)
} else {
// Combine results and update buildInfo
result := compiler.CombineEmitResults(results)
h.updateHasEmitDiagnostics(result)
h.emitBuildInfo(options, result)
return result
}
} else if !h.isForDtsErrors {
result := h.program.program.Emit(h.ctx, h.getEmitOptions(options))
h.updateHasEmitDiagnostics(result)
h.updateSnapshot()
h.emitBuildInfo(options, result)
return result
Expand All @@ -76,12 +84,19 @@ func (h *emitFilesHandler) emitAllAffectedFiles(options compiler.EmitOptions) *c
Diagnostics: h.program.program.GetDeclarationDiagnostics(h.ctx, options.TargetSourceFile),
}
if len(result.Diagnostics) != 0 {
h.updateHasEmitDiagnostics(result)
h.program.snapshot.hasEmitDiagnostics = true
}
return result
}
}

func (h *emitFilesHandler) updateHasEmitDiagnostics(result *compiler.EmitResult) {
if result != nil && len(result.Diagnostics) != 0 {
h.hasEmitDiagnostics.Store(true)
}
}

func (h *emitFilesHandler) emitBuildInfo(options compiler.EmitOptions, result *compiler.EmitResult) {
buildInfoResult := h.program.emitBuildInfo(h.ctx, options)
if buildInfoResult != nil {
Expand Down Expand Up @@ -132,6 +147,7 @@ func (h *emitFilesHandler) emitFilesIncremental(options compiler.EmitOptions) []
Diagnostics: h.program.program.GetDeclarationDiagnostics(h.ctx, affectedFile),
}
}
h.updateHasEmitDiagnostics(result)

// Update the pendingEmit for the file
h.emitUpdates.Store(path, &emitUpdate{pendingKind: getPendingEmitKind(emitKind, pendingKind), result: result})
Expand Down Expand Up @@ -199,8 +215,6 @@ func (h *emitFilesHandler) getEmitOptions(options compiler.EmitOptions) compiler
if h.skipDtsOutputOfComposite(options.TargetSourceFile, fileName, text, data, emitSignature, &differsOnlyInMap) {
return nil
}
} else if len(data.Diagnostics) > 0 {
h.hasEmitDiagnostics.Store(true)
}
}

Expand Down Expand Up @@ -317,6 +331,7 @@ func emitFiles(ctx context.Context, program *Program, options compiler.EmitOptio
// Single file emit - do direct from program
if !isForDtsErrors && options.TargetSourceFile != nil {
result := program.program.Emit(ctx, emitHandler.getEmitOptions(options))
emitHandler.updateHasEmitDiagnostics(result)
if ctx.Err() != nil {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@ export function isString(value) {
export function isExplicitString(value) {
return typeof value === "string";
}


//// [isolatedDeclarationsTypePredicate.d.ts]
export declare function isString(value: unknown): value is string;
export declare function isExplicitString(value: unknown): value is string;
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,5 @@ const a = x.a;
const b = x.b;


//// [x.d.ts]
export {};
//// [y.d.ts]
export {};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,3 @@ function foo<T>(arr: T[], depth: number) {
function foo(arr, depth) {
return flat(arr, depth);
}


//// [arrayFakeFlatNoCrashInferenceDeclarations.d.ts]
type BadFlatArray<Arr, Depth extends number> = {
obj: {
"done": Arr;
"recur": Arr extends ReadonlyArray<infer InnerArr> ? BadFlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]> : Arr;
}[Depth extends -1 ? "done" : "recur"];
}["obj"];
declare function flat<A, D extends number = 1>(arr: A, depth?: D): BadFlatArray<A, D>[];
declare function foo<T>(arr: T[], depth: number): any;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,41 +88,3 @@ function ns() { return { v: 0 }; }
export const o9 = {
[ns().v]: 1
};


//// [computedPropertiesNarrowed.d.ts]
export declare let o: {
1: number;
};
export declare let o2: {
0: number;
};
export declare let o3: {
[1]: number;
};
export declare let o31: {
[-1]: number;
};
export declare let o32: {
[x: number]: number;
};
export declare let o4: {
[x: symbol]: number;
};
export declare let o5: {
[x: symbol]: number;
};
declare const uu: unique symbol;
export declare let o6: {
[uu]: number;
};
export declare let o7: {
1: number;
};
export declare const o8: {
1: number;
};
export declare const o9: {
0: number;
};
export {};
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,3 @@ const foo_1 = require("foo");
const root_1 = require("root");
exports.x = (0, foo_1.foo)();
exports.y = (0, root_1.bar)();


//// [entry.d.ts]
export declare const x: any;
export declare const y: import("root").RootProps;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@ export type Type = {
[Foo.sym]: 0;
};
};
//// [index.d.ts]
export declare const foo: {
x?: {
[Foo.sym]: 0;
};
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ export type Type = {
};
};
export {};
//// [index.d.ts]
export declare const foo: {
x?: {
[Foo.sym]: 0;
};
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,3 @@ interface I {
}
export declare function f(): I;
export {};
//// [b.d.ts]
export declare function q(): void;
export declare namespace q {
var val: I;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,3 @@ type AX = {
};
export declare const A: AX;
export {};
//// [b.d.ts]
export declare const A1: {
readonly A: unique symbol;
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (false) {
exports.myClass = 0;
}


//// [declarationEmitInvalidExport.d.ts]
export type MyClass = typeof myClass;
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,3 @@ const trpc = server_1.initTRPC.create();
exports.middleware = trpc.middleware;
exports.router = trpc.router;
exports.publicProcedure = trpc.procedure;


//// [index.d.ts]
export declare const middleware: <TNewParams extends Record<string, any>>(fn: import("@trpc/server/middleware").MiddlewareFunction<{
_config: import("@trpc/server/internals/config").RootConfig<{
errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape<import("@trpc/server/internals/utils").ErrorFormatter<object, import("@trpc/server/internals/utils").DefaultErrorShape<{}>>>;
}>;
}, TNewParams>) => import("@trpc/server/middleware").MiddlewareBuilder<{
_config: import("@trpc/server/internals/config").RootConfig<{
errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape<import("@trpc/server/internals/utils").ErrorFormatter<object, import("@trpc/server/internals/utils").DefaultErrorShape<{}>>>;
}>;
}, TNewParams>;
export declare const router: {};
export declare const publicProcedure: {};

This file was deleted.

Loading
Loading