schematics-utilities icon indicating copy to clipboard operation
schematics-utilities copied to clipboard

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

Open ofirrifo opened this issue 4 years ago • 2 comments

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

ofirrifo avatar Jun 15 '20 13:06 ofirrifo

same here

polonmedia avatar Aug 14 '20 13:08 polonmedia

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.

flobiber avatar Aug 20 '20 00:08 flobiber