Cannot declare Schema as a function return type in typescript
#1.094 aberto em 11 de jan. de 2021
Métricas do repositório
- Stars
- (2.025 estrelas)
- Métricas de merge de PR
- (Nenhuma PRs mesclada em 30d)
Description
import { Schema } from "dynamoose"; export function MySchema() : Schema { return new Schema({id: String, name: String}); }
For the above code the typescript compiler throws 2 errors "'Schema' refers to a value, but is being used as a type here. Did you mean 'typeof Schema'?", and "Return type of exported function has or is using private name 'Schema'".
import * as dynamoose from "dynamoose"; export function MySchema() : dynamoose.Schema { return new dynamoose.Schema({id: String, name: String}); }
For the above code the typescript compiler throws 2 errors "Cannot find namespace 'dynamoose'", and "Return type of exported function has or is using private name 'dynamoose'".
The behavior I would expect is that this would not be an error. I had observed this with typescript version 3.5, which prompted me to upgrade to version 4.1.3, where I see the same behavior. I am using version 2.5.0 of the dynamoose package.