Skip to content
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

chore(snc): fix some snc errors in transpile-module.ts #5748

Merged
merged 1 commit into from
May 10, 2024
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
2 changes: 1 addition & 1 deletion src/compiler/transformers/static-to-meta/visitor.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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