diff --git a/src/visitors/typescript/generates.ts b/src/visitors/typescript/generates.ts index f258e3c9..76bbe5f2 100644 --- a/src/visitors/typescript/generates.ts +++ b/src/visitors/typescript/generates.ts @@ -288,6 +288,8 @@ export function generateTsType(valueExpr: any, toCreate?: boolean) { return toCreate ? 'Date | Literal' : 'Date'; } else if (valueExpr?.datatype === ns.xsd('string')) { return toCreate ? 'string | Literal' : 'string'; + } else if (valueExpr?.datatype === ns.xsd('language')) { + return toCreate ? 'string | Literal' : 'string'; } else if (valueExpr?.datatype) { return valueExpr?.datatype; } else if (typeof valueExpr === 'string') { diff --git a/test/__snapshots__/generate.test.ts.snap b/test/__snapshots__/generate.test.ts.snap index f23f4df0..e9045eb7 100644 --- a/test/__snapshots__/generate.test.ts.snap +++ b/test/__snapshots__/generate.test.ts.snap @@ -701,6 +701,7 @@ export const cryptocurrency = new Shape< export type BasicContainerShape = { id: string; // the url of a node of this shape + description: string; // Gives a description for the resource contains?: ResourceShape | ResourceShape[]; // Contains these Resources size: number; // Size of Container mtime: number; // Time of Container creation created @@ -714,6 +715,7 @@ export type BasicContainerShape = { export type BasicContainerShapeCreateArgs = { id?: string | NamedNode; // the url to match or create the node with e.g. 'https://example.com#this', 'https://example.com/profile/card#me' + description: string | Literal; // Gives a description for the resource contains?: | URL | NamedNode @@ -762,6 +764,7 @@ export enum ResourceShapeType { export enum BasicContainerShapeContext { type = 'rdf:type', + description = 'terms:description', contains = 'ldp:contains', size = 'st:size', mtime = 'st:mtime', @@ -788,6 +791,8 @@ ldp:BasicContainerShape EXTRA a { // rdfs:comment \\"Defines the node as a Container\\" ; a [ ldp:Container ] // rdfs:comment \\"Defines the node as a Container\\" ; + terms:description xsd:language + // rdfs:comment \\"Gives a description for the resource\\" ; ldp:contains @ldp:ResourceShape * // rdfs:comment \\"Contains these Resources\\" ; st:size xsd:integer diff --git a/test/shapes/ldpShapes.shex b/test/shapes/ldpShapes.shex index 4210a27b..3c20dae2 100644 --- a/test/shapes/ldpShapes.shex +++ b/test/shapes/ldpShapes.shex @@ -10,6 +10,8 @@ ldp:BasicContainerShape EXTRA a { // rdfs:comment "Defines the node as a Container" ; a [ ldp:Container ] // rdfs:comment "Defines the node as a Container" ; + terms:description xsd:language + // rdfs:comment "Gives a description for the resource" ; ldp:contains @ldp:ResourceShape * // rdfs:comment "Contains these Resources" ; st:size xsd:integer