dem icon indicating copy to clipboard operation
dem copied to clipboard

Problem with dem ensure

Open A2va opened this issue 3 years ago • 0 comments

When i use dem ensure for this project and I started the code. I got Uncaught SyntaxError: The requested module './vendor/https/jspm.dev/typescript/lib/typescript.js' does not provide an export named 'default'

So I looked the code and the hasDefaultExport function return false even if a module a export default. I rewrite the code to get working but that's my first step with typescript and I think my code could be better.

Here is the full function

export function hasDefaultExport(body: string): boolean {
  const sourceFile = ts.createSourceFile("", body, ts.ScriptTarget.ES2020);
  let hasDefault = false;
  sourceFile.forEachChild((node: ts.Node) => {
    if(ts.isExportDeclaration(node)){
      const exportClause: ts.NamedExports = node.exportClause as ts.NamedExports;
      if(exportClause !== undefined){
        hasDefault = hasDefault || (exportClause.elements[0].name.escapedText as string === 'default');
      }
    }
  });
  return hasDefault;
}

A2va avatar Jul 17 '21 15:07 A2va