What YANG typedef Declares in a Module
Short answer
A A YANG typedef declares a custom reusable data type derived from a base type, such as a percent range of 0-100 that other leaves can adopt.
Question
Key Takeaways
YANG typedef creates a custom reusable data type by deriving a named type from a base type, often tightening it with a range such as 0-100. Option A is correct because typedef yields a type name that leaves and other declarations can reference. Lists, containers, and rpcs define schema structure and operations instead of datatypes, so they cannot serve that purpose.
Expert Analysis
Because a YANG typedef binds a name to a derived type built on an existing base type, it is the only statement among the four that matches what the keyword actually declares in a module.
Option B misassigns the grouping that carries instance-level order and key constraints: the list statement declares repeating entries such as interface or route records, each with its own key leaf and min-elements/max-elements behavior, so it produces data instances rather than a type name. Option C likewise names a structure, not a datatype — a container scopes a subtree of nodes and gives the data tree its nesting, and it never yields something a leaf can be typed with. Option D claims the remote procedure construct, where rpc defines an operation name, its input and output groupings, and the operation's effects on the device; an rpc has no type identity to reuse. Read against a YANG module, these three statements all introduce schema nodes that appear as data tree or operation nodes in RFC8340 tree output, while typedef introduces a type definition that other nodes reference by name. The cost of picking any of them is therefore a keyword-to-grammar mismatch: the candidate would fail to recognize where derived types appear in a payload built from the model.
The decisive condition inside this scenario is that YANG typedef must produce a reusable named type that other declarations can reference, and A is the only option that names that product. A typedef statement takes an optional status and description, a derived type name such as percent, and a base type such as uint8, then optionally narrows the value space with a range or pattern or constrains it with a length or enum — exactly the mechanism that makes the name reusable everywhere a uint8 would otherwise be written. Once percent exists, a leaf such as utilization can be declared with type percent, and any other module or grouping that imports the definition gets the same 0-100 bound without restating the range. The reuse is lexical and static: the derived type travels with the module's schema, so a payload validator enforces the tightened range at every leaf that adopts it. That is a datatype declaration, not a container, list, or rpc, which is why option A holds while B, C, and D describe schema structure instead.
A named alternative becomes right only if the statement being asked about introduced a reusable schema construct rather than a reusable value type, and no such condition is present here. If the stem asked what groups a set of sibling nodes for embedding inside a container or rpc, the container option would carry the day, because containers do scope reusable subtrees through groupings — but a container itself defines a place in the data tree, not something a leaf can be typed with. If the stem asked what declares ordered instance records with keys, the list option would win, since lists own key, unique, and user-ordered attributes. If the stem asked what defines a NETCONF or RESTCONF operation exposed by the device, the rpc option would win, because rpcs name operations and their input/output payload rather than a datatype. None of those questions is in play: the stem names typedef and asks about its purpose, so the structure-defining keywords remain adjacent grammar with no claim on the answer.
Carry one rule to every other YANG-grammar item: sort each keyword by what it produces — a type name, a data-tree node, or an operation — and match the stem to that product. If the stem says type, typedef is the only keyword among these four that yields a name usable in a type statement, so A follows immediately without reading the distractors in depth. Applied to payload construction, a derived type such as percent means any leaf adopting it inherits the range, length, or pattern restriction, so a JSON or XML value outside 0-100 is rejected by the schema even though the base uint8 would have accepted it — worth checking whenever a pyang tree or YANG Suite output shows a typedef-referenced leaf. When the stem instead names structure, key handling, or remote operations, switch to container, list, and rpc respectively. Also remember that typedefs can be nested inside a container, list, or rpc scope, so location in the module does not change the rule: only the produced artifact decides.
Official Reference
https://datatracker.ietf.org/doc/html/rfc7950#section-7.3
This link opens the official vendor documentation in a new tab.
Exam Strategy
On YANG-grammar items, classify each keyword by what it emits: a type name, a data-tree node, or an operation, then match the stem's noun to that class. Here the stem says typedef, and among container, list, and rpc only a typedef produces something a leaf can be typed with, so A survives even if you skim the distractors. Apply the same sort whenever a payload or pyang tree question names a keyword you do not immediately recognize.
Related Analysis
Practice All 300-435 Questions
Access 150 questions with complete answers and detailed explanations.
View Full 300-435 Practice Test →