Skip to content

Commit

Permalink
chore(snc): fix some snc errors in transpile-module.ts (#5748)
Browse files Browse the repository at this point in the history
  • Loading branch information
alicewriteswrongs committed May 10, 2024
1 parent 9d967c8 commit a84be26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/compiler/transformers/static-to-meta/visitor.ts
Expand Up @@ -13,7 +13,7 @@ export const convertStaticToMeta = (
compilerCtx: d.CompilerCtx,
buildCtx: d.BuildCtx,
typeChecker: ts.TypeChecker,
collection: d.CollectionCompilerMeta,
collection: d.CollectionCompilerMeta | null,
transformOpts: d.TransformOptions,
): ts.TransformerFactory<ts.SourceFile> => {
return (transformCtx) => {
Expand Down
14 changes: 7 additions & 7 deletions src/compiler/transpile/transpile-module.ts
Expand Up @@ -111,15 +111,15 @@ export const transpileModule = (
const program = ts.createProgram([sourceFilePath], tsCompilerOptions, compilerHost);
const typeChecker = program.getTypeChecker();

const transformers: ts.CustomTransformers = {
const transformers = {
before: [
convertDecoratorsToStatic(config, buildCtx.diagnostics, typeChecker, program),
performAutomaticKeyInsertion,
updateStencilCoreImports(transformOpts.coreImportPath),
],
after: [convertStaticToMeta(config, compilerCtx, buildCtx, typeChecker, null, transformOpts)],
afterDeclarations: [],
};
afterDeclarations: [] as (ts.CustomTransformerFactory | ts.TransformerFactory<ts.SourceFile | ts.Bundle>)[],
} satisfies ts.CustomTransformers;

if (config.transformAliasedImportPaths) {
transformers.before.push(rewriteAliasedSourceFileImportPaths);
Expand All @@ -146,7 +146,7 @@ export const transpileModule = (

program.emit(undefined, undefined, undefined, false, transformers);

const tsDiagnostics = [...program.getSyntacticDiagnostics()];
const tsDiagnostics = [...program.getSyntacticDiagnostics()] as ts.Diagnostic[];

if (config.validateTypes) {
tsDiagnostics.push(...program.getOptionsDiagnostics());
Expand All @@ -156,15 +156,15 @@ export const transpileModule = (

results.diagnostics.push(...buildCtx.diagnostics);

results.moduleFile = compilerCtx.moduleMap.get(results.sourceFilePath);
results.moduleFile = compilerCtx.moduleMap.get(results.sourceFilePath)!;

return results;
};

const getScriptTargetKind = (transformOpts: d.TransformOptions) => {
const target = transformOpts.target && transformOpts.target.toUpperCase();
if (isNumber((ts.ScriptTarget as any)[target])) {
return (ts.ScriptTarget as any)[target];
if (isNumber((ts.ScriptTarget as any)[target as string])) {
return (ts.ScriptTarget as any)[target as string];
}
// ESNext and Latest are the same
return ts.ScriptTarget.Latest;
Expand Down

0 comments on commit a84be26

Please sign in to comment.