@@ -1797,7 +1797,7 @@ namespace ts {
17971797 case SyntaxKind . PropertyDeclaration :
17981798 case SyntaxKind . MethodDeclaration :
17991799 if ( ( < ParameterDeclaration | PropertyDeclaration | MethodDeclaration > parent ) . questionToken === node ) {
1800- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . _0_can_only_be_used_in_a_ts_file , "?" ) ) ;
1800+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . The_0_modifier_can_only_be_used_in_TypeScript_files , "?" ) ) ;
18011801 return ;
18021802 }
18031803 // falls through
@@ -1811,45 +1811,48 @@ namespace ts {
18111811 case SyntaxKind . VariableDeclaration :
18121812 // type annotation
18131813 if ( ( < FunctionLikeDeclaration | VariableDeclaration | ParameterDeclaration | PropertyDeclaration > parent ) . type === node ) {
1814- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . types_can_only_be_used_in_a_ts_file ) ) ;
1814+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Type_annotations_can_only_be_used_in_TypeScript_files ) ) ;
18151815 return ;
18161816 }
18171817 }
18181818
18191819 switch ( node . kind ) {
18201820 case SyntaxKind . ImportEqualsDeclaration :
1821- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . import_can_only_be_used_in_a_ts_file ) ) ;
1821+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . import_can_only_be_used_in_TypeScript_files ) ) ;
18221822 return ;
18231823 case SyntaxKind . ExportAssignment :
18241824 if ( ( < ExportAssignment > node ) . isExportEquals ) {
1825- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . export_can_only_be_used_in_a_ts_file ) ) ;
1825+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . export_can_only_be_used_in_TypeScript_files ) ) ;
18261826 return ;
18271827 }
18281828 break ;
18291829 case SyntaxKind . HeritageClause :
18301830 const heritageClause = < HeritageClause > node ;
18311831 if ( heritageClause . token === SyntaxKind . ImplementsKeyword ) {
1832- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . implements_clauses_can_only_be_used_in_a_ts_file ) ) ;
1832+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . implements_clauses_can_only_be_used_in_TypeScript_files ) ) ;
18331833 return ;
18341834 }
18351835 break ;
18361836 case SyntaxKind . InterfaceDeclaration :
1837- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . interface_declarations_can_only_be_used_in_a_ts_file ) ) ;
1837+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Interface_declaration_cannot_have_implements_clause ) ) ;
18381838 return ;
18391839 case SyntaxKind . ModuleDeclaration :
1840- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . module_declarations_can_only_be_used_in_a_ts_file ) ) ;
1840+ const moduleKeyword = node . flags & NodeFlags . Namespace ? tokenToString ( SyntaxKind . NamespaceKeyword ) : tokenToString ( SyntaxKind . ModuleKeyword ) ;
1841+ Debug . assertDefined ( moduleKeyword ) ;
1842+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . _0_declarations_can_only_be_used_in_TypeScript_files , moduleKeyword ) ) ;
18411843 return ;
18421844 case SyntaxKind . TypeAliasDeclaration :
1843- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . type_aliases_can_only_be_used_in_a_ts_file ) ) ;
1845+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Type_aliases_can_only_be_used_in_TypeScript_files ) ) ;
18441846 return ;
18451847 case SyntaxKind . EnumDeclaration :
1846- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . enum_declarations_can_only_be_used_in_a_ts_file ) ) ;
1848+ const enumKeyword = Debug . assertDefined ( tokenToString ( SyntaxKind . EnumKeyword ) ) ;
1849+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . _0_declarations_can_only_be_used_in_TypeScript_files , enumKeyword ) ) ;
18471850 return ;
18481851 case SyntaxKind . NonNullExpression :
1849- diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . non_null_assertions_can_only_be_used_in_a_ts_file ) ) ;
1852+ diagnostics . push ( createDiagnosticForNode ( node , Diagnostics . Non_null_assertions_can_only_be_used_in_TypeScript_files ) ) ;
18501853 return ;
18511854 case SyntaxKind . AsExpression :
1852- diagnostics . push ( createDiagnosticForNode ( ( node as AsExpression ) . type , Diagnostics . type_assertion_expressions_can_only_be_used_in_a_ts_file ) ) ;
1855+ diagnostics . push ( createDiagnosticForNode ( ( node as AsExpression ) . type , Diagnostics . Type_assertion_expressions_can_only_be_used_in_TypeScript_files ) ) ;
18531856 return ;
18541857 case SyntaxKind . TypeAssertionExpression :
18551858 Debug . fail ( ) ; // Won't parse these in a JS file anyway, as they are interpreted as JSX.
@@ -1878,7 +1881,7 @@ namespace ts {
18781881 case SyntaxKind . ArrowFunction :
18791882 // Check type parameters
18801883 if ( nodes === ( < DeclarationWithTypeParameterChildren > parent ) . typeParameters ) {
1881- diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . type_parameter_declarations_can_only_be_used_in_a_ts_file ) ) ;
1884+ diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . Type_parameter_declarations_can_only_be_used_in_TypeScript_files ) ) ;
18821885 return ;
18831886 }
18841887 // falls through
@@ -1894,7 +1897,7 @@ namespace ts {
18941897 if ( nodes === ( < PropertyDeclaration > parent ) . modifiers ) {
18951898 for ( const modifier of < NodeArray < Modifier > > nodes ) {
18961899 if ( modifier . kind !== SyntaxKind . StaticKeyword ) {
1897- diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . _0_can_only_be_used_in_a_ts_file , tokenToString ( modifier . kind ) ) ) ;
1900+ diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . The_0_modifier_can_only_be_used_in_TypeScript_files , tokenToString ( modifier . kind ) ) ) ;
18981901 }
18991902 }
19001903 return ;
@@ -1903,7 +1906,7 @@ namespace ts {
19031906 case SyntaxKind . Parameter :
19041907 // Check modifiers of parameter declaration
19051908 if ( nodes === ( < ParameterDeclaration > parent ) . modifiers ) {
1906- diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . parameter_modifiers_can_only_be_used_in_a_ts_file ) ) ;
1909+ diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . Parameter_modifiers_can_only_be_used_in_TypeScript_files ) ) ;
19071910 return ;
19081911 }
19091912 break ;
@@ -1915,7 +1918,7 @@ namespace ts {
19151918 case SyntaxKind . TaggedTemplateExpression :
19161919 // Check type arguments
19171920 if ( nodes === ( < NodeWithTypeArguments > parent ) . typeArguments ) {
1918- diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . type_arguments_can_only_be_used_in_a_ts_file ) ) ;
1921+ diagnostics . push ( createDiagnosticForNodeArray ( nodes , Diagnostics . Type_arguments_can_only_be_used_in_TypeScript_files ) ) ;
19191922 return ;
19201923 }
19211924 break ;
@@ -1941,7 +1944,7 @@ namespace ts {
19411944 case SyntaxKind . ReadonlyKeyword :
19421945 case SyntaxKind . DeclareKeyword :
19431946 case SyntaxKind . AbstractKeyword :
1944- diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . _0_can_only_be_used_in_a_ts_file , tokenToString ( modifier . kind ) ) ) ;
1947+ diagnostics . push ( createDiagnosticForNode ( modifier , Diagnostics . The_0_modifier_can_only_be_used_in_TypeScript_files , tokenToString ( modifier . kind ) ) ) ;
19451948 break ;
19461949
19471950 // These are all legal modifiers.
0 commit comments