since i updated the angular cli and nestjs versions I am getting hundreds of warnings that my custom type definitions and interfaces can not be found. But my nestjs api still works fine.
i am exporting my interface like this
export interface Role {...}
and getting this warning
WARNING in ./apps/api/src/app/users/dto/update-user.dto.ts 31:75-80
"export 'Role' was not found in '@project/api-datatypes'
my import looks like this
import { Role } from '@project/api-datatypes';
what was changed in the latest version and what do I have to do to fix those warnings?
currently i am running the following versions:
├── @angular/[email protected]
├── @nestjs/[email protected]
├── [email protected]
├── [email protected]
└── [email protected]
Use a named export to export a type in TypeScript, e.g. export type Person = {} . The exported type can be imported by using a named import as import {Person} from './another-file' . You can have as many named exports as necessary in a single file.
Use named exports to export multiple classes in TypeScript, e.g. export class A {} and export class B {} . The exported classes can be imported by using a named import as import {A, B} from './another-file' . You can have as many named exports as necessary in a file.
The "export default was not found" error occurs when we try to import as default from a module that doesn't have a default export. To solve the error, make sure the module has a named export and wrap the import in curly braces, e.g. import {myFunction} from './myModule' .
TypeScript supports export = to model the traditional CommonJS and AMD workflow. The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.
just found the solution, since typescript 3.8 introduced type-only exports/import, I need to write import type { Role } from '@project/api-datatypes';
so a simple "type"
was missing
see link: https://medium.com/javascript-in-plain-english/leveraging-type-only-imports-and-exports-with-typescript-3-8-5c1be8bd17fb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With