Strict null checks for Map members
<!-- BUGS: Please use this template. --> <!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript --> <!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md --> **TypeScript Version:** 2.0.0-beta **Code** ``` ts 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?
Posted by sanex3339 on Jul 11, 2016, 7:25 PM
Tags
Related issues
- Add 65536 size support for maps
- TypeScript 7.1 Iteration Plan
- nvim-treeconfig: upstream nvim-treesitter
- Add the "action" and "method" attributes to <button>
- [FEATURE] Support multiple Connector accounts (same connector, different accounts) in Claude and Claude Code on the web (claude.ai/code)
- > We were imposed GitHub for so many exercises!
Raise real-world problems, find people facing the same issue, and discuss solutions.5,000 issues0 comments
support (Software)
Add 65536 size support for maps
TypeScript 7.1 Iteration Plan
nvim-treeconfig: upstream nvim-treesitter
Add the "action" and "method" attributes to <button>
[FEATURE] Support multiple Connector accounts (same connector, different accounts) in Claude and Claude Code on the web (claude.ai/code)
> We were imposed GitHub for so many exercises!
Add support for Visual Studio 2026 Integration
Support for Helm v4
Strict null checks for Map members
<!-- BUGS: Please use this template. --> <!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript --> <!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md --> **TypeScript Version:** 2.0.0-beta **Code** ``` ts 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?
Comments (0)
No comments yet. Start the discussion.