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

fix: fix idraw dts issue #326

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
fix: fix idraw dts issue
  • Loading branch information
chenshenhai committed Jun 9, 2024
commit e80e0330548eb2b3953869b3f8d3a9cafd4e07be
5 changes: 3 additions & 2 deletions packages/idraw/src/idraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ export class iDraw {
store.destroy();
}

getViewCenter() {
getViewCenter(): PointSize {
const { viewScaleInfo, viewSizeInfo } = this.getViewInfo();
return calcViewCenter({ viewScaleInfo, viewSizeInfo });
const pointSize: PointSize = calcViewCenter({ viewScaleInfo, viewSizeInfo });
return pointSize;
}

$onBoardWatcherEvents() {
Expand Down
20 changes: 19 additions & 1 deletion scripts/build-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ts from 'typescript';
import { Project } from 'ts-morph';
import type { CompilerOptions } from 'ts-morph';
import path from 'path';
import fs from 'fs';
import * as glob from 'glob';
import { packages } from './config';
import { joinPackagePath } from './util/project';
Expand All @@ -18,10 +19,28 @@ async function build() {
console.log(`Remove packages/${dirName}/dist/`);
removeFullDir(`${pkgDir}/dist`);
buildPackage(dirName);
checkPackageDts(dirName);
console.log(`Build ESM of ${dirName} successfully!`);
}
}

function checkPackageDts(dirName: string) {
console.log(`Checking dts files for ${dirName} ...`);
const pattern = '**/*.js';
const cwd = joinPackagePath(dirName, 'dist');
const files = glob.sync(pattern, { cwd });

for (let i = 0; i < files.length; i++) {
const jsFilePath = files[i];
const dtsFilePath = jsFilePath.replace(/.js$/, '.d.ts');
const dtsAbsolutePath = path.join(cwd, dtsFilePath);
if (!(fs.existsSync(dtsAbsolutePath) && fs.statSync(dtsAbsolutePath).isFile())) {
throw Error(`ERROR: lack ${dirName}/dist/${dtsFilePath} `);
}
}
console.log(`Check dts files of ${dirName} successfully!`);
}

function buildPackage(dirName: string) {
const pattern = '**/*.ts';
const cwd = joinPackagePath(dirName, 'src');
Expand All @@ -37,7 +56,6 @@ function buildPackage(dirName: string) {
// const compilerOptions = tsConfig.compilerOptions;
const compilerOptions: CompilerOptions = {
noUnusedLocals: true,

declaration: true,
sourceMap: false,
target: ts.ScriptTarget.ES2015,
Expand Down