Skip to content

Commit

Permalink
fix: update warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
cpylua committed Mar 29, 2019
1 parent 510e4ca commit d22ddb9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"*.js": ["yarn format", "eslint", "git add"],
"*.{ts,tsx}": ["yarn format", "tslint --format stylish --project packages/zent/tsconfig.json", "git add"],
"packages/zent/src/*.{ts,tsx}": ["yarn format", "tslint --format stylish --project packages/zent/tsconfig.json", "git add"],
"packages/zent/scripts/cruiser/*.{ts,tsx}": ["yarn format", "tslint --format stylish --project packages/zent/scripts/cruiser/tsconfig.json", "git add"],
"*.scss": ["yarn format", "sass-lint -vq", "git add"]
}
14 changes: 5 additions & 9 deletions packages/zent/scripts/cruiser/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function tsort(edges: Graph): string[] {
};

// 1. build data structures
edges.forEach(function(v) {
edges.forEach(v => {
const from = v[0];
const to = v[1];
if (!nodes[from]) nodes[from] = new Node(from);
Expand All @@ -147,19 +147,15 @@ function tsort(edges: Graph): string[] {

visited[idstr] = true;

node.afters.forEach(function(afterID) {
node.afters.forEach(afterID => {
const ances = ancestors as string[];

if (ances.indexOf(afterID) >= 0)
if (ances.indexOf(afterID) >= 0) {
// if already in ancestors, a closed chain exists.
throw new Error('closed chain : ' + afterID + ' is in ' + id);
}

visit(
afterID.toString(),
ances.map(function(v) {
return v;
})
); // recursive call
visit(afterID.toString(), ances.map(v => v)); // recursive call
});

sorted.unshift(id);
Expand Down
14 changes: 7 additions & 7 deletions packages/zent/scripts/cruiser/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface IRegistry {
[key: string]: { exports: Set<ValueExport>; dependencies: Set<string> };
}

interface SourceFile extends ts.SourceFile {
interface ISourceFile extends ts.SourceFile {
imports?: ts.StringLiteral[];
}

Expand Down Expand Up @@ -82,7 +82,7 @@ function parseValueExports(
* Excludes export ... from './x'
*/
function getModuleLocalExportedValueNames(
sourceFile: SourceFile
sourceFile: ISourceFile
): Set<ValueExport> {
const exportedVariables = new Set<ValueExport>();
sourceFile.statements.forEach(stmt => {
Expand Down Expand Up @@ -124,7 +124,7 @@ function getModuleLocalExportedValueNames(
* 4. imports of 1,2,3
*/
function getModuleValueNames(
sourceFile: SourceFile,
sourceFile: ISourceFile,
cwd: string,
registry: IRegistry,
exportedLocalVariables: Set<ValueExport>
Expand Down Expand Up @@ -207,7 +207,7 @@ function getModuleValueNames(
* 4. re-exports of 1,2,3 from other modules
*/
function getModuleValueExportNames(
sourceFile: SourceFile,
sourceFile: ISourceFile,
cwd: string,
registry: IRegistry,
localValueVariables: Set<ValueExport>
Expand All @@ -216,7 +216,7 @@ function getModuleValueExportNames(
sourceFile.statements.forEach(stmt => {
if (ts.isVariableStatement(stmt)) {
// export const A = 1
if (isNodeExported((<unknown>stmt) as ts.Declaration)) {
if (isNodeExported((stmt as unknown) as ts.Declaration)) {
const vars = getVariableNames(stmt.declarationList.declarations);
for (const v of vars) {
if (localValueVariables.has(v)) {
Expand Down Expand Up @@ -278,7 +278,7 @@ function getModuleValueExportNames(
} else if (stmt.moduleSpecifier) {
console.warn(
chalk.yellow(
`Named export '${propertyName}' not found in module ${dependentModulePath}`
`Named export '${propertyName}' not found in module ${dependentModulePath}\nYou can safely ignore this warning if it is an exported type`
)
);
}
Expand Down Expand Up @@ -384,7 +384,7 @@ function getBindingNames(
/**
* Parse a module
*/
function createSourceFile(filename: string): SourceFile {
function createSourceFile(filename: string): ISourceFile {
/** ts.CompilerHost */
const compilerHost = {
fileExists: () => true,
Expand Down

0 comments on commit d22ddb9

Please sign in to comment.