-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 2.0.0-beta
Code
export interface INode {
type: string;
parentNode?: INode;
}
export interface IIdentifierNode extends INode {
name: string;
}
public static isIdentifierNode (node: INode): node is IIdentifierNode {
return node.type === NodeType.Identifier;
}
var namesMap = new Map<string, string>();
// main part
if (Nodes.isIdentifierNode(node) && namesMap.has(node.name)) {
node.name = namesMap.get(node.name); //`Type 'string | undefined' is not assignable to type 'string'.`
}
Expected behavior:
No errors
Actual behavior:
Type 'string | undefined' is not assignable to type 'string'.
Looks like here no TypeGuards for Maps?
aseemk, kitsonk, fusepilot, philipstanislaus, Smert and 170 more
Metadata
Metadata
Assignees
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript