nitayneeman / schematics-utilities

🛠️ Useful exported utilities for working with Schematics
https://nitayneeman.github.io/schematics-utilities
MIT License
87 stars 9 forks source link

type script exception after upgrade to "typescript": "~3.8.2" #28

Open ofirrifo opened 4 years ago

ofirrifo commented 4 years ago

After I upgrade from "typescript": "~3.5.3" to "typescript": "~3.8.2" I start to get the following error:

src/schematics-utils/schematics.utils.ts:39:33 - error TS2345: Argument of type 'import("/../node_modules/typescript/lib/typescript").SourceFile' is not assignable to parameter of type 'import("/../node_modules/schematics-utilities/node_modules/@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript").SourceFile'.
  Types of property 'kind' are incompatible.
    Type 'import("/../node_modules/typescript/lib/typescript").SyntaxKind.SourceFile' is not assignable to type 'import("/../node_modules/schematics-utilities/node_modules/@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript").SyntaxKind.SourceFile'.

39     const change = insertImport(sourceFile, pathFileToEdit, importSymbolName, importPath, isDefault) as InsertChange;
                                   ~~~~~~~~~~

I have a utils imports in my code

import * as ts from 'typescript';
import { InsertChange, insertImport } from 'schematics-utilities';
}

in case I'm replace the type ts.SourceFile to any the build work but I want to keep the type I think it happen since the

polonmedia commented 4 years ago

same here

flobiber commented 4 years ago

With cast to any it will build but it doesn't work as excepted. Always added imports, also if there are already there (Seems like the SourceFile analysis isn't working correct).

For me, i just copied the relevant parts into my project - now everything is working.