fix immediate bug
This commit is contained in:
Родитель
6c2c434c31
Коммит
a2a5a91a1f
|
@ -165,9 +165,11 @@ export function createBinder(): Binder {
|
|||
|
||||
currentFile.namespaces.push(statement);
|
||||
|
||||
if (!statement.statements) {
|
||||
if (statement.statements === undefined) {
|
||||
currentFile.exports = statement.exports!;
|
||||
scope = currentNamespace = statement;
|
||||
} else if (!Array.isArray(statement.statements)) {
|
||||
scope = currentNamespace = statement;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +203,7 @@ function hasScope(node: Node): node is ScopeNode {
|
|||
case SyntaxKind.ModelStatement:
|
||||
return true;
|
||||
case SyntaxKind.NamespaceStatement:
|
||||
return true;
|
||||
return Array.isArray(node.statements);
|
||||
case SyntaxKind.ADLScript:
|
||||
return true;
|
||||
default:
|
||||
|
|
|
@ -57,7 +57,7 @@ describe("namespaces with blocks", () => {
|
|||
strictEqual(Z.properties.size, 2, "has two properties");
|
||||
});
|
||||
|
||||
it.only("merges like namespaces across files", async () => {
|
||||
it("merges like namespaces across files", async () => {
|
||||
testHost.addAdlFile(
|
||||
"a.adl",
|
||||
`
|
||||
|
@ -168,7 +168,12 @@ describe("blockless namespaces", () => {
|
|||
}
|
||||
`
|
||||
);
|
||||
await testHost.compile("./");
|
||||
try {
|
||||
await testHost.compile("./");
|
||||
} catch (e) {
|
||||
console.log(e.diagnostics);
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it("binds correctly", async () => {
|
||||
|
@ -220,4 +225,32 @@ describe("blockless namespaces", () => {
|
|||
ok(M.namespace);
|
||||
strictEqual(M.namespace, N);
|
||||
});
|
||||
|
||||
it("works with nested blockless and blockfull namespaces", async () => {
|
||||
testHost.addAdlFile(
|
||||
"a.adl",
|
||||
`
|
||||
@test
|
||||
namespace N.M;
|
||||
|
||||
@test
|
||||
namespace O {
|
||||
model A { }
|
||||
}
|
||||
`
|
||||
);
|
||||
testHost.addAdlFile(
|
||||
"b.adl",
|
||||
`
|
||||
model X { a: N.M.O.A }
|
||||
`
|
||||
);
|
||||
const { M, O } = (await testHost.compile("/")) as {
|
||||
M: NamespaceType;
|
||||
O: NamespaceType;
|
||||
};
|
||||
|
||||
ok(M.namespace);
|
||||
strictEqual(O.namespace, M);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче