Fix class extends t (#315)
This commit is contained in:
Родитель
02141ec9ba
Коммит
4c67999669
|
@ -385,15 +385,14 @@ export function createChecker(program: Program) {
|
|||
}
|
||||
}
|
||||
|
||||
const type: ModelType = createType({
|
||||
return createType({
|
||||
kind: 'Model',
|
||||
name: node.kind === SyntaxKind.ModelStatement ? node.id.sv : '',
|
||||
node: node,
|
||||
properties,
|
||||
baseModels: baseModels
|
||||
});
|
||||
|
||||
return type;
|
||||
|
||||
} else {
|
||||
// model =
|
||||
// this will likely have to change, as right now `model =` is really just
|
||||
|
@ -416,9 +415,14 @@ export function createChecker(program: Program) {
|
|||
}
|
||||
|
||||
function checkClassHeritage(heritage: ReferenceExpression[]): ModelType[] {
|
||||
return heritage.map(heritageRef => {
|
||||
return heritage.flatMap(heritageRef => {
|
||||
const heritageType = getTypeForNode(heritageRef);
|
||||
|
||||
if (heritageType.kind === "TemplateParameter") {
|
||||
// don't need to track heritage for template parameters.
|
||||
return [];
|
||||
}
|
||||
|
||||
if (heritageType.kind !== "Model") {
|
||||
throwDiagnostic("Models must extend other models.", heritageRef);
|
||||
}
|
||||
|
|
|
@ -689,6 +689,7 @@ export function visitChildren<T>(node: Types.Node, cb: NodeCb<T>): T | undefined
|
|||
return visitEach(cb, node.decorators) ||
|
||||
visitNode(cb, node.id) ||
|
||||
visitEach(cb, node.templateParameters) ||
|
||||
visitEach(cb, node.heritage) ||
|
||||
visitNode(cb, node.assignment) ||
|
||||
visitEach(cb, node.properties);
|
||||
case Types.SyntaxKind.NamedImport:
|
||||
|
|
Загрузка…
Ссылка в новой задаче