@@ -1937,6 +1937,7 @@ namespace ts {
19371937 }
19381938
19391939 export function createVariableDeclaration ( name : string | BindingName , type ?: TypeNode , initializer ?: Expression ) {
1940+ /* Internally, one should probably use createTypeScriptVariableDeclaration instead and handle definite assignment assertions */
19401941 const node = < VariableDeclaration > createSynthesizedNode ( SyntaxKind . VariableDeclaration ) ;
19411942 node . name = asName ( name ) ;
19421943 node . type = type ;
@@ -1945,13 +1946,34 @@ namespace ts {
19451946 }
19461947
19471948 export function updateVariableDeclaration ( node : VariableDeclaration , name : BindingName , type : TypeNode | undefined , initializer : Expression | undefined ) {
1949+ /* Internally, one should probably use updateTypeScriptVariableDeclaration instead and handle definite assignment assertions */
19481950 return node . name !== name
19491951 || node . type !== type
19501952 || node . initializer !== initializer
19511953 ? updateNode ( createVariableDeclaration ( name , type , initializer ) , node )
19521954 : node ;
19531955 }
19541956
1957+ /* @internal */
1958+ export function createTypeScriptVariableDeclaration ( name : string | BindingName , exclaimationToken ?: Token < SyntaxKind . ExclamationToken > , type ?: TypeNode , initializer ?: Expression ) {
1959+ const node = < VariableDeclaration > createSynthesizedNode ( SyntaxKind . VariableDeclaration ) ;
1960+ node . name = asName ( name ) ;
1961+ node . type = type ;
1962+ node . initializer = initializer !== undefined ? parenthesizeExpressionForList ( initializer ) : undefined ;
1963+ node . exclamationToken = exclaimationToken ;
1964+ return node ;
1965+ }
1966+
1967+ /* @internal */
1968+ export function updateTypeScriptVariableDeclaration ( node : VariableDeclaration , name : BindingName , exclaimationToken : Token < SyntaxKind . ExclamationToken > | undefined , type : TypeNode | undefined , initializer : Expression | undefined ) {
1969+ return node . name !== name
1970+ || node . type !== type
1971+ || node . initializer !== initializer
1972+ || node . exclamationToken !== exclaimationToken
1973+ ? updateNode ( createTypeScriptVariableDeclaration ( name , exclaimationToken , type , initializer ) , node )
1974+ : node ;
1975+ }
1976+
19551977 export function createVariableDeclarationList ( declarations : readonly VariableDeclaration [ ] , flags = NodeFlags . None ) {
19561978 const node = < VariableDeclarationList > createSynthesizedNode ( SyntaxKind . VariableDeclarationList ) ;
19571979 node . flags |= flags & NodeFlags . BlockScoped ;
0 commit comments